1. 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?

new topic     » topic index » view message » categorize

2. Re: variable start values

Hi Jason,

----------
> From: Jason Dube <dubetyrant at hotmail.com>
> 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

Try please instead:

 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
   else         -----<---- new
     capital1=1 -----<---- new 
   end if
     return capital1
 end function

[snipped]

Regards,
Igor Kachan
kinz at peterlink.ru

new topic     » goto parent     » topic index » view message » categorize

3. Re: variable start values

On Wed, 10 Dec 2003 16:33:19 +0000, Jason Dube
<dubetyrant at hotmail.com> wrote:

>  if x[1][1] < 90 then

It took me a moment to figure that out. I suggest you use 
"if x[1][1] < 'Z' then" instead, and probably <= as well.

Regards,
Pete

new topic     » goto parent     » topic index » view message » categorize

4. Re: variable start values

----- Original Message ----- 
From: "Ron Austin" <ronaustin at alltel.net>
To: <EUforum at topica.com>
Subject: RE: variable start values


> 
> 
> Pete Lomax wrote:
> > 
> > 
> > On Wed, 10 Dec 2003 16:33:19 +0000, Jason Dube
> > <dubetyrant at hotmail.com> wrote:
> > 
> > >  if x[1][1] < 90 then
> > 
> > It took me a moment to figure that out. I suggest you use 
> > "if x[1][1] < 'Z' then" instead, and probably <= as well.
> > 
> > Regards,
> > Pete
> > If he wants to trap non capital letters shouldn't it be <65 or > 90  -- 
> > <'A' or >'Z' this would trap lower case plus misc numbers, punctuation , 
> > etc.
> 

I believe that 

    if find(x[1][1], upper_case_chars) = 0 then 

is the safest method, because it does not restrict itself to ASCII coding or to
English. All that is needed is to load the sequence 'upper_case_chars' with the
values that the current user believes are uppercase characters at runtime. The
default can be "ABCDEFGHIJKLMNOPQRSTUVWXYZ" but should be changable under user
control.

-- 
Derek

new topic     » goto parent     » topic index » view message » categorize

5. Re: variable start values

On Thu, 11 Dec 2003 07:51:20 +1100, Derek Parnell
<ddparnell at bigpond.com> wrote:

>
>
>----- Original Message ----- 
>From: "Ron Austin" <ronaustin at alltel.net>
>To: <EUforum at topica.com>
>Subject: RE: variable start values
>
>
>> Pete Lomax wrote:
>> > 
>> > 
>> > On Wed, 10 Dec 2003 16:33:19 +0000, Jason Dube
>> > <dubetyrant at hotmail.com> wrote:
>> > 
>> > >  if x[1][1] < 90 then
>> > 
>> > It took me a moment to figure that out. I suggest you use 
>> > "if x[1][1] < 'Z' then" instead, and probably <= as well.
>> > 
>> > Regards,
>> > Pete
>> > If he wants to trap non capital letters shouldn't it be <65 or > 90  -- 
>> > <'A' or >'Z' this would trap lower case plus misc numbers, punctuation , 
>> > etc.
>> 
>
>I believe that 
>
>    if find(x[1][1], upper_case_chars) = 0 then 
>
>is the safest method, because it does not restrict itself to ASCII coding or to
>English. All that is needed is to load the sequence 'upper_case_chars' with the
>values that the current user believes are uppercase characters at runtime. The
>default can be "ABCDEFGHIJKLMNOPQRSTUVWXYZ" but should be changable under user
>control.

Yep. My favored method is:

sequence charset
	charset=repeat(ILLEGAL,256)
	charset['A'..'Z']=UPPER

then,
	if charset[x[1][1]]=UPPER

obviously, ILLEGAL=-1, UPPER=7 (etc) as previously defined constants.

Pete

new topic     » goto parent     » topic index » view message » categorize

6. Re: variable start values

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 message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu