Sign in to follow this  
Followers 0
AutoScrub

Changing Var from Input after Button Press

8 posts in this topic

I'm loosing my mind, hopefully someone can help me out. Basically I have a tab open with an input box where you can type a name in and then it goes ahead and checks that name against a library for info. I have the input box set with a name when it launches, so it queries that info and that single instance works. What does not work is me being able to query any other instance.

 

$Tab_Tracker = GUICtrlCreateTabItem("Tracker")

        Global $I_SN = GUICtrlCreateInput("TestName", 16, 48, 169, 21)
        $Label11 = GUICtrlCreateLabel("Name: ", 16, 80, 186, 25)
        $Label12 = GUICtrlCreateLabel("Level: ", 16, 112, 186, 25)
        $Label13 = GUICtrlCreateLabel("Id: ", 16, 144, 186, 25)
        $Label14 = GUICtrlCreateLabel("Elo: ", 16, 176, 186, 25)
        $Label15 = GUICtrlCreateLabel("Label15", 16, 208, 186, 25)
        $B_S_LU = GUICtrlCreateButton("Query", 200, 48, 75, 25)
        $UserName = GUICtrlRead($I_SN)

Func Query()

        $I_SN = GUICtrlCreateInput
        $UserName = GUICtrlRead($I_SN)

EndFunc

I can't figure out how I can get the input variable to change in the code once I press the button and have all my labels (WHICH ARE BASED OF OFF THE VAR) to change. Please help Obi-Wan Kenobi.

Share this post


Link to post
Share on other sites



You keep recreating the Input (in the Query() func), using GUICtrlRead right after before anything can be typed in it.

Remove the Query() $I_SN = GUICtrlCreateInput


Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites

So I would have GUICtrlRead($I_SN, 0), which would read it but you said to add it in the querry and then you said to remove querry, which is it, cause neither seems to work.

Share this post


Link to post
Share on other sites

right after before 

I feel like your trolling me so hard.

Share this post


Link to post
Share on other sites

AutoScrub,

Moderators here are not in the habit of trolling newcomers. :naughty:

We prefer welcoming them to the forum - so consider yourself welcome. :)

SmOke_N's comment was absolutely correct - in the Query() function you are reassigning the $I_SN by (incorrectly and with bad syntax) reusing GUICtrlCreateInput so that the original ControlID set when creating the "TestName" input is lost. That means that your GUICtrlRead does not use the correct value for the original input and so fails to read its content. Take a look at this example script:

#include <GUIConstantsEx.au3>

$hGUI = GUICreate("Test", 500, 500)

Global $I_SN = GUICtrlCreateInput("TestName", 16, 48, 169, 21)

$Label11 = GUICtrlCreateLabel("Name: ", 16, 80, 186, 25)
$Label12 = GUICtrlCreateLabel("Level: ", 16, 112, 186, 25)
$Label13 = GUICtrlCreateLabel("Id: ", 16, 144, 186, 25)
$Label14 = GUICtrlCreateLabel("Elo: ", 16, 176, 186, 25)
$Label15 = GUICtrlCreateLabel("Label15", 16, 208, 186, 25)

$B_S_LU = GUICtrlCreateButton("Query", 200, 48, 75, 25)

GUISetState()

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $B_S_LU
            _Query()
    EndSwitch
WEnd

Func _Query()
    ; Read username
    $UserName = GUICtrlRead($I_SN)
    If $UserName Then
        ; Change label
        GUICtrlSetData($Label11, "Name: " & $UserName)
    EndIf
EndFunc   ;==>_Query
Please ask if yo have any questions. :)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

Thank's alot! That helped understand it much better and I was able to resolve the issue using the While and Func example you gave.

Share this post


Link to post
Share on other sites

AutoScrub,

Glad I could help. :)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

Guess I forgot a comma separating the two.  I'm not in the habit of recreating code that doesn't run out of the box to demonstrate the issue.  Certainly not looking to "troll" anyone, regardless of their status on the forum.  Glad things worked out for you, as it seems, the original code you posted (able to be ran on our side or not) did not really demonstrate the extent of the issue based on your reply to Melba23.


Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

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