Vindicator209 Posted June 25, 2007 Share Posted June 25, 2007 Ehh, My attempt at making a switch UDF, however, it can't tell the script that its up (or down), I'm guessing the UDF doesnt apply its own variables to the script?All help appreciated =PUDF:Func _SwitchButton($swFolder,$swLeft,$swTop,$swWidth,$swHeight,$swDefault) If $swDefault = 0 Then $SwitchUp = GUICtrlCreatePic($swFolder & "\Up.bmp",$swLeft,$swTop,$swWidth,$swHeight) ElseIf $swDefault = 1 $SwitchDown = GUICtrlCreatePic($swFolder & "\Down.bmp",$swLeft,$swTop,$swWidth,$swHeight) EndIf While 1 $msg = GUIGetMsg() If $msg = $SwitchUp Then GUICtrlDelete($SwitchUp) $SwitchDown = GUICtrlCreatePic($swFolder & "\Down.bmp",$swLeft,$swTop,$swWidth,$swHeight) EndIf If $msg = $SwitchDown Then GUICtrlDelete($SwitchDown) $SwitchUp = GUICtrlCreatePic($swFolder & "\Up.bmp",$swLeft,$swTop,$swWidth,$swHeight) EndIf WEndEndFuncMy Test Script:#include <Switches.au3>#include <GuiConstants.au3>GuiCreate("MyGUI", 392, 316,-1, -1 , BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS))$Button_1 = _SwitchButton("Switch\ButtonSwitch", 10, 10, 140, 40,0)GuiSetState()While 1 $msg = GuiGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case Else ;;; EndSelectWEndExit [center]"When you look at old, classic games like Snake, you often put it off because it's such a simple game, but it's only when you actually try and create your own unique game from scratch, do you finally appreciate those games."[/center][center]Don't ask for answers if you haven't TRIED yet![/center][center]Most answers can be answered in the help file! Use it![/center] Link to comment Share on other sites More sharing options...
Vindicator209 Posted June 25, 2007 Author Share Posted June 25, 2007 ..Nope? [center]"When you look at old, classic games like Snake, you often put it off because it's such a simple game, but it's only when you actually try and create your own unique game from scratch, do you finally appreciate those games."[/center][center]Don't ask for answers if you haven't TRIED yet![/center][center]Most answers can be answered in the help file! Use it![/center] Link to comment Share on other sites More sharing options...
PsaltyDS Posted June 25, 2007 Share Posted June 25, 2007 ..Nope?I don't get it... Which variable are you talking about? The $swDefault variable tells the function up or down. The variables in the function are all Local, are you looking for a Global flag of some kind...? Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
poisonkiller Posted June 25, 2007 Share Posted June 25, 2007 Are you looking for #include "Switches.au3", I don't really understand what your question is. Link to comment Share on other sites More sharing options...
Vindicator209 Posted June 25, 2007 Author Share Posted June 25, 2007 (edited) My Bad.... Ok, there are two variables I need, $SwitchUp and $SwitchDown, I put it in a while loop like a GUI, so it would act just like it would in the main script, but when testing it, the script says it doesn't exist XD Scratch that, I just realized you can't make a control object on the main script from the include... so how do I work around this? Edited June 25, 2007 by MethodZero [center]"When you look at old, classic games like Snake, you often put it off because it's such a simple game, but it's only when you actually try and create your own unique game from scratch, do you finally appreciate those games."[/center][center]Don't ask for answers if you haven't TRIED yet![/center][center]Most answers can be answered in the help file! Use it![/center] Link to comment Share on other sites More sharing options...
PsaltyDS Posted June 25, 2007 Share Posted June 25, 2007 (edited) Ok, there are two variables I need, $SwitchUp and $SwitchDown, I put it in a while loop like a GUI, so it would act just like it would in the main script, but when testing it, the script says it doesn't exist XDScratch that, I just realized you can't make a control object on the main script from the include... so how do I work around this?$SwitchUp and $SwitchDown are Local unless you declared them Global somewhere else. They should work fine inside the Func, but won't be available outside it.I think you've gone down a bad road putting your GUI loop inside the function, it can work, but is unnecessarily complicated and hard to maintain. Why bother with putting that in a UDF, and then having another GUI loop in the main script? Edited June 25, 2007 by PsaltyDS Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
DW1 Posted June 25, 2007 Share Posted June 25, 2007 I agree with the penguin. Keep your gui in your program, but you should know how to declare a $var as global. AutoIt3 Online Help Link to comment Share on other sites More sharing options...
Vindicator209 Posted June 25, 2007 Author Share Posted June 25, 2007 yep, thanks! I'll see what I can do >.> Perhaps not much.... [center]"When you look at old, classic games like Snake, you often put it off because it's such a simple game, but it's only when you actually try and create your own unique game from scratch, do you finally appreciate those games."[/center][center]Don't ask for answers if you haven't TRIED yet![/center][center]Most answers can be answered in the help file! Use it![/center] Link to comment Share on other sites More sharing options...
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