avery Posted August 20, 2008 Share Posted August 20, 2008 (edited) I downloaded my first UDF! Yay me... I put the UDF in its own file and had to remove a bunch of '\' that gave me warnings/errors on 'Go'. It worked!! My background changed to the one I made, woooot! I've now moved the function call to the UDF cut-n-paste job I did into my .au3 file. For some reason it doesn't work now Please help! ; Desktop wallpaper changer vars Global $pic = "DoD-SECRET.bmp"; (S) Pic Global $style = 0; 0=center, 1=stretched, 2=tiled Global $warn = 1; warnings 0=off, 1=on ; I also tried Const here as well as Global Const (if that is even possible). ...Click a button that calls -> create_dod_inf() Func create_dod_inf() ....my stuff here.... _setwallpaper($pic, $style, $warn) EndFunc Func _setwallpaper($pic, $style, $warn) ....UDF stuff here.... EndFunc Edited August 20, 2008 by avery www.abox.orgAvery HowellVisit My AutoIt Websitehttp://www.abox.org Link to comment Share on other sites More sharing options...
LarryDalooza Posted August 20, 2008 Share Posted August 20, 2008 it doesn't work nowIs this the exact error message you get?Lar. AutoIt has helped make me wealthy Link to comment Share on other sites More sharing options...
avery Posted August 20, 2008 Author Share Posted August 20, 2008 Is this the exact error message you get?Lar.I get no error at all and nothing changes. I have $warn = 1 on the UDF but I see no difference when toggled. It all worked fine until I put it in my script. Any chance I can screw up the scope of the variables? Can you tell I have no idea what I'm talking about yet? www.abox.orgAvery HowellVisit My AutoIt Websitehttp://www.abox.org Link to comment Share on other sites More sharing options...
PsaltyDS Posted August 20, 2008 Share Posted August 20, 2008 (edited) Your problem is reusing the variable names of the Globals as input variables to the function _setwallpaper(). Input variables to a function are automatically declared local to that function, and therefore do not contain the data passed from the Globals.NVM, calling _setwallpaper() from within create_dod_inf() does in fact pass the Global values into the local variables. Note however that changes made inside that function will only happen to the Locals, not the Globals. Global $pic = "DoD-SECRET.bmp" Global $style = 0 Global $warn = 1 create_dod_inf() Func create_dod_inf() _setwallpaper($pic, $style, $warn) EndFunc Func _setwallpaper($pic, $style, $warn) MsgBox(64, "Inputs", "$pic = " & $pic & @CRLF & _ "$style = " & $style & @CRLF & _ "$warn = " & $warn) EndFunc Edited August 20, 2008 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...
avery Posted August 20, 2008 Author Share Posted August 20, 2008 Your problem is reusing the variable names of the Globals as input variables to the function _setwallpaper(). Input variables to a function are automatically declared local to that function, and therefore do not contain the data passed from the Globals. NVM, calling _setwallpaper() from within create_dod_inf() does in fact pass the Global values into the local variables. Note however that changes made inside that function will only happen to the Locals, not the Globals. Global $pic = "DoD-SECRET.bmp" Global $style = 0 Global $warn = 1 create_dod_inf() Func create_dod_inf() _setwallpaper($pic, $style, $warn) EndFunc Func _setwallpaper($pic, $style, $warn) MsgBox(64, "Inputs", "$pic = " & $pic & @CRLF & _ "$style = " & $style & @CRLF & _ "$warn = " & $warn) EndFunc Interesting, thanks. It worked now. And I updated my version of au3 (oops) www.abox.orgAvery HowellVisit My AutoIt Websitehttp://www.abox.org 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