..t.k. Posted May 6, 2004 Posted May 6, 2004 Hi,I'd like to know how to put a function within a function - or any other method of doing this...!I'm trying to make a script compatible for both WinXP and W2k.The reason they differ, is because of a registry setting depending on the OS version.So what I'd like to do is this:If @OSVersion = 'WIN_2000' then _Win2k() elseif @OSVersion = 'WIN_XP' then _Win_XP() endif FUNC _Win2k() msgbox (0, "", "Win2k" ) ;instead of msgbox, Several other functions goes here! Endfunc ;;; Win2k FUNC _Win_XP() msgbox (0, "", "WinXP" ) ;instead of msgbox, Several other functions goes here! EndFunc ;;; WinXPCan anyone guide me in the right direction here?And to those of you who wasn't figured it out - I'm no programmer...!!! ..t.k. [font="Geneva"]..t.k.[/font]
Valik Posted May 6, 2004 Posted May 6, 2004 Uhh...? What's wrong with that? You do realize MsgBox is a function right? So you are already calling a function in a function.
SlimShady Posted May 6, 2004 Posted May 6, 2004 You don't have to put a function in a function.If you create the 2nd function elsewhere and call it from the 1st(like the msgbox function), it will work fine.
scriptkitty Posted May 6, 2004 Posted May 6, 2004 Aye, more examples of func in a func. If @OSVersion = 'WIN_2000' then _Win2k() elseif @OSVersion = 'WIN_XP' then _Win_XP() endif FUNC _Win2k() tip() msgbox (0, "", "Win2k" );instead of msgbox, Several other functions goes here! Endfunc;;; Win2k FUNC _Win_XP() tip() msgbox (0, "", "WinXP" );instead of msgbox, Several other functions goes here! EndFunc;;; WinXP func tip() tooltip("Please click the OK button",@desktopwidth/2-60,@desktopheight/2-60) endfunc AutoIt3, the MACGYVER Pocket Knife for computers.
pekster Posted May 6, 2004 Posted May 6, 2004 The only thing you can't do is define a function within another function. Outside of this limitation you can craete as many user defined functions as you need, and use them in any script where they are defined. [font="Optima"]"Standing in the rain, twisted and insane, we are holding onto nothing.Feeling every breath, holding no regrets, we're still looking out for something."[/font]Note: my projects are off-line until I can spend more time to make them compatable with syntax changes.
..t.k. Posted May 7, 2004 Author Posted May 7, 2004 Thanks, pek!I realize I've explained my problem a bit poorly.Define a function within another function is excactly what I tried to do.Anyway, when that's not possible - what do I do to get around that??..t.k. [font="Geneva"]..t.k.[/font]
..t.k. Posted May 7, 2004 Author Posted May 7, 2004 (edited) Whoops!Didn't read scriptKitty and SlimShady's answers thoroughly enough.Sorry, I'll stop nagging you for now and do some more testing.Then I'll nag you some more after that....!! ..t.k. Edited May 7, 2004 by ..t.k. [font="Geneva"]..t.k.[/font]
..t.k. Posted May 7, 2004 Author Posted May 7, 2004 Thanks to all of you!I've got it working now!! ..t.k. [font="Geneva"]..t.k.[/font]
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