Sign in to follow this  
Followers 0
codename44

How can i return multiple var ?

5 posts in this topic

Hi

I would like to know if you had a trick to return multiple var with a function ?

This would help me a lot

Is it posible to make something like a procedure in C ?

Thanks ! :)

Share this post


Link to post
Share on other sites



Return an array. There are no procedures in C, so I will assume you mean functions. Yes, you can create functions in AutoIt.

Syntax for creating a function:

Func ASDF()
Msgbox(0,"ASDF","The ASDF function was called.")
Return 1
EndFunc

- The Kandie Man ;-)


"So man has sown the wind and reaped the world. Perhaps in the next few hours there will no remembrance of the past and no hope for the future that might have been." & _"All the works of man will be consumed in the great fire after which he was created." & _"And if there is a future for man, insensitive as he is, proud and defiant in his pursuit of power, let him resolve to live it lovingly, for he knows well how to do so." & _"Then he may say once more, 'Truly the light is sweet, and what a pleasant thing it is for the eyes to see the sun.'" - The Day the Earth Caught Fire

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Maybe....

$var = ListWindows()

For $i = 1 To $var[0][0]
    ; Only display visble windows that have a title
    If $var[$i][0] <> "" And IsVisible($var[$i][1]) Then
        MsgBox(0, "Details", "Title=" & $var[$i][0] & @LF & "Handle=" & $var[$i][1])
    EndIf
Next


Func ListWindows()
    Return WinList()
EndFunc   ;==>ListWindows

Func IsVisible($handle)
    If BitAND(WinGetState($handle), 2) Then
        Return 1
    Else
        Return 0
    EndIf

EndFunc   ;==>IsVisible

8)

EDIT: used Tidy

Edited by Valuater

NEWHeader1.png

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

an array, yes, good idea !

thanks for tip !

Valuater sorry, i don't understand what your script does

maybe procedure isn't the good word :

how would you call this :

void print_result(int var) {

printf("%d", var);
...

}

=> this is what I was talking about

and this :

int get_var () {

int var;
scanf("%d", &var);
return (var);

}
Edited by codename44

Share this post


Link to post
Share on other sites

...

maybe procedure isn't the good word :

how would you call this :

void print_result(int var) {
           
           printf("%d", var);
           ...
           
           }

=> this is what I was talking about

and this :

int get_var () {
           
           int var;
           scanf("%d", &var);
           return (var);
           
           }
Those are functions. Like I said above, you meant functions. The first function doesn't return anything and that is elaborated by the fact that it returns a void aka nothing. The second one returns an integer.

Here are some rough translations:

print_result(get_var())


Func print_result($iVar)
    ConsoleWrite($iVar & @LF)
EndFunc

Func get_var()
    Local $iVar
    $iVar = Int(InputBox("Input Integer","Please input the integer:"))
    Return $iVar
EndFunc

- The Kandie Man ;-)


"So man has sown the wind and reaped the world. Perhaps in the next few hours there will no remembrance of the past and no hope for the future that might have been." & _"All the works of man will be consumed in the great fire after which he was created." & _"And if there is a future for man, insensitive as he is, proud and defiant in his pursuit of power, let him resolve to live it lovingly, for he knows well how to do so." & _"Then he may say once more, 'Truly the light is sweet, and what a pleasant thing it is for the eyes to see the sun.'" - The Day the Earth Caught Fire

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