1. a little confused about scope
- Posted by Jason Dube <dubetyrant at hotmail.com> Dec 17, 2003
- 462 views
Hi all, I was having trouble figuring out why I get an error in my program if I declare a variable in the middle of a procedure as opposed to declaring it at the top of the procedure. If I declare it at the top of the procedure, my program runs fine. This generates the error message: "expected to see possibly 'end', not a type" But if I put the declaration at the top of the procedure it runs fine. Do private variables in functions have to be declared before anything else? I read the manual under scope, but I didn't come across any hardfast rules, am I missing something? procedure test_block_1() position (20,1) puts(1,"RAW INPUT:") print (1,raw_data) position(22,1) print(1,process_one) position(23,1) puts (1,"LENGTH OF COMMONWORDS SEQUENCE: ") print(1,length(common_100)) position(27,1) puts(1,"LENGTH OF TOKENIZED DATA: ") print(1,length(process_one)) object x <<<<<<<<<<<<<<<<<OFFENDING LINE<<<<<<<<<< position(28,1) x=find("in",common_100) puts(1,"WHICH PLACE IN COMMONWORDS SEQUENCE: ") print(1,x) position(29,1) print(1,process_two) position(30,1) puts(1,"WHICH PLACE IN FIRSTWORDS SEQUENCE: ") print(1,process_three) end procedure
2. Re: a little confused about scope
- Posted by "Juergen Luethje" <j.lue at gmx.de> Dec 17, 2003
- 461 views
Jason Dube wrote: <snip> > Do private variables in functions have to be declared before anything > else? Yes. <snip> Regards, Juergen
3. Re: a little confused about scope
- Posted by "Hayden McKay" <hmck1 at dodo.com.au> Dec 17, 2003
- 465 views
I think there was something in the "refman.txt" about this. I seen it somewere in the docs. Yes, you must always declare variables within any routine type at the top befor any other call. ----- Original Message ----- From: "Jason Dube" <dubetyrant at hotmail.com> To: <EUforum at topica.com> Subject: a little confused about scope > > > Hi all, > > I was having trouble figuring out why I get an error in my program if I > declare a variable in the middle of a procedure as opposed to declaring > it at the top of the procedure. If I declare it at the top of the > procedure, my program runs fine. > > This generates the error message: "expected to see possibly 'end', not a > type" > > But if I put the declaration at the top of the procedure it runs fine. > Do private variables in functions have to be declared before anything > else? I read the manual under scope, but I didn't come across any > hardfast rules, am I missing something? > > procedure test_block_1() > > > position (20,1) > puts(1,"RAW INPUT:") > print (1,raw_data) > position(22,1) > print(1,process_one) > > position(23,1) > puts (1,"LENGTH OF COMMONWORDS SEQUENCE: ") > print(1,length(common_100)) > > position(27,1) > puts(1,"LENGTH OF TOKENIZED DATA: ") > print(1,length(process_one)) > > object x <<<<<<<<<<<<<<<<<OFFENDING LINE<<<<<<<<<< > > position(28,1) > x=find("in",common_100) > puts(1,"WHICH PLACE IN COMMONWORDS SEQUENCE: ") > print(1,x) > > position(29,1) > print(1,process_two) > > position(30,1) > puts(1,"WHICH PLACE IN FIRSTWORDS SEQUENCE: ") > print(1,process_three) > end procedure > > > > 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.551 / Virus Database: 343 - Release Date: 11/12/03 > --- --