RosettaCodeData/Task/Empty-string/Cache-ObjectScript/empty-string.cos

16 lines
681 B
Plaintext

EMPTYSTR
; Demonstrate how to assign an empty string to a variable.
set x = ""
; Demonstrate how to check that a string is empty.
; Length 0 is empty; equality/pattern check are 1=T, 0=F
write !,"Assigned x to null value. Tests: "
write !,"String length: "_$length(x)_", Equals null: "_(x = "")_", Empty pattern: "_(x?."") ; length 0 is empty
; Demonstrate how to check that a string is not empty. Same as above.
set x = " " ;assign to a space - not null
write !!,"Assigned x to a single blank space. Tests: "
write !,"String length: "_$length(x)_", Equals null: "_(x = "")_", Empty pattern: "_(x?."")
quit