Identify Array

Virgani Dhirgac

New Member
Gurus,

Errr First, hope I can speak clearly about this :)

Let's say that I've a codes like this:
------------------------------------------------------------------------------------------------
define variable aclass1 as integer extent 10 initial 0.
define variable aclass2 as integer extent 10 initial 0.
define variable aclass3 as integer extent 10 initial 0.
define variable nclass as integer label "Which Class".
define variable nloop as integer initial 1.

update nclass with frame nclass.

/*
assume nclass is not zero, and user's entry is 1 .. or 2 .. or 3 and so on ....
*/
case nclass:
when 1 then do:
do nloop = 1 to 10:
display aclass1[nloop] with frame xx.
end.
end.
when 2 then do:
do nloop = 1 to 10:
display aclass2[nloop] with frame xx.
end.
end.
when 3 then do:
do nloop = 1 to 10:
display aclass3[nloop] with frame xx.
end.
end.
end case.
------------------------------------------------------------------------------------------------

the question is, can I make above code more shorter with something like this:

do nloop = 1 to 10:
display aclass&&string(nclass)[nloop] with frame xx.
end.

so I dont have to use "CASE ... END CASE" ....

Hope you can understand.

Rgds,
Virgani
 
Something like this:

Code:
define temp-table ttClass no-undo
  field id       as integer
  field aClass as integer extent 10 initial 0
.

define variable nclass as integer label "Which Class".
define variable nloop as integer initial 1.

update nclass with frame nclass.

for each ttClass:
  do nloop = 1 to 10:
    display aClass[nloop] with frame xx.
  end.
  down 1 with frame xx.
end.

Of course you'll need to populate the TT but you also needed to populate the arrays and that wasn't shown either.
 
yup, I did.

try to change my programming style, leave all the variables and moved to table ... how fool I'm:D

old style programming ....

thanks all.
 
errr I think the code should be like this ?

define temp-table ttClass no-undo
field id as integer
field aClass as integer extent 10 initial 0
.

define variable nclass as integer label "Which Class".
define variable nloop as integer initial 1.

update nclass with frame nclass.

for each ttClass
where ttClass.id eq nclass:
do nloop = 1 to 10:
display aClass[nloop] with frame xx.
end.
down 1 with frame xx.
end.
 
Back
Top