Re: variable start values

new topic     » goto parent     » topic index » view thread      » older message » newer message

capital1 needs to be assighned a variable before the 
"if statement"

Your problem is capital1 is only assigned a variable 
if x[1][1] < 90

U need something like.

integer capital1
capital1 = 1 -- True
if x[1][1] < 90 then
.......
capital1 = 0
end if
return capital1

----- Original Message ----- 
From: "Jason Dube" <dubetyrant at hotmail.com>
To: <EUforum at topica.com>
Sent: Thursday, December 11, 2003 3:33 AM
Subject: variable start values


> 
> 
> 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?
> 
> 
> 
> TOPICA - Start your own email discussion group. FREE!
> 
> 
> -- 
> Incoming mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.548 / Virus Database: 341 - Release Date: 5/12/03
> 


---


--

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu