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

Username:   Password: 
 RegisterRegister   
 Problem with Text fields
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
yasser_986




PostPosted: Sun Mar 28, 2004 7:43 pm   Post subject: Problem with Text fields

Hi....i have a problem...
im making a program using GUI...i created a text field...and i want to use what i typed in it in my program using if statments for example like if the number entered = 1 a statement will appear on the screen and says this is the first number and so...
i used the GUI.GetText But it didn't work wit me.. here is the code that i have till now:

import GUI
View.Set("graphics:500;500")



var agetextfield : int

procedure getage1

var age : int
if agetextfield = 12 then
put "You have to pay 3 $"
end if
end getage1

procedure getage (dummy: string )
getage1
end getage

agetextfield:= GUI.CreateTextFieldFull (15, 20, 50, "",getage, GUI.INDENT, 0, 0)
var d1:int := GUI.CreateLabelFull (15, 20+ GUI.GetHeight(agetextfield), "Age", 50, 0,GUI.CENTER, 0)

loop
exit when GUI.ProcessEvent
end loop


And thankz..
Sponsor
Sponsor
Sponsor
sponsor
sport




PostPosted: Sun Mar 28, 2004 9:16 pm   Post subject: GUI

Here is a sample of what you should have.
You have to exit GUI to have the entered data from the field

code:
% The "GUI.CreateTextFieldFull" program
import GUI
View.Set ("graphics:200;100,nobuttonbar")

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) ..
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  [ 2 Posts ]
Jump to:   


Style:  
Search: