Re: booleans
- Posted by David Cuny <dcuny at LANSET.COM> Feb 05, 2001
- 474 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