%Tyrell Cromoshuk
%Tues, Oct 11, 2005
%The user enters a word and it outputs the middle letter(s) depending on the size of the word(even or odd amount of chars)
import GUI in "%oot/lib/GUI"
var winID : int
winID := Window.Open ("position:top;center,graphics:640;480")
%-------------------------------------------------Variable Table--------------------------------------------------------
var letter : int := 0
var middle, middle1 : int
var word : string
var introscreen, layout1, layout2, layout3 : int
var key, key1, key2 : string (1)
var font1 : int
%---------------------------------------------------End of Table--------------------------------------------------------
%Allows the quit button to work
procedure Quit
Pic.Draw (layout3, 0, 0, picCopy)
delay (4000)
Window.Close (winID)
end Quit
%Fonts
font1 := Font.New ("Times New Roman:16")
%Layouts for the program
introscreen := Pic.FileNew ("c:/Warmup4IntroScreen.jpg")
layout1 := Pic.FileNew ("c:/Warmup4WordScreen.jpg")
layout2 := Pic.FileNew ("c:/Warmup4MiddleScreen.jpg")
layout3 := Pic.FileNew ("c:/Warmup4ClosingScreen.jpg")
procedure restart
%Draws the intro screen for the program
View.Set ("nocursor")
Pic.Draw (introscreen, 0, 0, picCopy)
locate (23, 2)
getch (key)
cls
%Draws the next screen and asks the user to input a word
Pic.Draw (layout1, 0, 0, picCopy)
locate (11, 39)
get word : *
letter := length (word)
if letter / 2 = letter div 2 then
middle := letter div 2
middle1 := middle + 1
word := word (middle) + word (middle + 1)
Font.Draw ("Even", 355, 134, font1, red)
getch (key1)
cls
else
middle := letter div 2 + 1
word := word (middle)
Font.Draw ("Odd", 355, 134, font1, red)
getch (key1)
cls
end if
%Draws the next screen and gets the user to decide what they want to do next
Pic.Draw (layout2, 0, 0, picCopy)
Font.Draw (word, 355, 280, font1, red)
%Creates the buttons
var b : int := GUI.CreateButton (25, 270, 0, " Restart", restart)
var quitButton := GUI.CreateButton (25, 230, 0, "Quit!", Quit)
loop
exit when GUI.ProcessEvent
end loop
end restart
restart
|