Re: Beginners Guide Euphoria
- Posted by Michael Packard <lgp at EXO.COM> Feb 08, 1997
- 1268 views
On Sat, 8 Feb 1997, David Mosley wrote: >The problem I am having is > that when I try to declare a varable it keeps telling me that I am > wrong(e.g. c = c + 1) When I try to declare C I write atom c --It tells > me this is wrong so I try object c or integer c--but those are wrong too.I > have reread the frist part over again and looked in the manual and I can,t > see anything wrong HELP? > P.S. When I say I have "reread the frist part over again" I mean that I > have printed your data.doc out on my printer I find that it works good as a > refrence when I am try write a program.Hope that is ok! please tell me if > it is not. In the beginning of your code (usually) you declare you variables like this: atom c It doesn't give it ANY INITIAL VALUE WHEN YOU DECLARE IT. Unlike Basic, which just quietly assigns it to 0, Euphoria DOESN'T. Before you can go c=c+1, you need to give a an initial value. At the program start, you may say c=0 or whatever, then you are freee to add, subtract, or whatever to it, as long as you use legal values. If c is declared as an integer, you can't add fractional values to it (like c=c+.5). If c is an atom, you can add fractional values to it, but you can't add sequences to it, like c=c+{1,2,3,4}. If c is declared as a sequence or an object you can do all of the above. If c is the sequence {1,2,3,4} and you go c=c+1, you get c={2,3,4,5}. If c is a sequence of sequences like {{1,2},{3,4},{5,6}} c=c+1 gives c={{2,3},{4,5},{6,7}} I hope this helps... Michael Packard Lord Generic Productions lgp at exo.com http://exo.com/~lgp A Crash Course in Game Design and Production http://exo.com/~lgp/euphoria