代码大全

(singke) #1

'L': CommandWord: 'Left';
'R': CommandWord: 'Right'
'U': CommandWord:='Up'
'D': CommandWord:='Down';
else FatalError('Unexpected Command in Display Command.')
end {case}


extract arguments
ArgCount:=0
for Idx=3 to Length (CommandSentence) do begin
CommandChar=CommandSentence[Idx]

{begin new argument}
if(CommandSentence=ARGUMENT SIGN) then begin
ArgCount: ArgCount l;
Argument[Argcount]: ’’
end
{ add next character to existing argument}
else begin
Argument[Argcount]:=Argument[Argcount]+CommandChar
end
end;{for};


{display the command and its arguments in a pleasing format}
writeln{'Command:',CommandWord};
for Idx:=1 to ArgCount do begin
writeln(' ',Argument[Idx])
end
end {DisplayCommand}
4 case


Pascal case
{ expand the command abbreviation to a meaningful command word}
case CommandSentence[2] of
'L': CommandWord: 'Left';
'R': CommandWord: 'Right'
'U': CommandWord: 'Up'
'D': CommandWord: 'Down';
'E': CommandWord: 'Enter';
'X': CommandWord: 'Delete';

Free download pdf