Sign in to follow this  
Followers 0
Jeremy76

Variable issues

4 posts in this topic

Ok So what I am trying to do is depending on what radio button is selected and they click on a button I want to get data from a specific imput

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <GUIbutton.au3>
Global $Form1_1, $Adjustment, $Button1, $Button2, $Case, $CCB, $CNM, $DPCS, $DPPL, $DPPM, $Webm
Global $Input1, $Input2, $Input3, $Input4, $Input5, $Input6, $Input7, $Input8, $Input9, $imput
Global $jccb, $tracs, $ucms, $Radio1, $Radio2, $Radio3, $radio

$Form1_1 = GUICreate("Form1", 365, 360, 188, 114)
$Input1 = GUICtrlCreateInput("", 32, 24, 177, 21)  ; Provider Name
$Input2 = GUICtrlCreateInput("", 32, 64, 177, 21)  ; SSN
$Input3 = GUICtrlCreateInput("", 32, 104, 177, 21) ; Phoneautoit for command
$Input4 = GUICtrlCreateInput("", 32, 152, 177, 21) ; Street Add
$Input5 = GUICtrlCreateInput("", 32, 176, 68, 21)  ; City
$Input6 = GUICtrlCreateInput("", 104, 176, 30, 21) ; State
$Input7 = GUICtrlCreateInput("", 144, 176, 60, 21) ; Zip
$Input8 = GUICtrlCreateInput("", 32, 224, 177, 21) ; Provider No
$Input9 = GUICtrlCreateInput("", 32, 272, 177, 21) ; Case No
$Name = GUICtrlCreateLabel("Prov_No", 32, 208, 50, 17)
$SSN = GUICtrlCreateLabel("SSN", 40, 48, 26, 17)
$Case = GUICtrlCreateLabel("Phone", 40, 92, 36, 17)
$Provider = GUICtrlCreateLabel("Provider_Name", 24, 8, 99, 17)
$Address = GUICtrlCreateLabel("Address", 32, 136, 56, 17)
$Webm = GUICtrlCreateButton("Webm", 216, 8, 65, 25, $WS_GROUP)
$DPPM = GUICtrlCreateButton("DPPM", 216, 40, 65, 25, $WS_GROUP)
$CCB = GUICtrlCreateButton("CCB", 216, 136, 65, 25, $WS_GROUP)
$DPCS = GUICtrlCreateButton("DPCS", 216, 104, 65, 25, $WS_GROUP)
$JCCB = GUICtrlCreateButton("JCCB", 216, 168, 65, 25, $WS_GROUP)
$DPPL = GUICtrlCreateButton("DPPL", 216, 72, 65, 25, $WS_GROUP)
$Adjustment = GUICtrlCreateButton("Adjustment", 288, 8, 65, 25, $WS_GROUP)
$CNM = GUICtrlCreateButton("CNM", 288, 42, 65, 25, $WS_GROUP)
$Tracs = GUICtrlCreateButton("Tracs", 288, 76, 65, 25, $WS_GROUP)
$UCMS = GUICtrlCreateButton("UCMS", 288, 110, 65, 25, $WS_GROUP)
$Button2 = GUICtrlCreateButton("Button2", 288, 144, 65, 25, $WS_GROUP)
$Label1 = GUICtrlCreateLabel("Case_No", 40, 256, 48, 17)
$Radio1 = GUICtrlCreateRadio("Radio1", 8, 24, 17, 17) ; Name
$Radio2 = GUICtrlCreateRadio("Radio1", 8, 66, 17, 17) ; SSN
$Radio3 = GUICtrlCreateRadio("Radio1", 8, 107, 17, 17) ; Phone
$Radio4 = GUICtrlCreateRadio("Radio1", 8, 157, 17, 17) ; address
$Radio5 = GUICtrlCreateRadio("Radio1", 8, 222, 17, 17) ; prov no
$Radio6 = GUICtrlCreateRadio("Radio1", 8, 272, 17, 17) ; case no
GUISetState(@SW_SHOW)


While 1

    $nMsg = GUIGetMsg()
    Select
        Case $nMsg = $GUI_EVENT_CLOSE
            Exit
        case $nMsg = $Webm
            for $r = 1 To 5
                IF GUICtrlGetState($Radio[r]) Then
                    WinActivate("GUITEST.wps - Microsoft Works Word Processor")
                    send ("Webm Find "& guictrlread($Input[r])& "{enter}")
                endif
            next
        case $nMsg = $DPPM
                IF GUICtrlGetState($Radio1) Then
                    WinActivate("GUITEST.wps - Microsoft Works Word Processor")
                    send ("DPPM,"& guictrlread($input1)& "{enter}")
                EndIf
        case $nMsg = $DPPL
                WinActivate("GUITEST.wps - Microsoft Works Word Processor")
                send ("DPPL,"& guictrlread($input1)& "{enter}")
        Case $nMsg = $UCMS
                WinActivate("GUITEST.wps - Microsoft Works Word Processor")
                send ("DPPL,"& guictrlread($input1)& "{enter}")
    EndSelect
WEnd

I can get it to work the long way but I thought there might be a clean way to do it.

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Try this:

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <GUIButton.au3>

Global Const $Form1_1 = GUICreate("Form1", 365, 360, 188, 114)

Global Const $Input[9] = [ _
        GUICtrlCreateInput('', 32 , 24 , 177, 21)               , _ ; Provider Name
        GUICtrlCreateInput('', 32 , 64 , 177, 21, $ES_NUMBER)   , _ ; SSN
        GUICtrlCreateInput('', 32 , 104, 177, 21)               , _ ; Phoneautoit for command
        GUICtrlCreateInput('', 32 , 144, 177, 21)               , _ ; Street Add
        GUICtrlCreateInput('', 32 , 168, 110, 21)               , _ ; City
        GUICtrlCreateInput('', 145, 168, 22 , 21, $ES_UPPERCASE), _ ; State
        GUICtrlCreateInput('', 170, 168, 38 , 21, $ES_NUMBER)   , _ ; Zip
        GUICtrlCreateInput('', 32 , 208, 177, 21, $ES_NUMBER)   , _ ; Provider No
        GUICtrlCreateInput('', 32 , 248, 177, 21, $ES_NUMBER)]      ; Case No

GUICtrlSetLimit($Input[1], 9)  ; SSN cannot be more than nine characters
GUICtrlSetLimit($Input[2], 14) ; Phone cannot be more than fourteen characters (accommodates spaces, dashes, and parenthesis)
GUICtrlSetLimit($Input[5], 2)  ; State cannot be more than two capital letters
GUICtrlSetLimit($Input[6], 5)  ; Zip cannot be more than five digits

Global Const $Radio[6] = [ _
        GUICtrlCreateRadio('', 8, 24 , 17, 17), _ ; Name
        GUICtrlCreateRadio('', 8, 64 , 17, 17), _ ; SSN
        GUICtrlCreateRadio('', 8, 104, 17, 17), _ ; Phone
        GUICtrlCreateRadio('', 8, 157, 17, 17), _ ; address
        GUICtrlCreateRadio('', 8, 208, 17, 17), _ ; prov no
        GUICtrlCreateRadio('', 8, 248, 17, 17)]   ; case no

Global Const $Prov_Name = GUICtrlCreateLabel("Provider_Name", 33, 10 , 73, 11)
Global Const $SSN       = GUICtrlCreateLabel("SSN"          , 33, 50 , 21, 11)
Global Const $Phone     = GUICtrlCreateLabel("Phone"        , 33, 90 , 30, 11)
Global Const $Address   = GUICtrlCreateLabel("Address"      , 33, 130, 37, 11)
Global Const $Prov_No   = GUICtrlCreateLabel("Prov_No"      , 33, 194, 41, 11)
Global Const $Case_No   = GUICtrlCreateLabel("Case_No"      , 33, 234, 43, 11)

Global Const $Webm      = GUICtrlCreateButton("Webm"    , 216, 32 , 65, 25, $WS_GROUP)
Global Const $DPPM      = GUICtrlCreateButton("DPPM"    , 216, 64 , 65, 25, $WS_GROUP)
Global Const $DPPL      = GUICtrlCreateButton("DPPL"    , 216, 96 , 65, 25, $WS_GROUP)
Global Const $DPCS      = GUICtrlCreateButton("DPCS"    , 216, 128, 65, 25, $WS_GROUP)
Global Const $CCB       = GUICtrlCreateButton("CCB"     , 216, 160, 65, 25, $WS_GROUP)
Global Const $JCCB      = GUICtrlCreateButton("JCCB"    , 216, 196, 65, 25, $WS_GROUP)
Global Const $Adjustment = GUICtrlCreateButton("Adjustment", 288, 32 , 65, 25, $WS_GROUP)
Global Const $CNM       = GUICtrlCreateButton("CNM"     , 288, 64 , 65, 25, $WS_GROUP)
Global Const $Tracs     = GUICtrlCreateButton("Tracs"   , 288, 96 , 65, 25, $WS_GROUP)
Global Const $UCMS      = GUICtrlCreateButton("UCMS"    , 288, 128, 65, 25, $WS_GROUP)
Global Const $Button2   = GUICtrlCreateButton("Button2"   , 288, 160, 65, 25, $WS_GROUP)

GUISetState(@SW_SHOW)

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Webm
            For $r = 0 To 4
                If GUICtrlGetState($Radio[$r]) Then
                    WinActivate("GUITEST.wps - Microsoft Works Word Processor")
                    Send("Webm Find " & GUICtrlRead($Input[$r]) & "{enter}")
                EndIf
            Next
        Case $DPPM
            If GUICtrlGetState($Radio[0]) Then
                WinActivate("GUITEST.wps - Microsoft Works Word Processor")
                Send("DPPM," & GUICtrlRead($Input[0]) & "{enter}")
            EndIf
        Case $DPPL
            WinActivate("GUITEST.wps - Microsoft Works Word Processor")
            Send("DPPL," & GUICtrlRead($Input[0]) & "{enter}")
        Case $UCMS
            WinActivate("GUITEST.wps - Microsoft Works Word Processor")
            Send("DPPL," & GUICtrlRead($Input[0]) & "{enter}")
    EndSwitch
WEnd

This should take you closer to where you want to go.

Edited by LaCastiglione

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Firstly, in your code you need to use the "r" variable correctly. ("IF GUICtrlGetState($Radio[$r])", not "IF GUICtrlGetState($Radio[r])").

Secondly, if you want to use an expression to read variable information you need to use Eval():

for $r = 1 To 5
                IF GUICtrlGetState($Radio[$r]) Then
                    WinActivate("GUITEST.wps - Microsoft Works Word Processor")
                    send ("Webm Find "& guictrlread(Eval("Input" & $r))& "{enter}")
                endif
            next
Edited by Mallie99

Are you telling me something I need to know or something I want to know?

Share this post


Link to post
Share on other sites

Thank you soo much that got me in the right direction.

I ended up needing guictrlread so it would only print off the one line but thanks again.

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