Jump to content

Recommended Posts

Posted

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 ;;; WinXP

Can anyone guide me in the right direction here?

And to those of you who wasn't figured it out - I'm no programmer...!!! :D

..t.k.

[font="Geneva"]..t.k.[/font]
Posted

Uhh...? What's wrong with that? You do realize MsgBox is a function right? So you are already calling a function in a function.

Posted

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.

Posted

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.

Posted

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.

Posted

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]
Posted (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....!! :D

..t.k.

Edited by ..t.k.
[font="Geneva"]..t.k.[/font]

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...