dirty Posted February 17, 2010 Posted February 17, 2010 (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 February 17, 2010 by dirty
dirty Posted February 17, 2010 Author Posted February 17, 2010 (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 ? $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 February 17, 2010 by dirty
enaiman Posted February 17, 2010 Posted February 17, 2010 Setting aside the matter of bumping your own post in 30 minutes time .... 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 :)
BrettF Posted February 17, 2010 Posted February 17, 2010 Please check out section 4 of my tutorial (in my sig.) While you're at it check the rest of it out too. Cheers. Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version!
dirty Posted February 17, 2010 Author Posted February 17, 2010 (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 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 God damn it, i wish autoit had all those options, half of xcopy related posts would not exist then And what does "Setting aside the matter of bumping your own post in 30 minutes time" means ? Edited February 17, 2010 by dirty
enaiman Posted February 17, 2010 Posted February 17, 2010 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 AMPosted Today, 11:12 AMI 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 :)
dirty Posted February 17, 2010 Author Posted February 17, 2010 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 Sorry i didnt know i cant do that.Anyway problem solved.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now