Sign in to follow this  
Followers 0
magaf

problem with IsDeclared

9 posts in this topic

i think thats the problem...

the error i get is "Incorrect number of parameters in function call"

the code is:

if IsDeclared ( Eval ($x[$x[0]])) = 0 then Assign ( $x[$x[0]]), "a")

Share this post


Link to post
Share on other sites



if IsDeclared ( Eval ($x[$x[0]])) = 0 then Assign ( $x[$x[0]]), "a")

should be...

if IsDeclared ( Eval ($x[$x[0]])) = 0 then Assign ( $x[$x[0]], "a")

Share this post


Link to post
Share on other sites

... thanks i missed that

Share this post


Link to post
Share on other sites

after

if IsDeclared ( Eval ($x[$x[0]])) = 0 then Assign ( $x[$x[0]], "a")

i call a function and i want it to take the variable i made there so i use

Eval ($x[$x[0]])

as the parameter i send and in the function i take it ByRef when i did that it gave me an error:

"Expected a variable in user function call."

why is that? there should be a variable already...

Share this post


Link to post
Share on other sites

IsDeclared requires the NAME of the variable to be quoted in the function:

$x = 4
msgbox(0, "", IsDeclared("x")

Notice no $x in the function, but instead just x in quotes. For your particular problem, therefore, it will not work because you have an array.


Who else would I be?

Share this post


Link to post
Share on other sites

so on autoit as of now its impossible?

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

after

if IsDeclared ( Eval ($x[$x[0]])) = 0 then Assign ( $x[$x[0]], "a")

i call a function and i want it to take the variable i made there so i use

Eval ($x[$x[0]])

as the parameter i send and in the function i take it ByRef when i did that it gave me an error:

"Expected a variable in user function call."

why is that? there should be a variable already...

<{POST_SNAPBACK}>

What did you call the variable?

You have to use a real variable in the header of the function.

Example:

Func TestFunc($a, $b)
If $a <> "" AND $b <> "" Then
  ;Do stuff
EndIf
EndFunc

I don't understand exactly how ByRef works, so I can't help you with that.

Edited by SlimShady

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

... me too i dont know what byref can change in the fact that it worked before i putted it on byref

and i did use it like in your example...

Edited by magaf

Share this post


Link to post
Share on other sites

ive had to use another way less efficient way to make my program work

but still from what ive seen, with autoit its impossible to use a variable as an array's name...

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