Empty string: Difference between revisions

Content added Content deleted
(→‎{{header|Fortran}}: Clarify the stages of furrytran text gnashing.)
Line 570: Line 570:


=={{header|Fortran}}==
=={{header|Fortran}}==
Early Fortran offered only rather strange methods of manipulating text, involving overwriting text literals within FORMAT statements via a READ statement that used that format statement. Fortran 4 introduced the A format whereby text could be stored in integer or floating-point variables or arrays, and then those variables could be manipulated. Fortran 77 introduced a CHARACTER definition which greatly eased matters but it was not a "string" type, which is to say, a variable storing some sequence of characters (or, in principle, integers, or other data) and ''also'' having a length. A variable may be declared as having a fixed size, as in CHARACTER*24 TEXT, and there is a library function LEN which for that variable would return 24, no matter what the variable contained. That is to say, it reports the size of the variable, not the length in current use of a string of up to 24 characters as would be the case for a similar declaration in for example, Pascal.
Early Fortran offered only rather strange methods of manipulating text, involving overwriting text literals within a FORMAT statement via a READ statement that used that format statement. Such text could not be inspected, whether to see if it was blank or anything else. Fortran 4 introduced the A format whereby text could be stored in integer or floating-point variables or arrays, and then those variables could be manipulated and inspected - though their numerical values would be unusual, especially if in floating-point variables. Fortran 77 introduced a CHARACTER definition which greatly eased matters but it was not a "string" type, which is to say, a variable storing some sequence of characters (or, in principle, integers, or other data) and ''also'' having a length. A variable may be declared as having a fixed size, as in CHARACTER*24 TEXT, and there is a library function LEN which for that variable would return 24, no matter what the variable contained. That is to say, it reports the size of the variable, not the length in current use of a string of up to 24 characters as would be the case for a similar declaration in for example, Pascal.


Such variables, or text literals, may be passed as a parameter to a subprogram, and it may use the LEN function to ascertain the size of the parameter, which in that sense could be considered a string because CHARACTER parameters are passed with a secret additional parameter, their size, which is available to the LEN function within the subprogram.
Such variables, or text literals, may be passed as a parameter to a subprogram, and it may use the LEN function to ascertain the size of the parameter, which in that sense could be considered a string because CHARACTER parameters are passed with a secret additional parameter, their size, which is available to the LEN function within the subprogram.