Sign in to follow this  
Followers 0
dirty

Need help to change variable.

7 posts in this topic

#1 ·  Posted (edited)

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <SecondFile.au3>
$Form1 = GUICreate("",200,100)
$checkbox = GUICtrlCreateCheckbox ("Text",0,40)
$button = GUICtrlCreateButton ("Button",0,60)

$Variable = ?

GUISetState(@SW_SHOW)

While 1
   $nMsg = GUIGetMsg()
   Switch $nMsg
       Case $GUI_EVENT_CLOSE
           Exit
       Case $button
           button()
   EndSwitch
WEnd

Func button()
    $GetCheckBox = GUICtrlRead ($checkbox)
    If $GetCheckBox = 1 Then
    MsgBox (64,"","Box was checked")
    ElseIf $GetCheckBox = 4 Then
    MsgBox (64,"","Box not checked")
    EndIf
    EndFunc

Hi guys !

I run into this problem many times and i have yet discovered how this suppose to work.

What i am trying to accomplish is:

When box is checked i need script to change value of $variable.

For example code made from 2 script files.

1st Main script with GUI and all variables and second with function displayed above.

Functon controlreads the value of checkbox, and if its checked then somehow i need to set the value of previously created $Variable = ?

Ho do i go about changing this variable value so i can refer this variable in other parts of code and those located on separate script files ?

It other words here is what i need to accomplish.

RunWait(@ComSpec & ' /c xcopy ' & $variable & ' ' & '"Src dir" "Dest dir"')

where $variable value depends on checkbox checked or not

$variable would be xcopy switch such as /D/E/Y/H etc. I just need overwrite or other xcopy switches optional.

in advance...........

Thanks a ton for help

Edited by dirty

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

I tried

$variable = ''
Func button()
    $GetCheckBox = GUICtrlRead ($checkbox)
    If $GetCheckBox = 1 Then
        Assign ($variable, '/Y')
    MsgBox (64,"","Box was checked")
    ElseIf $GetCheckBox = 4 Then
    MsgBox (64,"","Box not checked")
EndIf

RunWait(@ComSpec & ' /k xcopy ' & $variable & ' "test.txt" "C:\"')

but its not working. it keeps asking of overwrite or not when instead it should just overwrite due to checkbox being checked before button pressed. :(

can you guys give me a clue to what am i doing wrong ? :mellow:

$variable = ''
Assign ($variable, "1st assign")
MsgBox (0,'',$variable)
Assign ($variable, "2d assign")
MsgBox (0,'',$variable)
is not working and i have no clue why.. Edited by dirty

Share this post


Link to post
Share on other sites

Setting aside the matter of bumping your own post in 30 minutes time :mellow: ....

Why are you using Assign???

What do you think the following line would accomplish?

$variable = "/Y"

???


SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script

wannabe "Unbeatable" Tic-Tac-Toe

Paper-Scissor-Rock ... try to beat it anyway :)

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

if assign would work the way i expect, /Y would overwrite target.

/Y is xcopy switch for overwrite

Anyway my mistake was that i thought:

Global $variable
Assign ("$variable", "1st assign")
MsgBox (0,'',$variable)
Assign ("$variable", "2d assign")
MsgBox (0,'',$variable)

Instead it was

Global $variable
Assign ("variable", "1st assign")
MsgBox (0,'',$variable)
Assign ("variable", "2d assign")
MsgBox (0,'',$variable)

thats why i was confused :(

Thought having $variable would target the variable, instead i had to have variable name only :lol: lol

too bad i forgot xcopy prompts for action if switch /Y not present thus making the script useless caz its just gonna freeze with xcopy stuck running in background so i decided not to add this feature to my script, instead make it overwrite all and have /D as optional to overwrite only older data :P

God damn it, i wish autoit had all those options, half of xcopy related posts would not exist then :mellow:

And what does "Setting aside the matter of bumping your own post in 30 minutes time" means ?

Edited by dirty

Share this post


Link to post
Share on other sites

No offense but you have absolutely no idea what you're talking about.

It would be better for you to follow BrettF advice.

Post bumping??

Posted Today, 10:45 AM

Posted Today, 11:12 AM

I can't see any other posts in-between.

SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script

wannabe "Unbeatable" Tic-Tac-Toe

Paper-Scissor-Rock ... try to beat it anyway :)

Share this post


Link to post
Share on other sites

I can't see any other posts in-between.

Oh that ? Well that was just additional information i wanted to add before someone replies instead of editing already posted one in case someone read it and typing response :mellow:

Sorry i didnt know i cant do that.

Anyway problem solved.

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