Jump to content

Empty string: Difference between revisions

(add Zig example)
Line 1,308:
 
=={{header|FutureBasic}}==
<lang futurebasic>window 1, @"Empty string", (0,0,480,270)
FB has several ways to determine string length as demonstrated below.
Note: The length -- or number of characters -- of a Pascal string in FB is stored in the first element of the string array. Here the string is dimensioned a s, hence s[0] contains the length of the string, and any individual character in the string can be found using s[i], where i is the position of the character. This makes iterating over the individual characters in a string easier than using functions such as instr or mid$.
<lang futurebasic>
include "ConsoleWindow"
 
CFStringRef s
dim as Str255 s
 
s = @""
if s( ==fn StringIsEqual( s, @"" ) ) then print @"Stringstring is empty"
if ( fn StringLength( s[0] ) == 0 ) then print @"Stringstring is empty"
if ( len(s) == 0 ) then print @"Stringstring is empty"
 
print
s = "Hello"
 
if s <> "" then print "String not empty."
s = @"Hello"
if s[0] then print "String not empty."
if len( fn StringIsEqual( s, @"" ) >== 0NO ) then print @"Stringstring not empty."
if ( fn StringLength( s[ ) != 0] ) then print @"Stringstring not empty."
</lang>
if ( len(s) <>!= ""0 ) then print @"Stringstring not empty."
 
HandleEvents</lang>
 
=={{header|Gambas}}==
416

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.