Extract file extension: Difference between revisions
Content deleted Content added
m →{{header|Sidef}}: updated the code to match the current specification of the task |
|||
Line 431: | Line 431: | ||
The source incorporates a collection of character characterisations via suitable spans of a single sequence of characters. Unfortunately, the PARAMETER statement does not allow its constants to appear in EQUIVALENCE statements, so the text is initialised by DATA statements, and thus loses the protection of read-only given to constants defined via PARAMETER statements. The statements are from a rather more complex text scanning scheme, as all that are needed here are the symbols of GOODEXT. |
The source incorporates a collection of character characterisations via suitable spans of a single sequence of characters. Unfortunately, the PARAMETER statement does not allow its constants to appear in EQUIVALENCE statements, so the text is initialised by DATA statements, and thus loses the protection of read-only given to constants defined via PARAMETER statements. The statements are from a rather more complex text scanning scheme, as all that are needed here are the symbols of GOODEXT. |
||
The text scan could instead check for a valid character via something like <code> ("a" <= C & C <= "z") | ("A" <= |
The text scan could instead check for a valid character via something like <code> ("a" <= C & C <= "z") | ("A" <= C & C <= "Z") | (0 <= C & C <= "9")</code> but this is not just messy but unreliable - in EBCDIC for example there are gaps in the sequence of letters that are occupied by other symbols. So instead, a test via INDEX into a sequence of all the valid symbols. If one was in a hurry, for eight-bit character codes, an array GOODEXT of 256 logical values could be indexed by the numerical value of the character. <lang Fortran> MODULE TEXTGNASH !Some text inspection. |
||
CHARACTER*10 DIGITS !Integer only. |
CHARACTER*10 DIGITS !Integer only. |
||
CHARACTER*11 DDIGITS !With a full stop masquerading as a decimal point. |
CHARACTER*11 DDIGITS !With a full stop masquerading as a decimal point. |