Loop for awk



             In the following awk script

             BEGIN{
                     FS="|"
             }
             {
               if($1=="NAME"){
             VOLUME_NAME=$2
               }
               if($1=="LOCATION"){
                  LOCATION_LAT[i]=$2
                  LOCATION_LNG[i]=$3
                          LAT_DEG[i]=substr($2,1,2)
                          LAT_MIN[i]=substr($2,3,2)
                          LAT_SEC[i]=substr($2,5,2)
                          LNG_DEG[i]=substr($3,1,3)
                          LNG_MIN[i]=substr($3,4,2)
                          LNG_SEC[i]=substr($3,6,2)
                          LAT[i]=LAT_DEG[i] + LAT_MIN[i] / 60. + LAT_SEC[i] / 3600.
                          LNG[i]=LNG_DEG[i] + LNG_MIN[i] / 60. + LNG_SEC[i] / 3600.
                          ?????????????
                       }
                       if($1="DATA"){
                          ALT_LOW=$2
                          ALT_HIGH=$3
                       }
                       for(i=1;i<=???????????;i++){
                          print
             (VOLUME_NAME"|"LOCATION_LAT[i]","LOCATION_LNG[i]"|"LAT[i]"|"LNG[i]"|"ALT_LOW"|"ALT_HIGH)

             }
             }

             What is needed to make this for loop print correctly. I think I have to assign a number based on
             LOCATION_LAT[i] but I can't seem to get it right.

             Thanks
tomatocansAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

monasCommented:
If you know that data is the last, then you could print the line _WHEN_ you find that $1="DATA"
YOu won't need a loop.
0
prakashk021799Commented:
Look at my comment in your other question ("parsing"). Anyway, what's ans awk question doing in a perl forum?
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
tomatocansAuthor Commented:
Thanks. The perfect solution.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Perl

From novice to tech pro — start learning today.