import GUI in "%oot/lib/GUI"
% --------------------------------------------------- Variable Table -------------------------------------------------------
var key, input_char : string (1)
var word : string := ""
var winID, oddeven, middle1, middle2, lengthword, introscreen, layoutscreen, closingscreen, font1, font2 : int
% ------------------------------------------------------ End Table ---------------------------------------------------------
% ---------------------------------------------- Values for Pictures, Fonts ------------------------------------------------
introscreen := Pic.FileNew ("e:/turinglayout4intro.jpg")
layoutscreen := Pic.FileNew ("e:/turinglayout4.jpg")
closingscreen := Pic.FileNew ("e:/turinglayout4close.jpg")
font1 := Font.New ("arial:10")
font2 := Font.New ("comicsansms:20")
% ------------------------------------------------------ End Values --------------------------------------------------------
% ----------------------------------------------------- Open Window --------------------------------------------------------
winID := Window.Open ("position:middle,center, graphics: 640;480, Title:Middle Letter Machine")
% This opens a window with a specific position on screen, a speicifc size, and with a custom title
% ------------------------------------------------------ End Window --------------------------------------------------------
% -------------------------------------------------------- Music -----------------------------------------------------------
process coldplay
loop
Music.PlayFile ("e:/coldplay.MP3")
end loop
end coldplay
% This opens a music file, is called later in the program, and repeats until the program is exited
% ------------------------------------------------------ End Music ---------------------------------------------------------
% ------------------------------------------------ Finding Middle Letters --------------------------------------------------
procedure calculate
if lengthword div 2 = lengthword / 2 then
Font.Draw ("Your word contains an even number of letters", 290, 70, font1, white)
middle1 := lengthword div 2
middle2 := middle1 + 1
Font.Draw ("Your middle letters of the word inputted are", 290, 50, font1, white)
Font.Draw (word (middle1), 370, 30, font2, white)
Font.Draw ("And", 395, 30, font1, white)
Font.Draw (word (middle2), 430, 30, font2, white)
else
Font.Draw ("Your word contains an odd amount of letters", 290, 70, font1, white)
middle1 := lengthword div 2 + 1
Font.Draw ("Your middle letter is", 350, 50, font1, white)
Font.Draw (word (middle1), 410, 30, font2, white)
end if
end calculate
% -------------------------------------------------- End Middle Letters ----------------------------------------------------
% ---------------------------------------------------- Closes Window -------------------------------------------------------
procedure exitprog
Window.Close (winID)
end exitprog
% This procedure is used to completely close the run screen, is called later in program by the button "Quit"
% -------------------------------------------------- End Close Window ------------------------------------------------------
% ---------------------------------------------------- Closing Screen ------------------------------------------------------
procedure finish
cls
Pic.Draw (closingscreen, 0, 0, picCopy)
var exitprogram : int := GUI.CreateButton (146, 37, 350, "Click Here To Completly Close The Program", exitprog)
end finish
% -------------------------------------------------- End Closing Screen ----------------------------------------------------
% ---------------------------------------------------- Main Program --------------------------------------------------------
procedure complete
View.Set ("nocursor")
Pic.Draw (introscreen, 0, 0, picCopy)
fork coldplay
getch (key)
cls
Pic.Draw (layoutscreen, 0, 0, picCopy)
locate (maxrow div 1.3, round (maxcol / 1.8))
get word:*
lengthword := length (word)
var calculator : int := GUI.CreateButton (17, 252, 120, "Calculate", calculate)
var repeatButton : int := GUI.CreateButton (17, 148, 120, "Repeat", complete)
var quitButton := GUI.CreateButton (17, 30, 120, "Quit", finish)
loop
exit when GUI.ProcessEvent
end loop
end complete
% --------------------------------------------------End Main Program -------------------------------------------------------
complete
|