import GUI
var w1 : int := Window.Open ("graphics:400;120,nobuttonbar")
colourback (gray)
cls
var maxItems : int := 1
var addItemBox, addItemTextBox, showItemTextBox, itemBox, choseItemBox, quitButton : int
var font1 : int := Font.New ("Arial:10:Bold")
var font2 : int := Font.New ("Arial:8")
var textBox : int
var items : flexible array 1 .. maxItems of string
var ch : string := ""
for i : 1 .. maxItems
items (i) := ""
end for
proc addItem (text : string)
var skipit : boolean := false
if text = "" then
skipit := true
else
for w : 1 .. maxItems
if text = items (maxItems) then
skipit := true
else
end if
end for
if skipit = false then
var file : int
open : file, "saveditems.txt", put, mod, seek
seek : file, *
put : file, text
close : file
GUI.AddLine (textBox, text)
new items, maxItems + 1
maxItems := maxItems + 1
items (maxItems) := text
GUI.SetText (addItemTextBox, "")
else
end if
end if
end addItem
proc openItems
var file : int
var next : int := 1
if File.Exists ("saveditems.txt") then
open : file, "saveditems.txt", get
loop
exit when eof (file)
get : file, items (maxItems) : *
GUI.AddLine (textBox, items (maxItems))
new items, maxItems + 1
maxItems := maxItems + 1
end loop
close : file
else
maxItems := 0
end if
end openItems
proc ChoseLine (line : int)
var font1 : int := Font.New ("Arial:10")
var text : string
if line not= 0 then
text := "You chose " + items (line) + "."
GUI.SetText (showItemTextBox, text)
else
end if
end ChoseLine
proc null (text : string)
end null
addItemTextBox := GUI.CreateTextField (195, 90, 180, "", addItem)
showItemTextBox := GUI.CreateTextField (195, 40, 180, "", null)
Font.Draw ("Item:", 160, 94, font1, black)
Font.Draw ("Chose:", 148, 44, font1, black)
textBox := GUI.CreateTextBoxChoice (10, 10, 120, maxy - 25, 0, 0, ChoseLine)
itemBox := GUI.CreateLabelledFrame (2, 2, 137, maxy - 5, GUI.LINE, "Items")
choseItemBox := GUI.CreateLabelledFrame (maxx - 2, 70, 137, 27, GUI.LINE, "Chosen Suitcase Item")
addItemBox := GUI.CreateLabelledFrame (maxx - 2, maxy - 5, 137, 80, GUI.LINE, "Add Items to the Suitcase")
quitButton := GUI.CreateButton (maxx - 57, 1, 40, "Quit", GUI.Quit)
GUI.Disable (showItemTextBox)
openItems
GUI.SetActive (addItemTextBox)
loop
exit when GUI.ProcessEvent
end loop
Window.Close (w1)
|