1. RE: Eu Doc's
- Posted by Mindpower <mindpower at mediaone.net> Apr 11, 2001
- 450 views
Thomas Parslow (PatRat) wrote: > > Hi Robert Hi All, > > I am not new to Euphoria but I have not used Euphoria in a very long > > time. Anyway I am back with Euphoria again and I can't remember some > > things about it. I clipped this from the documentation but I am not > > understanding something here and I know this may seem simple but here it > > > > goes anyway. In Example 2 below what variable type is "i" in the line > > "for i = 1 to length(x) do". I tried this same simple for loop and > > declared i as an integer but when I run the program it says that I am > > trying to redefine that variable. If anyone could give me a kick start > > back into Eu I would greatly appreciate it. > > the for..do..end for statement automatically declares the counter > variable. That means that you do not need to (and indeed cannot) > declare it yourself. You can use the counter (i) within the for loop > but not outside it. > > Thomas Parslow (PatRat) ICQ #:26359483 > Rat Software > http://www.rat-software.com/ > Please leave quoted text in place when replying > > > Hi Thomas, Thank you for the information but that still does not tell me what type of variable "i" is???? I guess my point is what type of variable does the length() routine return? I thought it was an integer but I guess it is some other type???? See ya on the NetMindPower
2. RE: Eu Doc's
- Posted by Brian Broker <bkb at cnw.com> Apr 11, 2001
- 444 views
Mindpower, The reference manual explains: To indicate what kind of object may be passed in and returned, the following prefixes are used: x - a general object (atom or sequence) s - a sequence a - an atom i - an integer fn - an integer used as a file number st - a string sequence, or single-character atom ---------- Also, the reference manual explains the types listed above. -- Brian Mindpower wrote: > > Thomas Parslow (PatRat) wrote: > > > Hi Robert Hi All, > > > I am not new to Euphoria but I have not used Euphoria in a very long > > > time. Anyway I am back with Euphoria again and I can't remember some > > > things about it. I clipped this from the documentation but I am not > > > understanding something here and I know this may seem simple but here it > > > > > > > > > goes anyway. In Example 2 below what variable type is "i" in the line > > > "for i = 1 to length(x) do". I tried this same simple for loop and > > > declared i as an integer but when I run the program it says that I am > > > trying to redefine that variable. If anyone could give me a kick start > > > back into Eu I would greatly appreciate it. > > > > the for..do..end for statement automatically declares the counter > > variable. That means that you do not need to (and indeed cannot) > > declare it yourself. You can use the counter (i) within the for loop > > but not outside it. > > > > Thomas Parslow (PatRat) ICQ #:26359483 > > Rat Software > > http://www.rat-software.com/ > > Please leave quoted text in place when replying > > > > > > > Hi Thomas, > Thank you for the information but that still does not tell me what type > of variable "i" is???? I guess my point is what type of variable does > the length() routine return? I thought it was an integer but I guess it > > is some other type???? > > > See ya on the Net> MindPower > >
3. RE: Eu Doc's
- Posted by Mindpower <mindpower at mediaone.net> Apr 11, 2001
- 447 views
Brian Broker wrote: > Mindpower, > > The reference manual explains: > > To indicate what kind of object may be passed in and returned, the > following prefixes are used: > > x - a general object (atom or sequence) > s - a sequence > a - an atom > i - an integer > fn - an integer used as a file number > st - a string sequence, or single-character atom > > ---------- > Also, the reference manual explains the types listed above. > > -- Brian > > > Mindpower wrote: > > > > Thomas Parslow (PatRat) wrote: > > > > Hi Robert Hi All, > > > > I am not new to Euphoria but I have not used Euphoria in a very long > > > > time. Anyway I am back with Euphoria again and I can't remember some > > > > things about it. I clipped this from the documentation but I am not > > > > understanding something here and I know this may seem simple but here it > > > > > > > > > > > > > > > > > > > > goes anyway. In Example 2 below what variable type is "i" in the line > > > > "for i = 1 to length(x) do". I tried this same simple for loop and > > > > declared i as an integer but when I run the program it says that I am > > > > trying to redefine that variable. If anyone could give me a kick start > > > > back into Eu I would greatly appreciate it. > > > > > > the for..do..end for statement automatically declares the counter > > > variable. That means that you do not need to (and indeed cannot) > > > declare it yourself. You can use the counter (i) within the for loop > > > but not outside it. > > > > > > Thomas Parslow (PatRat) ICQ #:26359483 > > > Rat Software > > > http://www.rat-software.com/ > > > Please leave quoted text in place when replying > > > > > > > > > > > Hi Thomas, <snip> Sorry to waste everyones time and bandwidth but I found the answer to my question after scouring the Eu docs over and over again. See below information for the 'for' statement. Start reading the paragraph where it says "The loop variable is declared automatically and exists until the end of the loop." and you will see as well. It says I would have to dump out the value for the variable to another variable outside of the for loop to use that final value. That is all I wanted to be able to do is get the final value of that variable outside the loop. Actually I think that is what Thomas was saying but I didn't quite have the complete scope of this2.5.5 for statement A for statement sets up a special loop with a controlling loop variable that runs from an initial value up or down to some final value. e.g. for i = 1 to 10 do ? i -- ? is a short form for print() end for -- fractional numbers allowed too for i = 10.0 to 20.5 by 0.3 do for j = 20 to 10 by -2 do -- counting down ? {i, j} end for end for The loop variable is declared automatically and exists until the end of the loop. Outside of the loop the variable has no value and is not even declared. If you need its final value, copy it into another variable before leaving the loop. The compiler will not allow any assignments to a loop variable. The initial value, loop limit and increment must all be atoms. If no increment is specified then +1 is assumed. The limit and increment values are established when the loop is entered, and are not affected by anything that happens during the execution of the loop. See also the scope of the loop variable in 2.4.2 Scope. -- See ya on the Net
sequence mindpower, JK mindpower = {33,121,101,115,110,105,75, 32,121,110,110,104,111,74, 32,121,108,108,97,101,114, 32,115,105, 32,114,101,119,111,80,100,110,105,77} JK = {} for i = length(mindpower) to 1 by -1 do JK = append(JK, mindpower[i]) puts(2,"\n" & JK & "\n") end for -- execute as dos32 for my realname
-- remember programming should be fun -- end prog