Search the web
Sign In
New User? Sign Up
geeksthatgawk · for GNU Awk questions & discussions
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Message search is now enhanced, find messages faster. Take it for a spin.

Best of Y! Groups

   Check them out and nominate your group.
Having problems with message search? Fill out this form to ensure your group is one of the first to be migrated to the new message search system.

Messages

  Messages Help
Advanced
Arry values not visible   Message List  
Reply | Forward Message #220 of 221 |
Re: [Geeks that Gawk] Arry values not visible

Hi Kaushik,

Try removing the "$" in ALL the array references,
for example: my_Array[$arr_Index] becomes my_Array[arr_Index]

Ambo

The bit of code I'm using to do this operation is as under -

awk -F"-!-" 'BEGIN{ TotalAlarms=0; InvalidAlarms=0;
OutstandingAlarms=0; TerminatedAlarms=0; AcknowledgedAlarms=0 }
/\/,/\/ {}
/^/ { arr_Index = 0 }
{

if ( $0 !~ /^/ && $0 !~ /^/ )
{
#printf "Line : %s\n", $0
#count = split ($0,Array,"-!-")
my_Array[$arr_Index]=sprintf("%s",$0)
printf ("-- Array %s : @ %d \n",my_Array[$arr_Index],arr_Index )
arr_Index++
}

if ( $0 ~ // )
{
print "Hope to see something in the array\n"
for ( i=0; i <= arr_Index; i++ )
{
printf ("Array Here @ %d is %s \n",i,my_Array[$i] )
}
}
}' /tmp/Recordfile

I'm unable to print the values stored in the array in the print statement

if ( $0 ~ // )
{
print "Hope to see something in the array\n"
for ( i=0; i <= arr_Index; i++ )
{
printf ("Array Here @ %d is %s \n",i,my_Array[$i] )
}
}

Can someone please help.

Thanks and regards
Kaushik





---------------------------------
Looking for earth-friendly autos?
Browse Top Cars by "Green Rating" at Yahoo! Autos' Green Center.

[Non-text portions of this message have been removed]




Thu Mar 22, 2007 3:47 am

aberdijo
Offline Offline
Send Email Send Email

Forward
Message #220 of 221 |
Expand Messages Author Sort by Date

Hi All, I'm trying to read a file which looks as below ( There are thousands of these records in the file )- <BEGINREC> ID -!- 359494 -!- ST -!- Outstanding ...
kaushik_908
Offline Send Email
Mar 20, 2007
12:41 pm

Hi Kaushik, Try removing the "$" in ALL the array references, for example: my_Array[$arr_Index] becomes my_Array[arr_Index] Ambo The bit of code...
Ambrosio Berdijo
aberdijo
Offline Send Email
Mar 22, 2007
3:47 am
Advanced

Copyright © 2009 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines - Help