Re: Using squences with a for lop
If the sequence is not initialized or has less elements than the element you
are trying to reference, it doesn't work. You have to set up the sequence
to have the correct number of elements.
e.g.
sequence seq
seq = {1,2,3,4,5} -- five elements
seq[6] = foobar -- error
try:
sequence seq
seq = repeat(0,6) --set the number of elements up at the start
seq[foo] = bar
or
sequence seq
seg = {1,2,3,4,5} --sample sequence
seq = append(seq,foobar) --apend element
StewartML
original message:
>From: Ron Austin <ronaustin at alltel.net>
>Reply-To: EUforum at topica.com
>To: EUforum at topica.com
>Subject: Using squences with a for lop
>Date: Sat, 25 Oct 2003 13:43:07 +0000
>
>
>I have made a simple program which stores a couple of fields
>
>- snip
>constant
>Lbl1 = create(LText,"Code",Win,20,50,60,20,0),
>Code = create(EditText,"",Win,100,50,42,20,ES_UPPERCASE),
>
>Lbl2 = create(LText,"Description",Win,20,80,60,20,0),
>Desc = create(EditText,"",Win,100,80,278,20,ES_UPPERCASE),
>
>--snip
>
> err = db_select_table("Diagnosis")
> err = db_insert(getText(Code),Diag_Data)
>--snip
>
>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)
>
>I've read the manual and looked at programs, but I can't figure this
>out. I need to get this program running and I'm stuck.
>
>
|
Not Categorized, Please Help
|
|