Re: Testing for NULL

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

The addition of testing EUPHORIA variables as being either not set or not is something that is relatively new. Some of us, like myself, say the user should have a set dummy value as values can be either atoms or sequences.

You can use object rather than sequence or use a custom type.

type sequence_or_0(object x) 
   return equal(x,0) or sequence(x) 
end type 
 
sequence_or_0 x = 0 -- no fatal error here. 

The variables should always be set to something. Here 0 means that there is no string yet.

public function fname(sequence_or_0 x) 
    if compare(x,0) then 
	self[FNAME] = x 
    end if 
    return self[FNAME] 
end function 

Values that might not be atoms (numbers) must not be used or you may get a fatal error. If you use x=0, then you will get a sequence of 0s and 1s depending on how the individual characters compare to 0. You can use compare(), and equal(). These always return atoms. Only atoms are valid, non-zero atoms are true, and 0 is is false.

Shawn

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

Search



Quick Links

User menu

Not signed in.

Misc Menu