Sign in to follow this  
Followers 0
JATO

Return codes -- Function returns ?

5 posts in this topic

The Help file talks alot about the function or command RETURNING either a specific name OR a 0 (zero)

How do I see what a function/command returned?

Say I use ProcessExist ("somename")

According to the Help File..

Return Value

Success: Returns the PID of the process.

Failure: Returns 0 if process does not exist.

How do I view this or check it? -- that's the part I can't find in the Help file.

Do I have to assign a variable to the command and then reference the variable, such as

$Var = ProcessExist ("somename")
MsgBox (0, "test", "$Var")

I've used NSIS installer and the Return value is stored in a stack as $0 or $1 -- so you can do a message box display $0 to view the result


~J. Schutzmanwww.alchemistgamer.com

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Do I have to assign a variable to the command and then reference the variable, such as

CODE

$Var = ProcessExist ("somename")

MsgBox (0, "test", "$Var")

yes

also...

functions can "return" 0 or specific names too

8)

Edited by Valuater

NEWHeader1.png

Share this post


Link to post
Share on other sites

Right here is a function from one of my scripts, it gets the dir size of a folder. The return value is either the file count $aSize[1] or -1 for failure (i.e the Dir does not exist)

To get the information from the function I would use $DirSize = GetCount("C:\MyFolder")

When the function is ran it will set the Var $DirSize to either the file count or -1

Func GetCount($Dir)

If FileExists($Dir) Then

$aSize = DirGetSize($Dir, 1)

Return $aSize[1]

Else

Return -1

EndIf

EndFunc

Share this post


Link to post
Share on other sites

good example chris... i couldn't think of a small exaple like that

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

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
Sign in to follow this  
Followers 0