[I6] Test an empty String in property

Can i test if a String in a property is empty?

[code]Property description;
Object test with description “”;

[ main;
if /* test.description ~= “” /
print (string) test.description;
do nothing */


[code]Property description;
Object test with description “”;
Array StorageForShortName buffer 160;

[ PrintToBuffer buf len a;
@output_stream 3 buf;
print (string) a;
@output_stream -3;
if (buf–>0 > len) print “Error: Overflow in PrintToBuffer.^”;
return buf–>0;

[ main key len;
len = PrintToBuffer (StorageForShortName, 160, test.description);
if (len)
print (string) test.description, “^”;

@read_char 1 ->key;

];[/code]Something simpler?

The default value for the description property is 0, not “”. You can test if (test.description == 0).

If you really want the empty string, it’s easiest to define a constant

Constant EMPTYSTR “”;
Object test with description EMPTYSTR;

Then testing if (test.description == EMPTYSTR) will work. Using literal quotes doesn’t work because the I6 compiler constructs a new string for each literal. (Unlike in I7.)