Created
January 20, 2014 17:43
-
-
Save sealfin/8524998 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This program will enumerate the format command characters in the file 'metal_help.mhlp', viz. characters preceded by three '@' characters. | |
'T' | |
'C' | |
'L' | |
'N' | |
't' | |
'B' | |
'n' | |
'I' | |
'E' | |
This program will now quit. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{$R+} | |
program mhlp_file_format_analyser_I( output ); | |
label | |
l_END; | |
const | |
k_F_PATH = 'metal_help.mhlp'; | |
var | |
f : text; | |
numberOfAtCharacters : 0..3; | |
formatCommandCharactersEnumerated : set of char; | |
c : char; | |
begin | |
writeln( 'This program will enumerate the format command characters in the file ''', k_F_PATH, ''', viz. characters preceded by three ''@'' characters.' ); | |
writeln; | |
assign( f, k_F_PATH ); | |
{$I-} | |
reset( f ); | |
if ioresult <> 0 then begin | |
{$I+} | |
writeln( 'Sorry, an error occurred: the file ''', k_F_PATH, ''' could not be opened; please ensure that the file is in the same folder as this program and try running this program again.' ); | |
goto l_END | |
end; | |
numberOfAtCharacters := 0; | |
formatCommandCharactersEnumerated := []; | |
while not eof( f ) do begin | |
read( f, c ); | |
if eoln( f ) then begin | |
readln( f ); | |
numberOfAtCharacters := 0 | |
end; | |
if numberOfAtCharacters = 3 then begin | |
if not ( c in formatCommandCharactersEnumerated ) then begin | |
writeln( '''', c, '''' ); | |
formatCommandCharactersEnumerated := formatCommandCharactersEnumerated + [ c ] | |
end; | |
numberOfAtCharacters := 0 | |
end | |
else | |
if c = '@' then | |
numberOfAtCharacters := numberOfAtCharacters + 1 | |
else | |
numberOfAtCharacters := 0 | |
end; | |
close( f ); | |
l_END:writeln; | |
writeln( 'This program will now quit.' ) | |
end. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
mhlp format analyser I.out
is the result of analysing the.mhlp
file which comes with METAL BASIC 1.7.3.