Category : Miscellaneous Language Source Code
Archive   : ADA-LRM3.ZIP
Filename : LR7AVCB.SRC

 
Output of file : LR7AVCB.SRC contained in archive : ADA-LRM3.ZIP


-- ON-LINE Ada LANGUAGE REFERENCE MANUAL
-- Developed at Nofolk State University
-- Development funded by a grant from the U. S. Army
-- Project ReDTEA
-- Version 1.0 released December 1988
-- Programmer: Esther M. Lumsdon
-- Project Director: George C. Harrison, PhD



package body LRM_NON_SMG is



procedure INITIALIZE is
-- Initialization for on-line Ada Language Reference Manual
--
--
----------------------------------------------------------------------------
procedure DECIDE_TERM_CATEGORY(USING_DEC_TERMINAL : out BOOLEAN) is

CHOSE_TERMINAL_CATEGORY : BOOLEAN;
TERM_CATEGORY : STRING(1 .. 5);
TERM_CATEGORY_LENGTH : NATURAL;


begin

loop
CLS;
PUT_LINE(" The following terminals are available for your use at NSU:")
;
PUT_LINE("Category A terminals:");
PUT_LINE(" VISUAL brand terminals");
PUT_LINE(" TeleVideo brand terminals");
PUT_LINE(" DEC terminals");
NEW_LINE;
PUT_LINE("Category B terminals:");
PUT_LINE(" ADM brand terminals");
PUT_LINE(" Adds-Viewpoint terminals");
PUT_LINE(" Hazeltine brand terminals");
NEW_LINE(2);
PUT(
"Please enter A or B for the category of terminal that you are using: "
);
GET_LINE(TERM_CATEGORY, TERM_CATEGORY_LENGTH);
CHOSE_TERMINAL_CATEGORY := TRUE;
case TERM_CATEGORY(1) is
when 'A' | ASCII.LC_A =>
USING_DEC_TERMINAL := TRUE;
when 'B' | ASCII.LC_B =>
USING_DEC_TERMINAL := FALSE;
when others =>
CHOSE_TERMINAL_CATEGORY := FALSE;
end case;
exit when CHOSE_TERMINAL_CATEGORY;
end loop;

end DECIDE_TERM_CATEGORY;




begin
USING_DEC_TERMINAL := FALSE;
end INITIALIZE;




------------------------------------------------------------------------------


procedure TERMINATE_LRM is

begin
if IS_OPEN(SAVE_FILE) then
CLOSE(SAVE_FILE);
end if;
CLS;
NEW_LINE(2);
PUT_LINE("Thank you for using the Ada Language Reference Manual Reader.");
end TERMINATE_LRM;


------------------------------------------------------------------------------

procedure DISPLAY_MAIN_MENU(IN_FILE_NAME : in STRING) is



-- read menu text from file, and put entire file on screen.

EMPTY_STRING_80 : STRING(1 .. 80);
LAST_CHAR : NATURAL := 0;
READ_IN_FILE : FILE_TYPE;
READ_IN_LINE : STRING(1 .. 80);


begin
EMPTY_STRING_80 := (others => ' ');
if not USING_DEC_TERMINAL then
OPEN(READ_IN_FILE, IN_FILE, IN_FILE_NAME);
while not END_OF_FILE(READ_IN_FILE) loop
READ_IN_LINE := EMPTY_STRING_80;
GET_LINE(READ_IN_FILE, READ_IN_LINE, LAST_CHAR);
PUT_LINE(READ_IN_LINE(1 .. SCREEN_WIDTH));
end loop;
end if;


end DISPLAY_MAIN_MENU;




------------------------------------------------------------------------------

procedure DISPLAY_MENU(IN_FILE_NAME : in STRING) is



-- read menu text from file, and put entire file on screen.

EMPTY_STRING_80 : STRING(1 .. 80);
LAST_CHAR : NATURAL := 0;
READ_IN_FILE : FILE_TYPE;
READ_IN_LINE : STRING(1 .. 80);


begin
EMPTY_STRING_80 := (others => ' ');

OPEN(READ_IN_FILE, IN_FILE, IN_FILE_NAME);
while not END_OF_FILE(READ_IN_FILE) loop
READ_IN_LINE := EMPTY_STRING_80;
GET_LINE(READ_IN_FILE, READ_IN_LINE, LAST_CHAR);
PUT_LINE(READ_IN_LINE(1 .. SCREEN_WIDTH));
end loop;

end DISPLAY_MENU;





---------------------------------------------------------------------------

procedure SCROLL_TEXT(IN_FILE_NAME : in STRING;
SAVE_TITLE : in STRING;
SAVE_FILE : in out FILE_TYPE) is


-- scroll text file on the screen, 19 lines at a time

type COMMAND is (CONTINUE, DISPLAY_AGAIN, EXIT_COMMAND, SAVE, NOTHING);

BLANK_COUNT : NATURAL := 0;
CURRENT_LINE : NATURAL := 0;
CURSOR_CONTROL_STR : STRING(1 .. 7) := " ";
EXIT_NOW : BOOLEAN := FALSE;
GOOD_ANSWER : BOOLEAN;
LAST_CHAR : NATURAL := 0;
LAST_COMMAND : COMMAND := NOTHING;
READ_IN_FILE : FILE_TYPE;
READ_IN_LINE : STRING(1 .. 80);
EMPTY_STRING_80 : STRING(1 .. 80);
SAVING : BOOLEAN := FALSE;
TARGET_LINE : NATURAL;
WAIT_STR : STRING(1 .. 10);
WAIT_STR_LENGTH : NATURAL;
LINE_COUNT : NATURAL := 0;

begin
EMPTY_STRING_80 := (others => ' ');
OPEN(READ_IN_FILE, IN_FILE, IN_FILE_NAME);

while not EXIT_NOW loop
LINE_COUNT := 0;
if LAST_COMMAND /= SAVE then

while ((not END_OF_FILE(READ_IN_FILE)) and (LINE_COUNT < (SCREEN_HEIGHT
- 3))) loop
if LINE_COUNT = 0 then
CLS;
end if;
READ_IN_LINE := EMPTY_STRING_80;
GET_LINE(READ_IN_FILE, READ_IN_LINE, LAST_CHAR);
if LAST_CHAR = 0 then
BLANK_COUNT := BLANK_COUNT + 1;
else
BLANK_COUNT := 0;
end if;
if BLANK_COUNT < 3 then
if LAST_CHAR > (SCREEN_WIDTH) then
PUT_LINE(READ_IN_LINE(1 .. SCREEN_WIDTH));
PUT_LINE(READ_IN_LINE(SCREEN_WIDTH + 1 .. LAST_CHAR));
LINE_COUNT := LINE_COUNT + 2;
else
PUT_LINE(READ_IN_LINE(1 .. SCREEN_WIDTH));
LINE_COUNT := LINE_COUNT + 1;
end if;
end if;
if SAVING then
PUT_LINE(SAVE_FILE, READ_IN_LINE(1 .. LAST_CHAR));
end if;
CURRENT_LINE := CURRENT_LINE + 1;
end loop;

end if;

GOOD_ANSWER := FALSE;
while not GOOD_ANSWER loop
GOOD_ANSWER := TRUE;
if LINE < 21 then
CURSOR_CONTROL_STR(2 .. 4) := INTEGER'IMAGE(SCREEN_HEIGHT);
CURSOR_CONTROL_STR(2) := '[';
CURSOR_CONTROL_STR(5 .. 7) := ";1H";
CURSOR_CONTROL_STR(1) := ASCII.ESC;
PUT_LINE(CURSOR_CONTROL_STR);

-- cursor_control_str contains ASCII.ESC & "[nn;1H"
end if;

-- put cursor on line screen_height of screen
WAIT_STR(1) := 'c';
if END_OF_FILE(READ_IN_FILE) then
PUT(" E[xit] S[ave] D[isplay again] ");
GET_LINE(WAIT_STR, WAIT_STR_LENGTH);
else
PUT(" E[xit] C[ontinue] S[ave] D[isplay again] ");
GET_LINE(WAIT_STR, WAIT_STR_LENGTH);
end if;
case WAIT_STR(1) is
when 'E' | ASCII.LC_E =>
LAST_COMMAND := EXIT_COMMAND;
EXIT_NOW := TRUE;
exit;
when 'S' | ASCII.LC_S =>
LAST_COMMAND := SAVE;
if not SAVING then
if not IS_OPEN(SAVE_FILE) then
CREATE(SAVE_FILE, OUT_FILE, LRM_READER_SAVE_FILE_NAME);
end if;
PUT_LINE(SAVE_FILE,
"Reference from Ada Language Reference Manual:");
PUT_LINE(SAVE_FILE, SAVE_TITLE);

-- write title of what is being saved to save_file.
NEW_LINE(SAVE_FILE, 2);
SAVING := TRUE;
if CURRENT_LINE > 1 then
RESET(READ_IN_FILE, IN_FILE);
for I in 1 .. CURRENT_LINE loop
GET_LINE(READ_IN_FILE, READ_IN_LINE, LAST_CHAR);
PUT_LINE(SAVE_FILE, READ_IN_LINE(1 .. LAST_CHAR));
end loop;
end if;
end if;
when 'D' | ASCII.LC_D =>
LAST_COMMAND := DISPLAY_AGAIN;
RESET(READ_IN_FILE, IN_FILE);
CURRENT_LINE := 0;
when 'C' | ASCII.LC_C =>
LAST_COMMAND := CONTINUE;

-- continue the display
when others =>
GOOD_ANSWER := FALSE;
PUT_LINE(ASCII.ESC & "[39D");

-- put cursor at column 1 of the line its on.
end case;

-- while not good_answer loop
end loop;

-- while not eof(read_in_file) loop
end loop;


if SAVING then
NEW_LINE(SAVE_FILE, 3);
end if;
CLOSE(READ_IN_FILE);


end SCROLL_TEXT;





------------------------------------------------------------------------------

------------------------------------------------------------------------------

procedure WELCOME(IN_FILE_NAME : in STRING) is



-- display welcome message

CURSOR_CONTROL_STR : STRING(1 .. 7) := " ";
LAST_CHAR : NATURAL := 0;
LINE_COUNT : NATURAL;
STR_TO_CONTINUE : STRING(1 .. 5);
STR_TO_CONTINUE_LENGTH : NATURAL;
WELCOME_FILE : FILE_TYPE;
-- menu.welcome_msg is 19 lines x 80 cols
WELCOME_LINE : STRING(1 .. 80);




begin
OPEN(WELCOME_FILE, IN_FILE, IN_FILE_NAME);

-- file "menu.welcome_msg"
GET_LINE(WELCOME_FILE, WELCOME_LINE, LAST_CHAR);
CLS;

while not END_OF_FILE(WELCOME_FILE) loop
GET_LINE(WELCOME_FILE, WELCOME_LINE, LAST_CHAR);
SKIP_LINE(WELCOME_FILE);
PUT_LINE(WELCOME_LINE(1 .. SCREEN_WIDTH));
end loop;

CURSOR_CONTROL_STR(2 .. 4) := INTEGER'IMAGE(SCREEN_HEIGHT);
CURSOR_CONTROL_STR(2) := '[';
CURSOR_CONTROL_STR(5 .. 7) := ";1H";
CURSOR_CONTROL_STR(1) := ASCII.ESC;
PUT_LINE(CURSOR_CONTROL_STR);
PUT(" Strike RETURN to continue: ");
GET_LINE(STR_TO_CONTINUE, STR_TO_CONTINUE_LENGTH);

CLOSE(WELCOME_FILE);
end WELCOME;




---------------------------------------------------------------------------

procedure CREDITS(SAVE_FILE : in out FILE_TYPE) is




-- scroll credit on the screen


begin
CLS;
SCROLL_TEXT(CREDITS_FILE_NAME, "Credits ", SAVE_FILE);
end CREDITS;

---------------------------------------------------------------------------

------------------------------------------------------------------------------

procedure DISPLAY_EXPLAIN(IN_FILE_NAME : in STRING) is




-- scroll text file on the screen, 19 lines at a time

CURSOR_CONTROL_STR : STRING(1 .. 7) := " ";
GOOD_ANSWER : BOOLEAN;
LAST_CHAR : NATURAL := 0;
READ_IN_FILE : FILE_TYPE;
READ_IN_LINE : STRING(1 .. 80);
EMPTY_STRING_80 : STRING(1 .. 80);
WAIT_STR : STRING(1 .. 10);
WAIT_STR_LENGTH : NATURAL;
LINE_COUNT : NATURAL := 0;

begin
EMPTY_STRING_80 := (others => ' ');
OPEN(READ_IN_FILE, IN_FILE, IN_FILE_NAME);
CLS;

while not (END_OF_FILE(READ_IN_FILE)) loop

LINE_COUNT := 0;

while (LINE_COUNT < (SCREEN_HEIGHT - 2)) loop
READ_IN_LINE := EMPTY_STRING_80;
if not END_OF_FILE(READ_IN_FILE) then
GET_LINE(READ_IN_FILE, READ_IN_LINE, LAST_CHAR);

if LAST_CHAR > SCREEN_WIDTH then
PUT_LINE(READ_IN_LINE(1 .. SCREEN_WIDTH));
PUT_LINE(READ_IN_LINE(SCREEN_WIDTH + 1 .. LAST_CHAR));
LINE_COUNT := LINE_COUNT + 1;
else
PUT_LINE(READ_IN_LINE(1 .. LAST_CHAR));
LINE_COUNT := LINE_COUNT + 1;
end if;
else
exit;
end if;
end loop;
CURSOR_CONTROL_STR(2 .. 4) := INTEGER'IMAGE(SCREEN_HEIGHT);
CURSOR_CONTROL_STR(2) := '[';
CURSOR_CONTROL_STR(5 .. 7) := ";1H";
CURSOR_CONTROL_STR(1) := ASCII.ESC;
PUT_LINE(CURSOR_CONTROL_STR);
PUT(" Strike RETURN to continue: ");
GET_LINE(WAIT_STR, WAIT_STR_LENGTH);

-- while not eof(read_in_file) loop
end loop;

CLOSE(READ_IN_FILE);


end DISPLAY_EXPLAIN;






------------------------------------------------------------------------------

procedure SELECT_FROM_MAIN_MENU(MAIN_MENU_CHOICE : out STRING) is

CURSOR_CONTROL_STR : STRING(1 .. 7) := " ";
MAIN_MENU_CHOICE_LEN : NATURAL;

begin
CLS;
NEW_LINE(2);
DISPLAY_MENU(MENU_MAIN_FILE_NAME);
CURSOR_CONTROL_STR(2 .. 4) := INTEGER'IMAGE(SCREEN_HEIGHT);
CURSOR_CONTROL_STR(2) := '[';
CURSOR_CONTROL_STR(5 .. 7) := ";1H";
CURSOR_CONTROL_STR(1) := ASCII.ESC;
PUT_LINE(CURSOR_CONTROL_STR);
PUT("Choose from 1 - 7, please: ");
GET_LINE(MAIN_MENU_CHOICE, MAIN_MENU_CHOICE_LEN);
end SELECT_FROM_MAIN_MENU;

------------------------------------------------------------------------------

procedure DO_ANNEX_MENU(SAVE_FILE : in out FILE_TYPE) is

ANNEX_MENU_CHOICE : STRING(1 .. 5);
ANNEX_MENU_CHOICE_LEN : NATURAL;
CURSOR_CONTROL_STR : STRING(1 .. 7) := " ";

begin
loop
CLS;
DISPLAY_MENU(MENU_ANNEX_FILE_NAME);
NEW_LINE(5);
CURSOR_CONTROL_STR(2 .. 4) := INTEGER'IMAGE(SCREEN_HEIGHT);
CURSOR_CONTROL_STR(2) := '[';
CURSOR_CONTROL_STR(5 .. 7) := ";1H";
CURSOR_CONTROL_STR(1) := ASCII.ESC;
PUT_LINE(CURSOR_CONTROL_STR);
PUT("Choose from A - F or Q, please: ");
GET_LINE(ANNEX_MENU_CHOICE, ANNEX_MENU_CHOICE_LEN);
case ANNEX_MENU_CHOICE(1) is
when 'A' | 'a' =>
SCROLL_TEXT(LRM_FILE_NAME_PREFIX(1 .. LRM_FILE_NAME_PREFIX_LENGTH) &
"chapa.doc", "Annex A ", SAVE_FILE);
when 'B' | 'b' =>
SCROLL_TEXT(LRM_FILE_NAME_PREFIX(1 .. LRM_FILE_NAME_PREFIX_LENGTH) &
"chapb.doc", "Annex B ", SAVE_FILE);
when 'C' | 'c' =>
SCROLL_TEXT(LRM_FILE_NAME_PREFIX(1 .. LRM_FILE_NAME_PREFIX_LENGTH) &
"chapc.doc", "Annex C ", SAVE_FILE);
when 'D' | 'd' =>
SCROLL_TEXT(LRM_FILE_NAME_PREFIX(1 .. LRM_FILE_NAME_PREFIX_LENGTH) &
"chapd.doc", "Annex D ", SAVE_FILE);
when 'E' | 'e' =>
SCROLL_TEXT(LRM_FILE_NAME_PREFIX(1 .. LRM_FILE_NAME_PREFIX_LENGTH) &
"chape.doc", "Annex E ", SAVE_FILE);
when 'F' | 'f' =>
SCROLL_TEXT(LRM_FILE_NAME_PREFIX(1 .. LRM_FILE_NAME_PREFIX_LENGTH) &
"chapf.doc", "Annex F ", SAVE_FILE);
when 'Q' | 'q' =>
exit;
when others =>
null;
end case;
end loop;


end DO_ANNEX_MENU;



---------------------------------------------------------------------------

------------------------------------------------------------------------------




procedure DISPLAY_CHAPTER_MENU(IN_FILE_NAME : in STRING) is



-- read menu text from file, and put entire file on screen.

EMPTY_STRING_80 : STRING(1 .. 80);
LAST_CHAR : NATURAL := 0;
READ_IN_FILE : FILE_TYPE;
READ_IN_LINE : STRING(1 .. 80);


begin
EMPTY_STRING_80 := (others => ' ');

OPEN(READ_IN_FILE, IN_FILE, IN_FILE_NAME);
CLS;
while not END_OF_FILE(READ_IN_FILE) loop
READ_IN_LINE := EMPTY_STRING_80;
GET_LINE(READ_IN_FILE, READ_IN_LINE, LAST_CHAR);
PUT_LINE(READ_IN_LINE(1 .. SCREEN_WIDTH));
end loop;

end DISPLAY_CHAPTER_MENU;


------------------------------------------------------------------------------


------------------------------------------------------------------------------

procedure SCROLL_CHAP(IN_FILE_NAME : in STRING;
FIRST_LINE : in out NATURAL;
LAST_LINE : in NATURAL;
SAVE_FILE : in out FILE_TYPE;
UNTIL_EOF : in BOOLEAN;
CITATION_REQUESTED : in STRING) is




-- scroll text file on the screen, 19 lines at a time

type COMMAND is (CONTINUE, DISPLAY_AGAIN, EXIT_COMMAND, SAVE, NOTHING);

AT_LAST_LINE : BOOLEAN := FALSE;
BLANK_30 : STRING(1 .. 30) := (others => ' ');
BLANK_COUNT : NATURAL := 0;
CURRENT_LINE : NATURAL := 0;
CURSOR_CONTROL_STR : STRING(1 .. 7) := " ";
EXIT_NOW : BOOLEAN := FALSE;
GOOD_ANSWER : BOOLEAN;
LAST_CHAR : NATURAL := 0;
LAST_COMMAND : COMMAND := NOTHING;
READ_IN_FILE : FILE_TYPE;
READ_IN_LINE : STRING(1 .. 156);
EMPTY_STRING_156 : STRING(1 .. 156);
SAVING : BOOLEAN := FALSE;
TARGET_LINE : NATURAL;
WAIT_STR : STRING(1 .. 10);
WAIT_STR_LENGTH : NATURAL;
LINE_COUNT : NATURAL := 0;

procedure GOTO_FIRST_LINE(FIRST_LINE : in NATURAL) is
READ_IN_LINE : STRING(1 .. 156);
LAST_CHAR : NATURAL;

begin
RESET(READ_IN_FILE, IN_FILE);
for I in 1 .. (FIRST_LINE - 1) loop
GET_LINE(READ_IN_FILE, READ_IN_LINE, LAST_CHAR);
end loop;
end GOTO_FIRST_LINE;


begin
EMPTY_STRING_156 := (others => ' ');
OPEN(READ_IN_FILE, IN_FILE, IN_FILE_NAME);
GOTO_FIRST_LINE(FIRST_LINE);
CURRENT_LINE := FIRST_LINE - 1;

while not EXIT_NOW loop
CLS;
LINE_COUNT := 0;
if LAST_COMMAND /= SAVE then

if UNTIL_EOF then

while ((not END_OF_FILE(READ_IN_FILE)) and (LINE_COUNT < (
SCREEN_HEIGHT - 3))) loop
READ_IN_LINE := EMPTY_STRING_156;
GET_LINE(READ_IN_FILE, READ_IN_LINE, LAST_CHAR);

-- don't need a SKIP_LINE statement.
-- SKIP_LINE (READ_IN_FILE);
if LAST_CHAR = 0 then
BLANK_COUNT := BLANK_COUNT + 1;
else
BLANK_COUNT := 0;
end if;
if SAVING then
PUT_LINE(SAVE_FILE, READ_IN_LINE(1 .. LAST_CHAR));
end if;
CURRENT_LINE := CURRENT_LINE + 1;
if BLANK_COUNT < 3 then
if LAST_CHAR > SCREEN_WIDTH then
PUT_LINE(READ_IN_LINE(1 .. SCREEN_WIDTH));
PUT_LINE(READ_IN_LINE(SCREEN_WIDTH + 1 .. LAST_CHAR));
LINE_COUNT := LINE_COUNT + 2;
else
PUT_LINE(READ_IN_LINE(1 .. LAST_CHAR));
LINE_COUNT := LINE_COUNT + 1;
end if;
end if;
end loop;

else

while ((CURRENT_LINE < LAST_LINE) and (LINE_COUNT <= (SCREEN_HEIGHT -
3))) loop
READ_IN_LINE := EMPTY_STRING_156;
GET_LINE(READ_IN_FILE, READ_IN_LINE, LAST_CHAR);
if LAST_CHAR = 0 then
BLANK_COUNT := BLANK_COUNT + 1;
else
BLANK_COUNT := 0;
end if;
if SAVING then
PUT_LINE(SAVE_FILE, READ_IN_LINE(1 .. LAST_CHAR));
end if;
CURRENT_LINE := CURRENT_LINE + 1;
if BLANK_COUNT < 3 then
if (not (LAST_CHAR < 42 and LAST_CHAR > 0 and READ_IN_LINE(1 .. 30
) = BLANK_30)) then
if LAST_CHAR > SCREEN_WIDTH then
PUT_LINE(READ_IN_LINE(1 .. SCREEN_WIDTH));
PUT_LINE(READ_IN_LINE(SCREEN_WIDTH + 1 .. LAST_CHAR));
LINE_COUNT := LINE_COUNT + 2;
else
PUT_LINE(READ_IN_LINE(1 .. LAST_CHAR));
LINE_COUNT := LINE_COUNT + 1;
end if;
end if;
end if;
end loop;
if CURRENT_LINE >= (LAST_LINE - 1) then
AT_LAST_LINE := TRUE;
end if;
end if;


end if;

GOOD_ANSWER := FALSE;
while not GOOD_ANSWER loop
GOOD_ANSWER := TRUE;
CURSOR_CONTROL_STR(2 .. 4) := INTEGER'IMAGE(SCREEN_HEIGHT);
CURSOR_CONTROL_STR(2) := '[';
CURSOR_CONTROL_STR(5 .. 7) := ";1H";
CURSOR_CONTROL_STR(1) := ASCII.ESC;
PUT_LINE(CURSOR_CONTROL_STR);

-- put cursor on line SCREEN_HEIGHT of screen
WAIT_STR(1) := 'c';
if END_OF_FILE(READ_IN_FILE) or (AT_LAST_LINE) then
PUT(" E[xit] S[ave] D[isplay again] ");
GET_LINE(WAIT_STR, WAIT_STR_LENGTH);
else
PUT(" E[xit] C[ontinue] S[ave] D[isplay again] ");
GET_LINE(WAIT_STR, WAIT_STR_LENGTH);
end if;
case WAIT_STR(1) is
when 'E' | ASCII.LC_E =>
LAST_COMMAND := EXIT_COMMAND;
EXIT_NOW := TRUE;
exit;
when 'S' | ASCII.LC_S =>
LAST_COMMAND := SAVE;
if not SAVING then
if not IS_OPEN(SAVE_FILE) then
CREATE(SAVE_FILE, OUT_FILE, LRM_READER_SAVE_FILE_NAME);
end if;
PUT_LINE(SAVE_FILE,
"Chapter reference from Ada Language Reference Manual:");
for I in 1 .. 11 loop
case CITATION_REQUESTED(I) is
when 'c' | 'C' =>
PUT(SAVE_FILE, "Chapter ");
when 's' | 'S' =>
PUT(SAVE_FILE, " Section ");
when 'v' | 'V' =>
PUT(SAVE_FILE, '.');
when 'p' | 'P' =>
PUT(SAVE_FILE, " Paragraph ");
when ' ' =>
null;
when others =>
PUT(SAVE_FILE, CITATION_REQUESTED(I));
end case;
end loop;
NEW_LINE(SAVE_FILE, 3);

-- write citation title to file save_file.
SAVING := TRUE;
if CURRENT_LINE > FIRST_LINE then
GOTO_FIRST_LINE(FIRST_LINE);
for I in FIRST_LINE .. CURRENT_LINE loop
READ_IN_LINE := EMPTY_STRING_156;
GET_LINE(READ_IN_FILE, READ_IN_LINE, LAST_CHAR);
PUT_LINE(SAVE_FILE, READ_IN_LINE(1 .. LAST_CHAR));
end loop;
end if;
end if;
when 'D' | ASCII.LC_D =>
LAST_COMMAND := DISPLAY_AGAIN;
GOTO_FIRST_LINE(FIRST_LINE);
CURRENT_LINE := FIRST_LINE - 1;
when 'C' | ASCII.LC_C =>
LAST_COMMAND := CONTINUE;

-- continue the display
when others =>
GOOD_ANSWER := FALSE;
end case;

-- while not good_answer loop
end loop;

-- while not eof(read_in_file) loop
end loop;


if SAVING then
NEW_LINE(SAVE_FILE, 3);
end if;
CLOSE(READ_IN_FILE);


end SCROLL_CHAP;





------------------------------------------------------------------------------

------------------------------------------------------------------------------


function EXTRACT_SECTION(CITATION : in STRING) return INTEGER is

-- Extract integer part of section number from citation.

FOUND : BOOLEAN := FALSE;
I : INTEGER;
FIRST_SECTION : INTEGER := 0;
LAST_SECTION : INTEGER := 0;

begin
I := 3;
loop
case CITATION(I) is
when 's' | 'S' =>
FIRST_SECTION := I + 1;
when 'v' | 'V' | 'p' | 'P' =>
LAST_SECTION := I - 1;
FOUND := TRUE;
when others =>
null;
end case;
if I = 11 then
exit;
else
I := I + 1;
end if;
exit when FOUND;
end loop;
if not FOUND then
for I in reverse 1 .. 11 loop
if CITATION(I) /= ' ' then
LAST_SECTION := I;
FOUND := TRUE;
exit when FOUND;
end if;
end loop;
end if;

return INTEGER'VALUE(CITATION(FIRST_SECTION .. LAST_SECTION));
end EXTRACT_SECTION;




------------------------------------------------------------------------------

function EXTRACT_CHAPTER(CITATION : in STRING) return INTEGER is

-- Extract chapter from citation.

FOUND : BOOLEAN := FALSE;
I : INTEGER;
LAST_CHAP : INTEGER := 0;

begin
I := 2;
loop
case CITATION(I) is
when 'p' | 'P' | 's' | 'S' =>
LAST_CHAP := I - 1;
FOUND := TRUE;
when others =>
null;
end case;
if I = 11 then
exit;
else
I := I + 1;
end if;
exit when FOUND;
end loop;
if not FOUND then
for I in reverse 1 .. 11 loop
if CITATION(I) /= ' ' then
LAST_CHAP := I;
FOUND := TRUE;
exit when FOUND;
end if;
end loop;
end if;

return INTEGER'VALUE(CITATION(2 .. LAST_CHAP));
end EXTRACT_CHAPTER;


------------------------------------------------------------------------------

procedure GET_NEXT_SECTION_NUMBER(NEXT_SECTION : in out STRING;
LAST_LINE : in out NATURAL;
UNTIL_EOF : in out BOOLEAN;
SUBSECTION : in BOOLEAN) is


ORIGINAL_CHAPTER : INTEGER; -- chapter part of requested chapter reference
ORIGINAL_SECTION : INTEGER; -- integer part of section of requested chapter reference
CURRENT_CHAPTER : INTEGER;
CURRENT_SECTION : INTEGER;
-- integer part of section of current chapter reference
NOT_PARAGRAPH : BOOLEAN;
NS : LEGAL_CITATIONS;
CITATION_STRING : STRING(1 .. 11);


begin
LAST_LINE := 0;
UNTIL_EOF := FALSE;
NS := LEGAL_CITATIONS'VALUE(NEXT_SECTION);
ORIGINAL_CHAPTER := EXTRACT_CHAPTER(NEXT_SECTION);
ORIGINAL_SECTION := EXTRACT_SECTION(NEXT_SECTION);
if SUBSECTION then
loop
NOT_PARAGRAPH := TRUE;
if NS /= C14S7P3 then
NS := LEGAL_CITATIONS'SUCC(NS);
else
UNTIL_EOF := TRUE;
goto DISPLAY_REMAINDER_OF_FILE;
end if;

-- >>>>>> detect next chapter
--
--
LEGAL_CITATIONS_IO.PUT(NEXT_SECTION, NS);
CURRENT_CHAPTER := EXTRACT_CHAPTER(NEXT_SECTION);
if CURRENT_CHAPTER > ORIGINAL_CHAPTER then
UNTIL_EOF := TRUE;
goto DISPLAY_REMAINDER_OF_FILE;
end if;
for I in reverse 1 .. 11 loop
if ((NEXT_SECTION(I) = 'p') or (NEXT_SECTION(I) = 'P')) then
NOT_PARAGRAPH := FALSE;
end if;
end loop;
if NOT_PARAGRAPH then
exit;
end if;
end loop;
else
loop
if NS /= C14S7P3 then
NS := LEGAL_CITATIONS'SUCC(NS);
else
UNTIL_EOF := TRUE;
goto DISPLAY_REMAINDER_OF_FILE;
end if;
LEGAL_CITATIONS_IO.PUT(NEXT_SECTION, NS);
CURRENT_CHAPTER := EXTRACT_CHAPTER(NEXT_SECTION);
if CURRENT_CHAPTER > ORIGINAL_CHAPTER then
UNTIL_EOF := TRUE;
goto DISPLAY_REMAINDER_OF_FILE;
else
CURRENT_SECTION := EXTRACT_SECTION(NEXT_SECTION);
if CURRENT_SECTION > ORIGINAL_SECTION then
UNTIL_EOF := FALSE;
goto DISPLAY_REMAINDER_OF_FILE;
end if;
end if;
end loop;

-- if subsection
end if;

<> null;

if not UNTIL_EOF then
LAST_LINE := CHAP_POINTERS(NS);
end if;
end GET_NEXT_SECTION_NUMBER;

------------------------------------------------------------------------------



------------------------------------------------------------------------------
procedure DO_CHAPTER_MENU(SAVE_FILE : in out FILE_TYPE) is


ALL_CHAPTER : BOOLEAN := FALSE;
ALL_SECTION : BOOLEAN := FALSE;
CHAP_FILENAME : STRING(1 .. 35) :=
" ";
CHAPTER_CHOICE : STRING(1 .. 5);
CHAPTER_CHOICE_INT : INTEGER;
CHAPTER_CHOICE_LEN_INT : INTEGER;

-- strictly local.
CITATION_REQUESTED : STRING(1 .. 11) := "c1p1 ";
CITATION_REQUESTED_LENGTH : NATURAL;
CITATION_TO_GET : LEGAL_CITATIONS := C1P1;
CITATION_MARKER : LEGAL_CITATIONS := C1P1;
EXIT_CHAPTER_LOOP : BOOLEAN;
EXIT_CHOICE : STRING(1 .. 5);
EXIT_CHOICE_LENGTH : NATURAL;
FIRST_LINE : NATURAL := 0;
FIRST_TIME_THROUGH_OUTER_LOOP : BOOLEAN := TRUE;
GOOD_ANSWER : BOOLEAN;
I : INTEGER := -1;
LAST_LINE : NATURAL := 0;
NEXT_CITATION : STRING(1 .. 11);
NEXT_CITATION_LENGTH : NATURAL;
NONEXISTENT_CITATION_MESSAGE : STRING(1 .. 78);
NONEXISTENT_CITATION_REPLY : STRING(1 .. 2);
NONEXISTENT_CITATION_REPLY_LEN : NATURAL;
PARAGRAPH_CHOICE : STRING(1 .. 5);
PARAGRAPH_CHOICE_LEN_INT : INTEGER;
PLACE : NATURAL := 0;
REQUEST_LENGTH : NATURAL := 2;
SECTION_BEGIN, SECTION_END : NATURAL := 0;
SECTION_CHOICE : STRING(1 .. 10);
SECTION_CHOICE_LEN_INT : INTEGER;
SUBSECTION : BOOLEAN;

--strictly local.
UNTIL_EOF : BOOLEAN := FALSE;
C1 : STRING(1 .. 3);
C2 : INTEGER;
ROW, COL : INTEGER;
DUMP_FILE : FILE_TYPE;

---------------------------------------
function CHAPTER_NUMBER(CHAP : in STRING;
CHAP_LEN : in INTEGER) return INTEGER is

--NOT ABLE TO MAKE THIS GLOBAL

I : INTEGER;
TEMP : INTEGER := 0;
begin
TEMP := INTEGER'VALUE(CHAP(1 .. CHAP_LEN));
return TEMP;
end CHAPTER_NUMBER;

---------------------------------------
function VALID_CHAPTER(CHAP : in INTEGER) return BOOLEAN is
TEMP_RESULT : BOOLEAN;
begin
case CHAP is
when 1 .. 14 =>
TEMP_RESULT := TRUE;
when others =>
TEMP_RESULT := FALSE;
end case;
return TEMP_RESULT;
end VALID_CHAPTER;

---------------------------------------
procedure GET_CITATION_FROM_USER is

-- local -- term_code
-- parameter -- chapter_choice_int
begin
CHAPTER_CHOICE := " ";
SECTION_CHOICE := " ";
PARAGRAPH_CHOICE := " ";

PUT("Enter chapter, please: ");
GET_LINE(CHAPTER_CHOICE, CHAPTER_CHOICE_LEN_INT);
PUT(" section: ");
GET_LINE(SECTION_CHOICE, SECTION_CHOICE_LEN_INT);
PUT(" paragraph: ");
GET_LINE(PARAGRAPH_CHOICE, PARAGRAPH_CHOICE_LEN_INT);

CHAPTER_CHOICE_INT := INTEGER'VALUE(CHAPTER_CHOICE);
if VALID_CHAPTER(CHAPTER_CHOICE_INT) then
GOOD_ANSWER := TRUE;
end if;
end GET_CITATION_FROM_USER;

---------------------------------------
procedure COMBINE_STRINGS_INTO_IMAGE_FORM is

-- local -- place, request_length, section_begin, section_end
begin
CITATION_REQUESTED := " ";
CITATION_REQUESTED_LENGTH := 0;
CITATION_REQUESTED(1) := 'C';
CITATION_REQUESTED(2 .. 2) := CHAPTER_CHOICE(1 .. 1);
CITATION_REQUESTED(2 .. (CHAPTER_CHOICE_LEN_INT + 1)) := CHAPTER_CHOICE(1
.. CHAPTER_CHOICE_LEN_INT);
PLACE := CHAPTER_CHOICE_LEN_INT + 2;
REQUEST_LENGTH := PLACE - 1;
if (SECTION_CHOICE_LEN_INT > 0) then
CITATION_REQUESTED(PLACE) := 'S';
SECTION_BEGIN := PLACE + 1;
for I in 1 .. SECTION_CHOICE_LEN_INT loop
if SECTION_CHOICE(I) = '.' then
CITATION_REQUESTED(PLACE + I) := 'v';
SUBSECTION := TRUE;
else
CITATION_REQUESTED(PLACE + I) := SECTION_CHOICE(I);
end if;
end loop;
SECTION_END := SECTION_BEGIN + SECTION_CHOICE_LEN_INT - 1;
PLACE := PLACE + SECTION_CHOICE_LEN_INT + 1;
REQUEST_LENGTH := PLACE - 1;
if PARAGRAPH_CHOICE_LEN_INT <= 0 then
ALL_SECTION := TRUE;
end if;
else
if PARAGRAPH_CHOICE_LEN_INT <= 0 then
ALL_CHAPTER := TRUE;
end if;
end if;

-- if section_choice_len_int > 0
if (PARAGRAPH_CHOICE_LEN_INT > 0) then
CITATION_REQUESTED(PLACE) := 'P';
CITATION_REQUESTED((PLACE + 1) .. (PLACE + PARAGRAPH_CHOICE_LEN_INT))
:= PARAGRAPH_CHOICE(1 .. PARAGRAPH_CHOICE_LEN_INT);
REQUEST_LENGTH := PLACE + PARAGRAPH_CHOICE_LEN_INT;
end if;

-- if paragraph_choice_len_int > 0
end COMBINE_STRINGS_INTO_IMAGE_FORM;

---------------------------------------
procedure FILL_IN_CHAPTER_FILENAME(CHAP_FILENAME : out STRING;
CHAPTER_CHOICE_INT : in INTEGER) is

TEMP_CHAP_FILENAME : STRING(1 .. 10) := "chap .doc";
TEMP_LENGTH : NATURAL;

begin
if CHAPTER_CHOICE_INT in 1 .. 14 then
case CHAPTER_CHOICE_INT is
when 1 =>
TEMP_CHAP_FILENAME(5 .. 6) := "01";
when 2 =>
TEMP_CHAP_FILENAME(5 .. 6) := "02";
when 3 =>
TEMP_CHAP_FILENAME(5 .. 6) := "03";
when 4 =>
TEMP_CHAP_FILENAME(5 .. 6) := "04";
when 5 =>
TEMP_CHAP_FILENAME(5 .. 6) := "05";
when 6 =>
TEMP_CHAP_FILENAME(5 .. 6) := "06";
when 7 =>
TEMP_CHAP_FILENAME(5 .. 6) := "07";
when 8 =>
TEMP_CHAP_FILENAME(5 .. 6) := "08";
when 9 =>
TEMP_CHAP_FILENAME(5 .. 6) := "09";
when 10 =>
TEMP_CHAP_FILENAME(5 .. 6) := "10";
when 11 =>
TEMP_CHAP_FILENAME(5 .. 6) := "11";
when 12 =>
TEMP_CHAP_FILENAME(5 .. 6) := "12";
when 13 =>
TEMP_CHAP_FILENAME(5 .. 6) := "13";
when 14 =>
TEMP_CHAP_FILENAME(5 .. 6) := "14";
when others =>
null;
end case;

-- Length of CHAP_FILENAME := LRM_FILE_NAME_PREFIX_LENGTH
-- + Length(TEMP_CHAP_FILENAME)
TEMP_LENGTH := LRM_FILE_NAME_PREFIX_LENGTH + 10;
CHAP_FILENAME(1 .. TEMP_LENGTH) := LRM_FILE_NAME_PREFIX(1 ..
LRM_FILE_NAME_PREFIX_LENGTH) & TEMP_CHAP_FILENAME;
end if;
end FILL_IN_CHAPTER_FILENAME;

---------------------------------------
procedure VALIDATE_CITATION(CITATION_REQUESTED : in STRING;
REQUEST_LENGTH : in NATURAL;
CITATION_TO_GET : out LEGAL_CITATIONS) is
begin

CITATION_TO_GET := LEGAL_CITATIONS'VALUE(CITATION_REQUESTED(1 ..
REQUEST_LENGTH));

end VALIDATE_CITATION;

------------------------------------------------------------
-- do_chapter_menu body
------------------------------------------------------------


--do_chapter_menu
begin

EXIT_CHAPTER_LOOP := FALSE;

loop

-- block for exception CONSTRAINT_ERROR
begin
CLS;
if not FIRST_TIME_THROUGH_OUTER_LOOP then
PUT("Do you want to leave the Chapter Menu now? ");
GET_LINE(EXIT_CHOICE, EXIT_CHOICE_LENGTH);
CLS;
end if;
FIRST_TIME_THROUGH_OUTER_LOOP := FALSE;

case EXIT_CHOICE(1) is
when 'y' | 'Y' =>
EXIT_CHAPTER_LOOP := TRUE;
when others =>
null;
end case;

exit when EXIT_CHAPTER_LOOP;

DISPLAY_CHAPTER_MENU(MENU_CHAPTER_FILE_NAME);

GOOD_ANSWER := FALSE;
while not GOOD_ANSWER loop
GET_CITATION_FROM_USER;
end loop;

-- Combine the contents of strings chapter_choice, section_choice
-- and paragraph_choice into one string in the same format as
-- the enumerated type legal_citations.
SUBSECTION := FALSE;
COMBINE_STRINGS_INTO_IMAGE_FORM;

-- Here we have at least a valid chapter.
-- See if its a legal citation.
-- If its NOT a legal citation, will raise exception constraint_error,
-- perform exception block (when constraint_error), and
-- exit procedure do_chapter_menu.
VALIDATE_CITATION(CITATION_REQUESTED, REQUEST_LENGTH, CITATION_TO_GET);

FILL_IN_CHAPTER_FILENAME(CHAP_FILENAME, CHAPTER_CHOICE_INT);
FIRST_LINE := CHAP_POINTERS(CITATION_TO_GET);


if PARAGRAPH_CHOICE_LEN_INT > 0 then
LAST_LINE := CHAP_POINTERS(LEGAL_CITATIONS'SUCC(CITATION_TO_GET));
SCROLL_CHAP(CHAP_FILENAME, FIRST_LINE, LAST_LINE, SAVE_FILE, FALSE,
CITATION_REQUESTED);
else
if SECTION_CHOICE_LEN_INT <= 0 then

-----entire chapter
SCROLL_CHAP(CHAP_FILENAME, FIRST_LINE, 0, SAVE_FILE, TRUE,
CITATION_REQUESTED);
else
NEXT_CITATION := CITATION_REQUESTED;
GET_NEXT_SECTION_NUMBER(NEXT_CITATION, LAST_LINE, UNTIL_EOF,
SUBSECTION);
SCROLL_CHAP(CHAP_FILENAME, FIRST_LINE, LAST_LINE, SAVE_FILE,
UNTIL_EOF, CITATION_REQUESTED);
end if;
end if;


exception
when CONSTRAINT_ERROR =>
PUT_LINE(ASCII.ESC & "[21;1H");
-- put cursor at line 21, column 1
NONEXISTENT_CITATION_MESSAGE := (others => ' ');
NONEXISTENT_CITATION_MESSAGE(1 .. 7) := "Chapter";
NONEXISTENT_CITATION_MESSAGE(9 .. (8 + CHAPTER_CHOICE_LEN_INT)) :=
CHAPTER_CHOICE(1 .. CHAPTER_CHOICE_LEN_INT);
PLACE := 10 + CHAPTER_CHOICE_LEN_INT;
if SECTION_CHOICE_LEN_INT > 0 then
NONEXISTENT_CITATION_MESSAGE(PLACE .. PLACE + 6) := "Section";
PLACE := PLACE + 8;
NONEXISTENT_CITATION_MESSAGE(PLACE .. (PLACE +
SECTION_CHOICE_LEN_INT - 1)) := SECTION_CHOICE(1 ..
SECTION_CHOICE_LEN_INT);
PLACE := PLACE + SECTION_CHOICE_LEN_INT + 1;
end if;
if PARAGRAPH_CHOICE_LEN_INT > 0 then
NONEXISTENT_CITATION_MESSAGE(PLACE .. PLACE + 8) := "Paragraph";
PLACE := PLACE + 10;
NONEXISTENT_CITATION_MESSAGE(PLACE .. (PLACE +
PARAGRAPH_CHOICE_LEN_INT - 1)) := PARAGRAPH_CHOICE(1 ..
PARAGRAPH_CHOICE_LEN_INT);
PLACE := PLACE + PARAGRAPH_CHOICE_LEN_INT + 1;
end if;
NONEXISTENT_CITATION_MESSAGE(PLACE .. PLACE + 24) :=
"is not a valid reference.";
PUT_LINE(NONEXISTENT_CITATION_MESSAGE);
NEW_LINE;
-- Display "Please try again " message.
PUT(" Please try again. ");
GET_LINE(NONEXISTENT_CITATION_REPLY, NONEXISTENT_CITATION_REPLY_LEN);

-- end of block for exception CONSTRAINT_ERROR
end;

end loop;




end DO_CHAPTER_MENU;

--------------------------------------------------------------------------
end LRM_NON_SMG;

------------------------------------------------------------------------------


  3 Responses to “Category : Miscellaneous Language Source Code
Archive   : ADA-LRM3.ZIP
Filename : LR7AVCB.SRC

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/