Data update
This commit is contained in:
parent
81fd053722
commit
52a6ef48dd
10248 changed files with 63654 additions and 6775 deletions
|
|
@ -1,38 +1,60 @@
|
|||
MODULE Menu;
|
||||
|
||||
FROM InOut IMPORT WriteString, WriteCard, WriteLn, ReadCard;
|
||||
FROM STextIO IMPORT ReadChar, SkipLine;
|
||||
FROM CharClass IMPORT IsNumeric, IsControl, IsWhiteSpace;
|
||||
|
||||
CONST StringLength = 100;
|
||||
MenuSize = 4;
|
||||
|
||||
TYPE String = ARRAY[0..StringLength-1] OF CHAR;
|
||||
|
||||
VAR menu : ARRAY[0..MenuSize] OF String;
|
||||
selection, index : CARDINAL;
|
||||
PROCEDURE MenuF(): String;
|
||||
VAR
|
||||
menu : ARRAY[0..MenuSize] OF String;
|
||||
inp : CHAR;
|
||||
selection, index : CARDINAL;
|
||||
|
||||
BEGIN
|
||||
menu[1] := "fee fie";
|
||||
menu[2] := "huff and puff";
|
||||
menu[3] := "mirror mirror";
|
||||
menu[4] := "tick tock";
|
||||
selection := 0;
|
||||
WHILE selection=0 DO
|
||||
FOR index := 1 TO HIGH(menu) DO
|
||||
WriteString("[");
|
||||
WriteCard( index,1);
|
||||
WriteString( "] ");
|
||||
WriteString( menu[index]);
|
||||
WriteLn;
|
||||
END;(*of FOR*)
|
||||
|
||||
FOR index := 1 TO HIGH(menu) DO
|
||||
WriteString("[");
|
||||
WriteCard( index,1);
|
||||
WriteString( "] ");
|
||||
WriteString( menu[index]);
|
||||
WriteLn;
|
||||
END;(*of FOR*)
|
||||
inp := '';
|
||||
WriteString("Choose what you want : ");
|
||||
ReadChar(inp);
|
||||
SkipLine;
|
||||
|
||||
WriteString("Choose what you want : ");
|
||||
ReadCard(selection);
|
||||
IF IsNumeric(inp) THEN
|
||||
CASE inp OF
|
||||
'1' : selection := 1 |
|
||||
'2' : selection := 2 |
|
||||
'3' : selection := 3 |
|
||||
'4' : selection := 4 |
|
||||
ELSE ;
|
||||
selection := 0;
|
||||
END;
|
||||
|
||||
IF (selection <= HIGH(menu)) AND (selection > 0) THEN
|
||||
WriteString("You have chosen: ");
|
||||
WriteString( menu[selection]);
|
||||
WriteLn;
|
||||
ELSE
|
||||
WriteString("Selection is out of range!");
|
||||
WriteLn;
|
||||
END (*of IF*)
|
||||
IF (selection <= HIGH(menu)) AND (selection > 0) THEN
|
||||
RETURN menu[selection];
|
||||
END (*of IF*)
|
||||
ELSIF IsWhiteSpace(inp) OR IsControl(inp) THEN
|
||||
RETURN "";
|
||||
END;
|
||||
END;
|
||||
END MenuF;
|
||||
|
||||
BEGIN
|
||||
WriteString(MenuF());
|
||||
WriteLn;
|
||||
END Menu.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue