1. Sequence trouble
- Posted by Eduardo Uemura Okada <cool at ART.COM.BR> Jul 16, 1997
- 751 views
Hi to all. Recently, I was working on a shape loader/writer/scanner and others "er", but something is not quite right. Sometime past, I did some sequence tests, and I found that if I declare a sequence, and put each value, like sequence[1]=xxx, sequence[2]=aaa, ex.err returned that the sequence value was zero!! Someone can explain it to me? I really need help!! Eduardo Uemura Okada e-mail: cool at art.com.br
2. Sequence trouble
- Posted by Craig Gilbert <cgilbert at CENNET.MC.PEACHNET.EDU> Jul 16, 1997
- 738 views
Eumura, you wrote: > Sometime past, I did some sequence tests, and I found that if I declare a >sequence, and put each value, like sequence[1]=xxx, sequence[2]=aaa, ex.err >returned that the sequence value was zero!! I'm not exactly clear on the situation you are describing, but if you are doing this . . . sequence s s[1] = 5 s[2] = 4 . . . then you will definitely get an error because the sequence has not been initialized, only declared, and so it does not actually *have* element 1, 2, etc. yet. That shouldn't give an error return of s = 0, but it will say this (in ex.err): s = <no value> Craig
3. Sequence trouble
- Posted by Eduardo Uemura Okada <cool at ART.COM.BR> Jul 17, 1997
- 719 views
Hey Craig (Gilbert) and anyone, what I mean is: sequence data data[1]=12 data[2]=23 data[3]=54 data=append(data,{data[1],data[2],data[3]}) ex.err results: data=<no value> That's just an example, but my real situation is a sequence in what each element is a sequence of 3 numbers, just like {{1,2,3},{4,5,6},{7,8,9},{.,.,.},...}. Anyone have a solution to put the values in the sequence without return <no value> ? I'll be thankful Eduardo Uemura Okada e-mail: cool at art.com.br
4. Re: Sequence trouble
- Posted by James Powell <jpowell at TELEPORT.COM> Jul 17, 1997
- 732 views
Eduardo Uemura Okada <cool at ART.COM.BR> wrote: > Hey Craig (Gilbert) and anyone, what I mean is: > > sequence data > data[1]=12 > data[2]=23 > data[3]=54 > data=append(data,{data[1],data[2],data[3]}) > > ex.err results: data=<no value> > > That's just an example, but my real situation is a sequence in what each > element is a sequence of 3 numbers, just like > {{1,2,3},{4,5,6},{7,8,9},{.,.,.},...}. > Anyone have a solution to put the values in the sequence without return > <no value> ? > I'll be thankful Craig's reply to your first message was correct. Once you declare a sequence, you CANNOT refer to it using a subscript unless you first give it some subscripts. What I mean is that for the following code, you cannot assign a value to x[i]: sequence x x[1] = 5 x[10] = 50 Both x[1] and x[10] will crash the program because x does not yet have a subscript value of 1 or 10. Instead, you must put your data into x directly (not referring to it with subscripts) or initialize x using the repeat() function. For example: sequence x x = {5,0,0,0,0,0,0,0,0,50} AND sequence x x = repeat(0, 10) x[1] = 5 x[10] = 50 Will both result in a sequence where x = {5,0,0,0,0,0,0,0,0,50} that can now be referred to using a subscript [i] where 1<=i<=10. I hope this helps. Maybe someone else can give a clearer answer than this if it hasn't. James Powell
5. Re: Sequence trouble
- Posted by Craig Gilbert <cgilbert at CENNET.MC.PEACHNET.EDU> Jul 17, 1997
- 714 views
Eduardo wrote: >sequence data >data[1] = 12 >data[2] = 23 >data[3] = 54 >data = append(data,{data[1],data[2],data[3]}) > . . .(SKIPPED) . . .my real situation is a sequence in what each >element is a sequence of 3 numbers, just like >{{1,2,3},{4,5,6},{7,8,9},{.,.,.},...}. Looks to me like you still have the problem of not initializing the data var. Try this: sequence data data = {} -- initialize it! data = append( data, {1,2,3} ) data = append( data, {4,5,6} ) -- etc., data should now be { {1,2,3}, {4,5,6} } Craig
6. Re: Sequence trouble
- Posted by Daniel Berstein <danielberstein at USA.NET> Jul 17, 1997
- 734 views
> sequence data > data[1]=12 > data[2]=23 > data[3]=54 > data=append(data,{data[1],data[2],data[3]}) > > ex.err results: data=<no value> Hi Eduardo, Maybe you write wrong the code in your mail, but maybe the bug is that you declared the sequence "sequence data" and then just started doing "data[x]=y" wich is WRONG. You must first give a value to "data" so Euphoria knows it's shape.. just after declaration, "data" is an empty sequence "{}". You code should look like this: sequence data data = {12,23,54} data=append(data,{data[1],data[2],data[3]}) Now data should be: {12,23,54,{12,23,54}} Other way could be: sequence data data = repeat({},3) --Replace "3" with the length you want data[1]=12 data[2]=23 data[3]=54 ... If you want to make a sequence of sequences ("{{1,1,1},{1,1,1}....}") then use something like: sequence data data=repeat(repeat({},3),10) data[1][1]=xxx data[1][2]=xxx data[1][3]=xxx .... data[10][3]=xxx This creates a sequence ("data") of length 10, and each of this elements is a sequence itself of length 3. Hope this helps... Regards, Daniel Berstein danielberstein at usa.net http://www.geocities.com/SiliconValley/Heights/9316