Empty string: Difference between revisions

Content added Content deleted
(Added FutureBasic example)
Line 601:
 
With F90, compound data aggregates can be defined and as well procedures for operating on them, so that, after a great deal of syntactic struggle, a string data type will be available. F2000 standardised one such scheme whereby character variables are de-allocated and re-allocated with usage so that a statement such as <code>TEXT = "This" // "That"</code> would cause a de-allocation of whatever storage had been associated with TEXT followed by a re-allocation of storage for eight characters, the required size, and LEN(TEXT) would give 8.
 
=={{header|FutureBasic}}==
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"
 
dim as Str255 s
 
s = ""
if s == "" then print "String is empty"
if s[0] == 0 then print "String is empty"
if len(s) == 0 then print "String is empty"
 
s = "Hello"
if s <> "" then print "String not empty."
if s[0] then print "String not empty."
if len(s) > 0 then print "String not empty."
</lang>
 
=={{header|Go}}==