% procedure clears the help box once user wishes to exit option.
procedure exit_help
    x := 130
    y := 275
    x1 := 497
    y1 := 47
    for i : 1 .. 115
	drawbox (x, y, x1, y1, 2)
	drawbox (x, y, x1, y1, 0)
	x := x + 1
	x1 := x1 - 1
	y := y - 1
	y1 := y1 + 1
    end for
end exit_help

% procedure deletes the main menu screen and brings up the help menu screen.
procedure enter_help
    x := 244
    y := 161
    x1 := 383
    y1 := 161
    for i : 1 .. 112
	x := x - 1
	x1 := x1 + 1
	y := y + 1
	y1 := y1 - 1
	drawbox (x, y, x1, y1, 2)
	drawbox (x, y, x1, y1, 0)
	if i = 3 then
	    locate (14, 33)
	    put "              "
	end if
    end for
    drawbox (130, 275, 497, 47, 10)
    drawbox (132, 273, 495, 49, 10)
end enter_help

% procedure blanks the help screen.
procedure blank_help_page
    for i : 8 .. 21
	locate (i, 19)
	put "                                           "
    end for
    locate (24, 26)
    put "                              "
end blank_help_page

% procedure displays the information dealing with help for the main menu.
procedure help_options
    locate (8, 36)
    put "OPTIONS"
    locate (10, 19)
    color (3)
    put " After you have selected one of the options"
    locate (11, 19)
    put "you will  see the  first information screen"
    locate (12, 19)
    put "dealing  with  that  option  pop up  on the"
    locate (13, 19)
    put "screen.  From  this  screen,  you  can  use"
    locate (14, 19)
    put "whatever  buttons are  presented to  you on"
    locate (15, 19)
    put "the screen. i.e. If you see 'PgUp', 'PgDn',"
    locate (15, 48)
    color (12)
    put "PgUp"
    locate (15, 56)
    put "PgDn"
    color (3)
    locate (16, 19)
    put "and 'Main Menu (M)' buttons  on the screen,"
    locate (16, 24)
    color (12)
    put "Main Menu (M)"
    color (3)
    locate (17, 19)
    put "simply press 'PgUp' to flip to the previous"
    locate (17, 33)
    color (12)
    put "PgUp"
    color (3)
    locate (18, 19)
    put "page of  information, 'PgDn' to flip to the"
    locate (18, 42)
    color (12)
    put "PgDn"
    color (3)
    locate (19, 19)
    put "next page of information, or 'M' to exit to"
    locate (19, 49)
    color (12)
    put "M"
    color (3)
    locate (20, 19)
    put "the Main Menu.  All of the buttons used in"
    locate (21, 19)
    put "this tutorial are pretty self explanatory."
    locate (24, 27)
    color (10)
    put "HIT ANY KEY TO CONTINUE!"
    locate (25, 1)
    getch (helpreply)
    blank_help_page
end help_options

% procedure displays the mainmenu help screen
procedure help_main
    locate (8, 35)
    put "MAIN MENU"
    locate (10, 19)
    color (3)
    put "  From the main menu screen, you can do two"
    locate (11, 19)
    put "things:"
    locate (12, 30)
    put "1. Choose an option"
    locate (13, 30)
    put "2. Quit to Dos"
    locate (15, 19)
    put "To choose of one the nine possible options,"
    locate (16, 19)
    put "simply use the '"
    locate (16, 35)
    color (12)
    put chr (24)
    color (3)
    locate (16, 36)
    put "' and '"
    locate (16, 43)
    color (12)
    put chr (25)
    color (3)
    locate (16, 44)
    put "' keys to position"
    locate (17, 19)
    put "the two  small atoms next to the option you"
    locate (18, 19)
    put "desire and press  'ENTER'."
    color (12)
    locate (18,38)
    put "ENTER"
    color (3)
    locate (19, 19)
    put "  To quit to DOS, simply  go  to the 'QUIT'"
    color (12)
    locate (19,57)
    put "Quit"
    color (3)
    locate (20, 19)
    put "option in the main menu and press 'ENTER'."
    color (12)
    locate (20,54)
    put "ENTER"
    locate (24, 27)
    color (10)
    put "HIT ANY KEY TO CONTINUE!"
    locate (25, 1)
    getch (helpreply)
    blank_help_page
end help_main


% Is the main call up procedure for the help option.  It draws the help
% menu and calls up all procedures needed to make option work.
procedure help_mainmenu
    colour (10)
    locate (7, 34)
    put "HELP SCREEN"
    delay (55)

    delay (55)
    color (3)
    locate (11, 23)
    put "Welcome to the main help screen of"
    delay (55)
    locate (12, 23)
    put "     Chemistry Tutorial V1.0"
    delay (55)
    locate (14, 26)
    put "What do you need help with?"
    delay (55)
    drawbox (242, 134, 372, 74, 10)
    drawbox (244, 132, 370, 76, 10)
    loop
	flag := 0
	if helpoption = 1 then
	    locate (19, 33)
	    put " "
	    locate (19, 45)
	    put " "
	    locate (18, 33)
	    put " "
	    locate (18, 45)
	    put " "
	    colour (2)
	    locate (17, 35)
	    put "MAIN MENU"
	    colour (10)
	    locate (17, 33)
	    put chr (26)
	    locate (17, 45)
	    put chr (27)
	else
	    colour (10)
	    locate (17, 35)
	    put "MAIN MENU"
	end if

	if helpoption = 2 then
	    locate (17, 33)
	    put " "
	    locate (17, 45)
	    put " "
	    locate (19, 33)
	    put " "
	    locate (19, 45)
	    put " "
	    locate (18, 35)
	    colour (2)
	    put " OPTIONS"
	    colour (10)
	    locate (18, 33)
	    put chr (26)
	    locate (18, 45)
	    put chr (27)
	else
	    locate (18, 35)
	    colour (10)
	    put " OPTIONS"
	end if

	if helpoption = 3 then
	    locate (18, 33)
	    put " "
	    locate (18, 45)
	    put " "
	    locate (17, 33)
	    put " "
	    locate (17, 45)
	    put " "
	    colour (2)
	    locate (19, 35)
	    put "  EXIT"
	    colour (10)
	    locate (19, 33)
	    put chr (26)
	    locate (19, 45)
	    put chr (27)
	else
	    locate (19, 35)
	    colour (10)
	    put "  EXIT"
	end if
	loop
	    getch (helpreply)
	       % 'if' statements check what key has been inputted by user.
	    if helpreply = chr (208) then
		if helpoption = 3 then
		    helpoption := 1
		else
		    helpoption := helpoption + 1
		end if
	    elsif helpreply = chr (200) then
		if helpoption = 1 then
		    helpoption := 3
		else
		    helpoption := helpoption - 1
		end if
	    elsif helpreply = chr (10) then
		flag := 1
		exit
	    else
		sound (100, 100)
	    end if
	    exit
	end loop
	exit when flag = 1
    end loop
end help_mainmenu

% procedure checks what option in the help main menu has been chosen and
% performs that option.
procedure helpmain
    loop
	help_mainmenu
	loop
	    if helpoption = 1 then
		delay (500)
		blank_help_page
		help_main
		flag := 4
		exit
	    elsif helpoption = 2 then
		delay (500)
		blank_help_page
		help_options
		flag := 4
		exit
	    elsif helpoption = 3 then
		delay (500)
		exit
	    end if
	end loop
	exit when flag not= 4
    end loop
end helpmain
