Re: Using squences with a for lop
- Posted by "Greg Haberek" <g.haberek at comcast.net> Oct 25, 2003
- 346 views
whenever you're indexing a sequence, that index must first exist. so you can not try to set mySeq[3] if mySeq is not at least 3 elements. here is a little function i like to use that i first saw in Don Phillips' xControls: function resizeSeq( sequence s1, integer len, object padding ) -- resizes 's1' to length 'len' by adding a sequence of 'padding' when necessary -- if the length of 's1' is already greater than or equal to 'len' the sequence is left alone if length(s1) < len then s1 &= repeat(padding, len-length(s1)) end if return s1 end function -- so you could do this: sequence Lbl ----- Original Message ----- From: "Ron Austin" <ronaustin at alltel.net> To: <EUforum at topica.com> Sent: Saturday, October 25, 2003 9:43 AM Subject: Using squences with a for lop > > > 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. > > > > > TOPICA - Start your own email discussion group. FREE! > >