Re: Using squences with a for lop

new topic     » goto parent     » topic index » view thread      » older message » newer message

On Saturday 25 October 2003 09:43 am, you wrote:

> I have made a simple program which stores a couple of fields
> Which is working okay with a couple of fields, but what if I want to
> store 10, or 100?
>
> I know the answer is to use sequences and a for loop.  I can get data
> out of a sequence using [], but how do you get it in?
>
> I tried this and that didn't work
>
> sequence
>
> Lbl1 = create(LText,"Code",Win,20,50,60,20,0),
> data[1] = create(EditText,"",Win,100,50,42,20,ES_UPPERCASE),
>
> Lbl2 = create(LText,"Description",Win,20,80,60,20,0),
> data[2] = create(EditText,"",Win,100,80,278,20,ES_UPPERCASE)

You could do this by declaring data as a sequence, then initializing it 
to the total number of data items you need: 

sequence data
 data = repeat (0, num_of_items)

Then
  data[1] = create(EditText,....)
  data[2] = create(EditText,....)
  etc.

To get the contents of the controls back as a sequence, use a for loop.
sequence all_data
all_data = {} 
for i = 1 to num_of_items do
  all_data = append(all_data,getText(data[i]))
end for

I think that should work.

Irv

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu