Jump to content

Need explanation about inline assignment.


jacQues
 Share

Recommended Posts

Someone explain to me what inline assignments are allowed and what are not allowed?

These two examples DO NOT work the same. The first one works as expected half the time and the second one never triggers a MsgBox().

CONST $dll = @ScriptDir&"\Au3zip.dll"

LOCAL $plh[3]

IF FileExists($dll) AND ($plh[1] = PluginOpen($dll))=0 THEN

MsgBox(0,"test","Plugin good...")

PluginClose($plh[1])

ENDIF

LOCAL $plh

IF FileExists($dll) AND ($plh = PluginOpen($dll))=0 THEN

MsgBox(0,"test","Plugin good...")

PluginClose($plh)

ENDIF

Edited by jacQues
Link to comment
Share on other sites

I cannot understand how your conditions are ok when PluginOpen returns a handle, else returns 0 (as undocumented). I could be wrong but I do not consider that you will see the msgbox upon success.

Edit:

removed 2 words which created a bad sentence.

Edited by MHz
Link to comment
Share on other sites

I cannot understand how your conditions are ok when PluginOpen returns a handle, else returns 0 (as undocumented). I could be wrong but I do not consider that you will see the msgbox upon success.

ZipPlugin documentation states to check for <>0 and =0 is the opposite. But that isn't my question, its just a random example.

Another example:

IF ($pos = StringInStr("1234567890",$str)) THEN

MsgBox(0,"found","Position: "&$pos)

ENDIF

Above example doesn't work. But some other inline assignments *do* work. My question is what rules apply for inline assignments in AutoIt.

Link to comment
Share on other sites

The rule is that there's no such thing as inline assignment.

In all your examples above, no assignment takes place, just case insensitive compare.

For example,

Global $x = 0
ConsoleWrite(($x = 0) & @CRLF)
ConsoleWrite(($x = 13) & @CRLF)
ConsoleWrite($x & @CRLF)

produces output

True
False
0

"be smart, drink your wine"

Link to comment
Share on other sites

The rule is that there's no such thing as inline assignment.

I agree.

Also, how can a return value from a function be used as a condition as a so called inline assignment?

Global $value

If $value = _test() Then
    ConsoleWrite('success' & @CRLF)
EndIf

Func _test()
    Return 1
EndFunc

That does not work as you need to declare $value first and how can you evaluate $value to the return of _Test() before the return value is known?

Link to comment
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
 Share

  • Recently Browsing   0 members

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