
-----------------------------------
eLegant
Sun Sep 17, 2006 5:49 pm

GUI Help
-----------------------------------
Hi all, I'm new to the forums.  :) 

Anyways,  I'm having problems with the GUI in my program. Here's the code.. 

Note: It does compile, but when i try to enter text into the text field, it crashes.


var winID:int:= Window.Open("position:middle;center,graphics:700;400")

var msgTxtField:int
var OutputTxtBox:int:= GUI.CreateTextBoxFull (2, 25, 518, 350, GUI.INDENT, 0)

procedure MsgEntered(text:string)
    GUI.AddLine(OutputTxtBox, GUI.GetText(msgTxtField))
end MsgEntered

var UserTxtBox:int:= GUI.CreateTextBoxFull (528, 25, 170, 350, GUI.INDENT, 0)
msgTxtField:=GUI.CreateTextFieldFull (2, 3, 696, "", MsgEntered, GUI.INDENT, 0, 0)

loop
    exit when GUI.ProcessEvent
end loop


What I want to create is a GUI with a text field along the bottom of the window and two text boxes (one for output, the other for a userlist).

All help is appreciated. Thanks in advance.

-----------------------------------
eLegant
Sun Sep 17, 2006 6:02 pm


-----------------------------------
Sorry for the double post, but I can't find the Edit button and I'm in a hurry.

The code I posted WILL NOT compile on it's own. For more advanced members who may have noticed, it needs..


import GUI


.. at the tiop of it in order to compile. Thanks again guys.

-----------------------------------
Tony
Sun Sep 17, 2006 6:22 pm


-----------------------------------
I think you have a wrong function declaration there

procedure MsgEntered(text:string) 

but you never pass text to it, you just call it as MsgEntered().

which is fine, since you never use that argument as well. Just drop the text:string part

-----------------------------------
eLegant
Sun Sep 17, 2006 6:37 pm


-----------------------------------
Thanks Tony, but that didn't work. I'd like to mention that code you mentioned is actually from the reference section of Turing. When I take out the part 'text:string', i get 'Argument is the wrong type'.

Here's the reference code..


        import GUI in "%oot/lib/GUI" 
        View.Set ("graphics:200;100") 
        
        var nameTextField, addressTextField : int   % The Text Field IDs.
        
        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
        
        GUI.SetBackgroundColor (gray)
        var quitButton := GUI.CreateButton (52, 5, 100, "Quit", GUI.Quit)
        nameTextField := GUI.CreateTextFieldFull (50, 70, 100, "", 
            NameEntered, GUI.INDENT, 0, 0)
        addressTextField := GUI.CreateTextFieldFull (50, 40, 100, "", 
            AddressEntered, GUI.INDENT, 0, 0)
        var nameLabel := GUI.CreateLabelFull (45, 70, "Name", 0, 0, 
            GUI.RIGHT, 0)
        var addressLabel := GUI.CreateLabelFull (45, 40, "Address", 0, 0, 
            GUI.RIGHT, 0)
        loop
            exit when GUI.ProcessEvent
        end loop
        
        GUI.Dispose (quitButton)
        colorback (gray)
        Text.Locate (maxrow  1, 1)
        put "Name = ", GUI.GetText (nameTextField)
        put "Address = ", GUI.GetText (addressTextField) ..


-----------------------------------
Clayton
Sun Sep 17, 2006 6:53 pm


-----------------------------------
first of all, welcome to CompSci!

now, as you might already of noticed, Turing's GUI really sucks, so why not make your own?!

You can find the tutorial that will give you the ability on how to, along with some sample code to build from, just go [url=http://compsci.ca/v2/viewtopic.php?t=10904]here!

Good Luck!

-----------------------------------
eLegant
Sun Sep 17, 2006 7:10 pm


-----------------------------------
Hey, Freakman. Yeah.. Turing, to me, is one of the ugliest languages I've ever had to deal with (I come from a C# background), so I wasn't that surprised to find that the GUI sucked. To be honest, I half expected NOT to find any way of being able to interact with the internet (thank God for Turing's limited support of TCP/IP).

Anyways, that tutorial you linked to was on Classes. Was that what you intended to link to or was there something else you wanted to show me?

-----------------------------------
Clayton
Sun Sep 17, 2006 7:41 pm


-----------------------------------
yes that link was the one i was intending to link to, if you read through it, you will find all you need to be well on your way to creating a GUI class, and there is sample code for a button class (start of a GUI) at the bottom in an attachment
