Sign in to follow this  
Followers 0
OminousIdol

GUIRead()

6 posts in this topic

Well I tired to read from a Input box from the GUI! Every time I have a Mesage box display the value in the Input Box i get a 4 instead of what was in their! I even try the example they give for GUIRead() I get a 4 too??? Whats?

My Code

;Create GUI
GUICreate("Game", 800, 600, 0, 0)

;Create Buttons
GUISetControl("button", "New", 10, 50, 80, 30)
GUISetControl("button", "Load", 10, 85, 80, 30)
GUISetControl("button", "Save", 10, 120, 80, 30)

;Show GUI
GUIShow()
GUIWaitClose()

;New Function
If GUIRead("New") Then
   Call("cChara")
Else
   GUIShow()
   GUIWaitClose()
EndIf

;Function Create Character
Func cChara()
;Create Character Creation GUI
   GuiCreate("Create Character", 800, 600, 0, 0)

;Create Text Boxes
GUISetControl("input", "Name", 10, 10, 150, 25)
GUISetControl("button", "Save", 10, 50, 80, 30)
;Create Save Function
GUIShow()
GUIWaitClose()

If GUIRead("Save") Then
   
MsgBox(0, "test", GUIRead("Name"))

EndIf
EndFunc

Have no clue whats going on so if somone could tell me how to read from a Input Box from the GUI that would be great!

Thanks

OminousIdol

Share this post


Link to post
Share on other sites



$NameInput = GUISetControl("input", "Name", 10, 10, 150, 25)

...

GuiRead($Name)

Try something more like this

red

Share this post


Link to post
Share on other sites

Variable used without being declared! Thats what I keep getting where are you getting $Name from anways? From the input text box but never declared that? I dont know what I am doing wrong but still does not work :ph34r: !

Thanks

OminousIdol

Share this post


Link to post
Share on other sites

It should be

$NameInput = GUISetControl("input", "Name", 10, 10, 150, 25)

...

GuiRead($NameInput)

Share this post


Link to post
Share on other sites

GuiSetControl() returns a reference to the control. This reference must be used in calls like GuiRead() or GuiWrite() (Anywhere that you see controlref, in fact). You need to create a global variable (So that it will be in scope across functions). Store the control reference as returned by GuiSetControl() in that variable, then use that variable whenever you want to access the contents of that control.

Share this post


Link to post
Share on other sites

Thanks slimshady for correcting my bad code :ph34r:

red

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0