Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 GUI Crashing with Keypress
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
vapour99




PostPosted: Tue Jan 06, 2009 2:09 pm   Post subject: GUI Crashing with Keypress

Hi;

I have been using turing GUI in a summative database project and just recently have noticed that pressing a key will crash the program to "widgetmobile.tu" in many cases. It was avoided by selecting certain textfields before typing, but now it crashes in some of my textfields as well!

I'm not sure what is causing this, but I hope there is a workaround, From what I understand, Turing's GUI is very buggy. I have a copy of LGUI ready to go, but i would prefer to fix this issue if possible and save rewriting my entire program in a different syntax. Code here with picture files, etc avaliable if need be.

Any help is much appreciated!

code:

import GUI
var nameTextField, addressTextField, numberTextField, fileTextField, file2, successful, ind, doneButton, win, first, saveButton, second, file, box, picture, sni, bck, bck2, fileName, errorLabel1,
    errorLabel2, filenameLabel, loadingpicture, textboxTextField, textboxchoice : int
var firstname, lastname, seatnum, report, num, list, part, filename, list2, chosen : string
var arrayitems : flexible array 1 .. 0 of string
var item : array 1 .. 6 of int % The menu items.
var name : array 1 .. 6 of string (20) := init ("Open", "Save As", "---", "Quit", "Add Passenger", "Edit Passenger List")
var nameLabel, addressLabel, numberLabel, textBox : int
win := Window.Open ("graphics:670;350,nobuttonbar")
bck := Pic.FileNew ("airrecordsbck.jpg")
bck2 := Pic.FileNew ("logo.gif")
ind := 0
var ch : string (1)

%%%% creates all procedures %%%%
proc MenuSelected
    for i : 1 .. 6
        if item (i) = GUI.GetEventWidgetID then
            Text.Locate (maxrow, 1)
            put name (i) + " selected               " ..
        end if
    end for
end MenuSelected

procedure ChoseLine (line : int)
    chosen := arrayitems (line)
    GUI.SetText (textboxTextField, chosen)
end ChoseLine

procedure NameEntered (text : string)
    GUI.SetSelection (addressTextField, 0, 0)
    GUI.SetActive (addressTextField)
end NameEntered

procedure AddressEntered (text : string)
    GUI.SetSelection (nameTextField, 0, 0)
    GUI.SetActive (nameTextField)
end AddressEntered

procedure textboxfield (text : string)
    GUI.SetSelection (textboxTextField, 0, 0)
    GUI.SetActive (textboxTextField)
end textboxfield

procedure NumberEntered (text : string)
    GUI.SetSelection (numberTextField, 0, 0)
    GUI.SetActive (numberTextField)
end NumberEntered

procedure fileEntered (text : string)
    GUI.SetSelection (fileTextField, 0, 0)
    GUI.SetActive (fileTextField)
end fileEntered

proc done
    ind := 1
end done

%%%% creates all error checking procs %%%% -add a strintok
proc seatcheck (sns : string)
    for a : 1 .. 5
        GUI.Hide (errorLabel1)
        GUI.Hide (errorLabel2)
    end for
    if strintok (sns) = false then
        ind := 1
        GUI.Show (errorLabel1)
        delay (1000)
        GUI.Hide (errorLabel1)
    else
        sni := strint (sns)
        if sni > 12 or sni < 1 then
            ind := 1
            GUI.Show (errorLabel2)
            delay (1000)
            GUI.Hide (errorLabel2)
        end if
    end if
end seatcheck

proc writeinfo
    firstname := GUI.GetText (nameTextField)
    lastname := GUI.GetText (addressTextField)
    seatnum := GUI.GetText (numberTextField)
    seatcheck (seatnum)
    if ind = 0 then
        open : file, "airrecords.t", put
        firstname := firstname + " "
        lastname := lastname + " "
        seatnum := seatnum + " "
        if file = 0 then
            put "Error with file 'airrecords.txt', check for errors "
        else
            put : file, firstname
                ..
            put : file, lastname
                ..
            put : file, seatnum
        end if
        close : file
        open : file, "airrecords.t", get
        if file = 0 then
            put "Error with file 'airrecords.txt', check for errors "
        else
            loop
                exit when eof (file)
                get : file, part : *
                GUI.AddLine (textBox, part)
                GUI.AddLine (textboxchoice, part)
            end loop
        end if
        close : file
        GUI.Show (successful)
        delay (1000)
        GUI.Hide (successful)
        GUI.Refresh
    elsif ind = 1 then
        ind := 0
    end if
end writeinfo

setscreen ("offscreenonly,nocursor")
%%%% creates all objects %%%%
loadingpicture := GUI.CreatePicture (0, 0, bck2, false)
picture := GUI.CreatePicture (0, -8, bck, false)
doneButton := GUI.CreateButton (550, 305, 100, "ok", writeinfo)
nameTextField := GUI.CreateTextFieldFull (50, 307, 100, "", NameEntered, GUI.INDENT, 0, 0)
textboxchoice := GUI.CreateTextBoxChoice (10, 10, 490, 275, 0, 0, ChoseLine)
textboxTextField := GUI.CreateTextFieldFull (559, 270, 290, "", textboxfield, GUI.INDENT, 0, 0)
addressTextField := GUI.CreateTextFieldFull (230, 307, 100, "", AddressEntered, GUI.INDENT, 0, 0)
numberTextField := GUI.CreateTextFieldFull (420, 307, 100, "", NumberEntered, GUI.INDENT, 0, 0)
fileTextField := GUI.CreateTextFieldFull (420, 307, 100, "", fileEntered, GUI.INDENT, 0, 0)
nameLabel := GUI.CreateLabelFull (39, 308, "Name:", 0, 0, GUI.RIGHT, 0)
addressLabel := GUI.CreateLabelFull (220, 308, "Last Name:", 0, 0, GUI.RIGHT, 0)
numberLabel := GUI.CreateLabelFull (412, 308, "Seat Number:", 0, 0, GUI.RIGHT, 0)
filenameLabel := GUI.CreateLabelFull (412, 308, "File Name:", 0, 0, GUI.RIGHT, 0)
fileName := GUI.CreateLabelFull (173, 290, "airrecords.t", 0, 0, GUI.RIGHT, 0)
textBox := GUI.CreateTextBoxFull (10, 10, 490, 275, GUI.INDENT, 0)
errorLabel2 := GUI.CreateLabelFull (270, 290, "Seat number must be between 1 and 12", 0, 0, GUI.RIGHT, 0)
errorLabel1 := GUI.CreateLabelFull (270, 290, "Seat number must be a number", 0, 0, GUI.RIGHT, 0)
successful := GUI.CreateLabelFull (650, 290, "Added Successfully", 0, 0, GUI.RIGHT, 0)
for u : 1 .. 5
    GUI.Hide (textboxTextField)
    GUI.Hide (successful)
    GUI.Hide (fileTextField)
    GUI.Hide (picture)
    GUI.Hide (doneButton)
    GUI.Hide (nameTextField)
    GUI.Hide (addressTextField)
    GUI.Hide (numberTextField)
    GUI.Hide (nameLabel)
    GUI.Hide (addressLabel)
    GUI.Hide (numberLabel)
    GUI.Hide (textBox)
    GUI.Hide (errorLabel1)
    GUI.Hide (errorLabel2)
    GUI.Hide (fileName)
    GUI.Hide (filenameLabel)
    GUI.Hide (textboxchoice)
    GUI.Refresh
end for
setscreen ("nooffscreenonly")
GUI.Show (loadingpicture)
getch (ch)
GUI.Hide (loadingpicture)


%%%% Creates 'functional' procedures %%%%
proc saveas
    for t : 1 .. 5
        GUI.Hide (textBox)
        GUI.Hide (textboxTextField)
        GUI.Hide (successful)
        GUI.Hide (saveButton)
        GUI.Hide (doneButton)
        GUI.Hide (nameTextField)
        GUI.Hide (addressTextField)
        GUI.Hide (numberTextField)
        GUI.Hide (nameLabel)
        GUI.Hide (addressLabel)
        GUI.Hide (numberLabel)
        GUI.Hide (picture)
        GUI.Hide (fileName)
        GUI.Hide (textboxTextField)
    end for
    GUI.Show (textboxchoice)
    GUI.Show (fileTextField)
    GUI.Show (saveButton)
    GUI.Show (filenameLabel)
end saveas

proc savelist % make it save to a new file
    list2 := list
    filename := GUI.GetText (fileTextField)
    filename := filename + ".t"
    Dir.Change ("Records")
    open : file2, filename, put
    if ind = 0 then
        if file2 = 0 then
            put "Error with file"
        else
            put : file2, list2
            GUI.Show (successful)
            delay (1000)
            GUI.Hide (successful)
        end if
        close : file2
    end if
end savelist

%%% save button %%%%
saveButton := GUI.CreateButton (550, 305, 100, "ok", savelist)
for u : 1 .. 5
    GUI.Hide (saveButton)
end for
%%%%%

proc addP
    for k : 1 .. 5
        GUI.Hide (textboxTextField)
        GUI.Hide (successful)
        GUI.Hide (fileTextField)
        GUI.Hide (saveButton)
        GUI.Hide (fileName)
        GUI.Hide (textBox)
        GUI.Hide (filenameLabel)
        GUI.Hide (textboxchoice)
        GUI.Refresh
    end for
    GUI.Show (picture)
    GUI.Show (doneButton)
    GUI.Show (nameTextField)
    GUI.Show (addressTextField)
    GUI.Show (numberTextField)
    GUI.Show (numberLabel)
    GUI.Show (nameLabel)
    GUI.Show (addressLabel)
end addP

proc remP % AKA edit passenger list
    for i : 1 .. 5
        GUI.Hide (textboxTextField)
        GUI.Hide (successful)
        GUI.Hide (fileTextField)
        GUI.Hide (saveButton)
        GUI.Hide (doneButton)
        GUI.Hide (nameTextField)
        GUI.Hide (addressTextField)
        GUI.Hide (numberTextField)
        GUI.Hide (nameLabel)
        GUI.Hide (addressLabel)
        GUI.Hide (numberLabel)
        GUI.Hide (picture)
        GUI.Hide (fileName)
        GUI.Hide (filenameLabel)
        GUI.Hide (textboxchoice)
        GUI.Refresh
    end for
    GUI.Show (textboxchoice)
    GUI.Show (textboxTextField)
end remP

proc Open % used to open other airplane records
    for i : 1 .. 5
        GUI.Hide (successful)
        GUI.Hide (fileTextField)
        GUI.Hide (saveButton)
        GUI.Hide (doneButton)
        GUI.Hide (nameTextField)
        GUI.Hide (addressTextField)
        GUI.Hide (numberTextField)
        GUI.Hide (nameLabel)
        GUI.Hide (addressLabel)
        GUI.Hide (numberLabel)
        GUI.Hide (picture)
        GUI.Hide (filenameLabel)
        GUI.Hide (textboxchoice)
        GUI.Refresh
    end for
    GUI.Show (fileName)
    GUI.Show (textboxTextField)
    GUI.Show(textBox)
end Open

proc Quit
    GUI.Quit
    Window.Close (win)
end Quit

%%%%%%PROGRAM%%%%%%%
var cnt :int  := 0
list := ""
open : file, "Records/airrecords.t", get
if file = 0 then
    put "Error with file 'airrecords.txt', check for errors "
else
    loop
        exit when eof (file)
        new arrayitems, 500 % max of 500 ppl in list
        cnt := cnt + 1
        get : file, part : *
        GUI.AddLine (textBox, part)
        GUI.AddLine (textboxchoice, part)
        arrayitems (cnt) := part
    end loop
    GUI.SetText (textboxTextField, list)
    GUI.Hide (textboxTextField)
end if
close : file
%Creates the 1st menu
first := GUI.CreateMenu ("File")
item (1) := GUI.CreateMenuItem (name (1), Open)
item (2) := GUI.CreateMenuItem (name (2), saveas)
item (3) := GUI.CreateMenuItem (name (3), MenuSelected)
item (4) := GUI.CreateMenuItem (name (4), Quit)
%Creates the 2nd menu
second := GUI.CreateMenu ("Edit")
item (5) := GUI.CreateMenuItem (name (5), addP)
item (6) := GUI.CreateMenuItem (name (6), remP)
%Exiting loop
loop
    exit when GUI.ProcessEvent
end loop
Sponsor
Sponsor
Sponsor
sponsor
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 1 Posts ]
Jump to:   


Style:  
Search: