RE: variable start values
- Posted by Jason Dube <dubetyrant at hotmail.com> Dec 10, 2003
- 502 views
Well ok, Sometimes it works and sometimes it doesn't. I went back and tested it several times without the var initializing and it generated the correct error message. The point is, sometimes it doesn't. I am assuming that I have to initialize every variable, but I have had euphoria for every year and this happens occassionally(like today) Jason Dube wrote: > > > Hi, > Im writing a simple punctuation checker, I get the following message > when I try to execute this: > > "capital1 has not been assigned a value" > > function check_for_punc_1(object x) > boolean capital1 > if x[1][1] < 90 then > position(2,1) > puts(1,"GARBLE: [Sentence is not capitalized...]") > capital1=0 > end if > return capital1 > end function > > Do I have to initialize it first? > Because I have noticed that at other times, with similar things, I dont > have to initialize... > For instance, if I go back to my function and add this line: > > function check_for_punc_1(object x) > boolean capital1 > capital1=1 > if x[1][1] < 90 then > position(2,1) > puts(1,"GARBLE: [Sentence is not capitalized...]") > capital1=0 > end if > return capital1 > end function > > The program will run fine... > Then I can actually go back and DELETE that line, and it will still run > fine. I can save the program and run it as many times as I want > and it will run fine without that initialization. > > Almost like the interpreter remembers when I initialized it... > > Am I making sense? What is going on? I would just as soon NOT initialize > > the variable if my routine is going to set the value later. > But the question is:do I have to or not? >