1. Using squences with a for lop
- Posted by Ron Austin <ronaustin at alltel.net> Oct 25, 2003
- 360 views
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.
2. Re: Using squences with a for lop
- Posted by Irv <irvm at ellijay.com> Oct 25, 2003
- 378 views
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
3. Re: Using squences with a for lop
- Posted by "Greg Haberek" <g.haberek at comcast.net> Oct 25, 2003
- 368 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! > >
4. Re: Using squences with a for lop
- Posted by "Greg Haberek" <g.haberek at comcast.net> Oct 25, 2003
- 362 views
stupd Ctrl+Enter!! I was fumbling around my keyboard and accidently sent the last post too early! here's what's left: sequence Lbl, Data Lbl = {} -- initialize with empty value Data = {} Lbl = resizeSeq( Lbl, 2, 0 ) -- same as Lbl &= repeat(0, 2) or Lbl &= {0,0} Lbl[1] = create(LText,"Code",Win,20,50,60,20,0), Data[1] = create(EditText,"",Win,100,50,42,20,ES_UPPERCASE), Lbl[2] = create(LText,"Description",Win,20,80,60,20,0), Data[2] = create(EditText,"",Win,100,80,278,20,ES_UPPERCASE) -- an easier way to do the above, however, is just using &= sequence Lbl, Data Lbl = {} Data = {} Lbl &= create(LText,"Code",Win,20,50,60,20,0), Data &= create(EditText,"",Win,100,50,42,20,ES_UPPERCASE), Lbl &= create(LText,"Description",Win,20,80,60,20,0), Data &= create(EditText,"",Win,100,80,278,20,ES_UPPERCASE) ----- 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! > >
5. Re: Using squences with a for lop
- Posted by "Stewart MacKenzie-Leigh" <stewartml89 at msn.com> Oct 26, 2003
- 374 views
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. > >
6. Re: Using squences with a for lop
- Posted by "Ron Austin" <ronaustin at alltel.net> Oct 26, 2003
- 361 views
--------------Boundary-00=3D_AYMDCJD0000000000000 charset=3D"iso-8859-1" Thanks Stewart and the rest of you who offered solutions. I have to forget= my 20 years programing in basic and start thinking in Euphoria. I probably= will have a lot more questions before I master this language. At least I a= m getting further than I did in Access and Virtual Basic.=0D =0D -------Original Message-------=0D =0D From: EUforum at topica.com=0D Date: Sunday, October 26, 2003 12:50:58 PM=0D To: EUforum at topica.com=0D Subject: Re: Using squences with a for lop=0D =0D =0D =0D =0D If the sequence is not initialized or has less elements than the element yo= u =0D are trying to reference, it doesn't work. You have to set up the sequence = =0D to have the correct number of elements.=0D =0D e.g.=0D sequence seq=0D seq =3D {1,2,3,4,5} -- five elements=0D seq[6] =3D foobar -- error=0D =0D try:=0D sequence seq=0D seq =3D repeat(0,6) --set the number of elements up at the start=0D seq[foo] =3D bar=0D =0D or=0D =0D sequence seq=0D seg =3D {1,2,3,4,5} --sample sequence=0D seq =3D append(seq,foobar) --apend element=0D =0D =0D =0D StewartML=0D =0D =0D original message:=0D >From: Ron Austin <ronaustin at alltel.net>=0D >Reply-To: EUforum at topica.com=0D >To: EUforum at topica.com=0D >Subject: Using squences with a for lop=0D >Date: Sat, 25 Oct 2003 13:43:07 +0000=0D >=0D >=0D >I have made a simple program which stores a couple of fields=0D >=0D >- snip=0D >constant=0D >Lbl1 =3D create(LText,"Code",Win,20,50,60,20,0),=0D >Code =3D create(EditText,"",Win,100,50,42,20,ES_UPPERCASE),=0D >=0D >Lbl2 =3D create(LText,"Description",Win,20,80,60,20,0),=0D >Desc =3D create(EditText,"",Win,100,80,278,20,ES_UPPERCASE),=0D >=0D >--snip=0D >=0D > err =3D db_select_table("Diagnosis")=0D > err =3D db_insert(getText(Code),Diag_Data)=0D >--snip=0D >=0D >Which is working okay with a couple of fields, but what if I want to=0D >store 10, or 100?=0D >=0D >I know the answer is to use sequences and a for loop. I can get data=0D >out of a sequence using [], but how do you get it in?=0D >=0D >I tried this and that didn't work=0D >=0D >sequence=0D >=0D >Lbl1 =3D create(LText,"Code",Win,20,50,60,20,0),=0D >data[1] =3D create(EditText,"",Win,100,50,42,20,ES_UPPERCASE),=0D >=0D >Lbl2 =3D create(LText,"Description",Win,20,80,60,20,0),=0D >data[2] =3D create(EditText,"",Win,100,80,278,20,ES_UPPERCASE)=0D >=0D >I've read the manual and looked at programs, but I can't figure this=0D >out. I need to get this program running and I'm stuck.=0D >=0D >=0D =0D =0D =0D Or send an email to: EUforum-unsubscribe at topica.com=0D =0D TOPICA - Start your own email discussion group. FREE!=0D =0D =0D =0D =0D .=20 --------------Boundary-00=3D_AYMDCJD0000000000000 Content-Type: Text/HTML; charset=3D"iso-8859-1" Content-Transfer-Encoding: 8bit <HTML><HEAD> <META http-equiv=3DContent-Type content=3D"text/html; charset=3Diso-8859-1"= > <META content=3D"IncrediMail 1.0" name=3DGENERATOR> <!--IncrdiXMLRemarkStart> <IncrdiX-Info> <X-FID>FLAVOR00-NONE-0000-0000-000000000000</X-FID> <X-FVER></X-FVER> <X-CNT>;</X-CNT> </IncrdiX-Info> <IncrdiXMLRemarkEnd--> </HEAD> <BODY style=3D"BACKGROUND-POSITION: 0px 0px; FONT-SIZE: 12pt; MARGIN: 5px 1= 0px 10px; FONT-FAMILY: Arial" bgColor=3D#ffffff background=3D"" scroll=3Dye= s ORGYPOS=3D"0" X-FVER=3D"3.0"> <TABLE id=3DINCREDIMAINTABLE cellSpacing=3D0 cellPadding=3D2 width=3D"100%"= border=3D0> <TBODY> <TR> <TD id=3DINCREDITEXTREGION style=3D"FONT-SIZE: 12pt; CURSOR: auto; FONT-FAM= ILY: Arial" width=3D"100%"> <DIV>Thanks Stewart and the rest of you who offered solutions. I have= to forget my 20 years programing in basic and start thinking in Euphoria.&= nbsp; I probably will have a lot more questions before I master this langua= ge. At least I am getting further than I did in Access and Virtual Ba= sic.<BR> </DIV> <DIV id=3DIncrediOriginalMessage><I>-------Original Message-------</I></DIV= > <DIV> </DIV> <DIV id=3Dreceivestrings> <DIV dir=3Dltr style=3D"FONT-SIZE: 11pt" <i><B>From:</B></I> <A href=3D"mai= lto:EUforum at topica.com">EUforum at topica.com</A></DIV> <DIV dir=3Dltr style=3D"FONT-SIZE: 11pt" <i><B>Date:</B></I> Sunday, Octobe= r 26, 2003 12:50:58 PM</DIV> <DIV dir=3Dltr style=3D"FONT-SIZE: 11pt" <i><B>To:</B></I> <A href=3D"mailt= o:EUforum at topica.com">EUforum at topica.com</A></DIV> <DIV dir=3Dltr style=3D"FONT-SIZE: 11pt" <i><B>Subject:</B></I> Re: Using s= quences with a for lop</DIV></DIV> <DIV> </DIV>=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D The Euphoria Mailing = List =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D <BR><BR><BR><BR>If the sequence i= s not initialized or has less elements than the element you <BR>are trying = to reference, it doesn't work. You have to set up the sequence <BR>to have = the correct number of elements.<BR><BR>e.g.<BR>sequence seq<BR>seq =3D {1,2= ,3,4,5} -- five elements<BR>seq[6] =3D foobar -- error<BR><BR>try:<BR>seque= nce seq<BR>seq =3D repeat(0,6) --set the number of elements up at the start= <BR>seq[foo] =3D bar<BR><BR>or<BR><BR>sequence seq<BR>seg =3D {1,2,3,4,5} -= -sample sequence<BR>seq =3D append(seq,foobar) --apend element<BR><BR><BR><= BR>StewartML<BR><BR><BR>original message:<BR>>From: Ron Austin <<A hr= ef=3D"mailto:ronaustin at alltel.net">ronaustin at alltel.net</A>><BR>>Repl= y-To: <A href=3D"mailto:EUforum at topica.com">EUforum at topica.com</A><BR>>T= o: <A href=3D"mailto:EUforum at topica.com">EUforum at topica.com</A><BR>>Subj= ect: Using squences with a for lop<BR>>Date: Sat, 25 Oct 2003 13:43:07 += 0000<BR>><BR>><BR>>I have made a simple program which stores a cou= ple of fields<BR>><BR>>- snip<BR>>constant<BR>>Lbl1 =3D create(= LText,"Code",Win,20,50,60,20,0),<BR>>Code =3D create(EditText,"",Win,100= ,50,42,20,ES_UPPERCASE),<BR>><BR>>Lbl2 =3D create(LText,"Description"= ,Win,20,80,60,20,0),<BR>>Desc =3D create(EditText,"",Win,100,80,278,20,E= S_UPPERCASE),<BR>><BR>>--snip<BR>><BR>> err =3D db_select_table= ("Diagnosis")<BR>> err =3D db_insert(getText(Code),Diag_Data)<BR>>--s= nip<BR>><BR>>Which is working okay with a couple of fields, but what = if I want to<BR>>store 10, or 100?<BR>><BR>>I know the answer is t= o use sequences and a for loop. I can get data<BR>>out of a sequence usi= ng [], but how do you get it in?<BR>><BR>>I tried this and that didn'= t work<BR>><BR>>sequence<BR>><BR>>Lbl1 =3D create(LText,"Code",= Win,20,50,60,20,0),<BR>>data[1] =3D create(EditText,"",Win,100,50,42,20,= ES_UPPERCASE),<BR>><BR>>Lbl2 =3D create(LText,"Description",Win,20,80= ,60,20,0),<BR>>data[2] =3D create(EditText,"",Win,100,80,278,20,ES_UPPER= CASE)<BR>><BR>>I've read the manual and looked at programs, but I can= 't figure this<BR>>out. I need to get this program running and I'm stuck= .<BR>><BR>><BR><BR>--^-----------------------------------------------= -----------------<BR>This email was sent to: <A href=3D"mailto:ronaustin@al= ltel.net">ronaustin at alltel.net</A><BR><BR>EASY UNSUBSCRIBE click here: <A h= ref=3D"http://topica.com/u/?b1dd66.b6KEgr.cm9uYXVz">http://topica.com/u/?b1= dd66.b6KEgr.cm9uYXVz</A><BR>Or send an email to: <A href=3D"mailto:EUforum-= unsubscribe at topica.com">EUforum-unsubscribe at topica.com</A><BR><BR>TOPICA - = Start your own email discussion group. FREE!<BR><A href=3D"http://www.topic= a.com/partner/tag02/create/index2.html">http://www.topica.com/partner/tag02= /create/index2.html</A><BR>--^---------------------------------------------= -------------------<BR><BR><BR><BR><BR>. </TD></TR> <TR> <TD id=3DINCREDIFOOTER width=3D"100%"> <TABLE cellSpacing=3D0 cellPadding=3D0 width=3D"100%"> <TBODY> <TR> <TD width=3D"100%"></TD> <TD id=3DINCREDISOUND vAlign=3Dbottom align=3Dmiddle></TD> <TD id=3DINCREDIANIM vAlign=3Dbottom align=3Dmiddle></TD></TR></TBODY></TAB= --------------Boundary-00=3D_AYMDCJD0000000000000--
7. Re: Using squences with a for lop
- Posted by Derek Parnell <ddparnell at bigpond.com> Oct 26, 2003
- 382 views
>----- Original Message ----- >From: "Ron Austin" <ronaustin at alltel.net> >To: <EUforum at topica.com> >Subject: Re: Using squences with a for lop Ron, whatever email client you are using, please adjust it to use text only. The above four lines is the ONLY thing I can see in your message (again). -- Derek
8. Re: Using squences with a for lop
- Posted by Pete Lomax <petelomax at blueyonder.co.uk> Oct 26, 2003
- 365 views
On Sun, 26 Oct 2003 18:43:55 +0000, Ron Austin <ronaustin at alltel.net> wrote: >Virtual Basic. I like that Pete