1. booleans
- Posted by Kat <gertie at PELL.NET> Feb 04, 2001
- 537 views
- Last edited Feb 05, 2001
Here is an example of the trouble i have with Eu's comparisons: result = "" -- i had to give it "", or else "&=" gives an error -- code doing things, but not changing result if ( result = "" ) then if equal(result,"") then both "if" statements give the same result: variable result has not been assigned a value So what i want to know is: how do i find out if result is still empty? length() is the only way? Ack! Kat
2. Re: booleans
- Posted by Kat <gertie at PELL.NET> Feb 04, 2001
- 507 views
- Last edited Feb 05, 2001
On 4 Feb 2001, at 23:52, Kat wrote: > Here is an example of the trouble i have with Eu's comparisons: > > result = "" > -- i had to give it "", or else "&=" gives an error > -- code doing things, but not changing result > > if ( result = "" ) then > if equal(result,"") then > > both "if" statements give the same result: > > variable result has not been assigned a value > > So what i want to know is: how do i find out if result is still empty? > length() is the > only way? Ack! No, because length() gives the same error, result has no value! Kat
3. Re: booleans
- Posted by David Cuny <dcuny at LANSET.COM> Feb 05, 2001
- 501 views
Kat wrote: > result = "" > if ( result = "" ) then > if equal(result,"") then If I write: object result result = "" if equal( result, "" ) then puts( 1, "empty" ) else puts( 1, "not empty" ) end if it will run correctly. It's only if I comment out the line: -- result = "" that I get an error. I can only assume that, in fact, result is not getting assigned before the if statement, just like Euphoria is telling you. I believe the larger question (how can I tell that a variable is unassigned) is: you can't without crashing your code. One option would be to initialize your variables to a different data type. For example, if you were dealing with strings, you could write: object string string = -1 ... if equal( string, -1 ) then puts( 1, "string is not initialized.\n" ) abort(0) end if For example, see gets() and dir(). These sorts of things are prone to causing errors, though. For example, I always expect dir() to return an empty sequence instead of -1. And I never catch that kind of bug until after the code has been released... -- David Cuny
4. Re: booleans
- Posted by Igor Kachan <kinz at peterlink.ru> Feb 05, 2001
- 529 views
Dear Kat: > No, because length() gives the same error, > result has no value! Try please: --------- sequence s s={} ? length(s) sequence t t="" ? length(t) --------- Regards, Igor Kachan
5. Re: booleans
- Posted by Rolf Schroeder <rolf.schroeder at DESY.DE> Feb 05, 2001
- 513 views
Dear Igor, Igor Kachan wrote: > > Dear Kat: > > > No, because length() gives the same error, > > result has no value! > > Try please: > > --------- > sequence s > s={} > ? length(s) > > sequence t > t="" > ? length(t) > --------- > ... please try this: --------- sequence s s={} ? t ? length(s) --------- Have a nice day, Rold
6. Re: booleans
- Posted by Rolf Schroeder <rolf.schroeder at DESY.DE> Feb 05, 2001
- 513 views
Rolf Schroeder wrote: nonsense, forget it, please!
7. Re: booleans
- Posted by Kat <gertie at PELL.NET> Feb 05, 2001
- 553 views
- Last edited Feb 06, 2001
On 5 Feb 2001, at 1:09, Igor Kachan wrote: > Dear Kat: > > > No, because length() gives the same error, > > result has no value! > > Try please: > > --------- > sequence s > s={} > ? length(s) > > sequence t > t="" > ? length(t) > --------- Ok, i declared result = {} and with result = "" and both died at the same place if ( length(result) = 0 ) with the same error: variable result has not been assigned a value ex.err has this: result = <no value> Changing result from a sequence to an object didn't help. Neither did if ( result = "" ) then <-- same error neither did: if equal(result,"") then <-- same error neither did: if compare(result,"") then <-- same error neither did: if match(result,"") then <-- same error I even checked ex.err trace to verify i had saved the new lines after editing them, to make sure i was running the code i thought i was! Robert, how do i do this? result = "" -- only so the &= operator will work -- misc code that doesn't change result in this pass --now how to tell if result is still "" or not? Kat, wringing her paws, recoding with: result = "-1" -- cause it will never be this, i hope -- code modified to not use the &= , -- but instead to replace result if "-1" -- and &= if not "-1" -- then check if result = "-1"
8. Re: booleans
- Posted by David Cuny <dcuny at LANSET.COM> Feb 06, 2001
- 571 views
Kat wrote: > Ok, i declared > result = {} > and with > result = "" > and both died at the same place > if ( length(result) = 0 ) > with the same error: > variable result has not been assigned a value > > ex.err has this: > result = <no value> To point out the obvious: if ex.err says that result hasn't been assigned a value, then it hasn't been. There are a couple possibilities: 1. The initialization is in a conditional statement that gets bypassed. 2. The execution order isn't what you expect, and you reach the test before the initialization. 3. You are initializing a local variable and testing a global, or vice versa. (I'm guessing this is what's happening to you). I'd stick a trace before the initialization and test, to make sure they were executing in order. If that doesn't work, reduce the code to a minimum and post it - I'd love to see it. -- David Cuny
9. Re: booleans
- Posted by Igor Kachan <kinz at peterlink.ru> Feb 06, 2001
- 545 views
Dear Kat: > Changing result from a sequence to an object didn't help. Post me please fragment of your booleans program that gives error. Regards, Igor Kachan kinz at peterlink.ru
10. Re: booleans
- Posted by Graeme <graemeburke at CROSSWINDS.NET> Feb 06, 2001
- 496 views
OK Kat, try this; new file, on it's own. -----<start>------- sequence s s="" ?s ?length(s) -------<end>---------- outputs: {} 0 As you can see, the s="" line _does_ initialize the sequence, therefore there _must_ be an error somewhere in your code. Unless this is a version specific bug (I use 2.1) but I would be very surprised if that section of the interpreter has been touched in the last few releases. Here's what I'd be looking for. Do you have, perhaps two vars, one called "Result" and one called "result" Do you have a local called "result" that you are, initializing and a private also called "result" that you are not? (or vice versa) Is the result="" DEFINATELY being executed? try putting this immediately berfore the line: if message_box("Initializing result","Debug",0) then end if (or under DOS) puts(1,"\n\nINITIALIZING result") if wait_key() then end if Then you will be SURE the line is executed as the program will halt and display a message. BTW: (result="") will always fail as logic tests must equate to an integer. Sequences can be compared using the '=' operator but they must be the same length ("MAN"="CAN") equates to {0,1,1} Graeme
11. Re: booleans
- Posted by Derek Parnell <ddparnell at bigpond.com> Feb 06, 2001
- 518 views
Hi Kat, I do this sort of thing all the time, and it works just fine. eg. sequence result result = "" Of course, it would be neater if one could do ... sequence result = "" but RDS does not believe in that particular 'heresy'. One possible problem that you might have is this type of coding... sequence result result = "" procedure xyz() sequence result if length(result) = 0 then ... end procedure here we have the identifier 'result' defined twice, once as a file-scoped variable and another as a procedure-scoped variable. The procedure one is being tested but the file one is being initialised. ------ Derek Parnell Melbourne, Australia (Vote [1] The Cheshire Cat for Internet Mascot) ----- Original Message ----- From: "Kat" <gertie at PELL.NET> To: <EUforum at topica.com> Sent: Tuesday, February 06, 2001 6:39 PM Subject: Re: booleans > On 5 Feb 2001, at 1:09, Igor Kachan wrote: > > > Dear Kat: > > > > > No, because length() gives the same error, > > > result has no value! > > > > Try please: > > > > --------- > > sequence s > > s={} > > ? length(s) > > > > sequence t > > t="" > > ? length(t) > > --------- > > Ok, i declared > result = {} > and with > result = "" > and both died at the same place > if ( length(result) = 0 ) > with the same error: > variable result has not been assigned a value > > ex.err has this: > result = <no value> > > Changing result from a sequence to an object didn't help. > > Neither did > if ( result = "" ) then <-- same error > neither did: > if equal(result,"") then <-- same error > neither did: > if compare(result,"") then <-- same error > neither did: > if match(result,"") then <-- same error > > I even checked ex.err trace to verify i had saved the new lines after editing them, to > make sure i was running the code i thought i was! > > Robert, how do i do this? > > result = "" -- only so the &= operator will work > -- misc code that doesn't change result in this pass > --now how to tell if result is still "" or not? > > Kat, > wringing her paws, > recoding with: > result = "-1" -- cause it will never be this, i hope > -- code modified to not use the &= , > -- but instead to replace result if "-1" > -- and &= if not "-1" > -- then check if result = "-1" >