Arrays

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Arrays

gpatrick
I have iostat output in a file and need a cumulative total for each device.  I can do this in awk using:

awk '{await[$1]+=$10}END{for(j in await)print j" "await[j]}' x

Giving output like:
sdy 19.18
sdz 14.19

How would I accomplish this in NetRexx?

Thanks
Reply | Threaded
Open this post in threaded view
|

Re: Arrays

gpatrick
I'm doing this which obviously is wrong:

do
  loop forever
  line = source.readLine()
  c=c+1
   if line = null then leave
   parse line dev . . . . . . . . await . .
   device[dev]=await+await
   say c device[dev]
  end
 source.close()

Compilation succeeds but running it gives:
# java m
Exception in thread "main" java.lang.NumberFormatException: sda
    at netrexx.lang.Rexx.toint(Unknown Source)
    at m.main(m.nrx:21)