Jump to content
Sign in to follow this  
JohnOne

@ScriptName [Solved]

Recommended Posts

JohnOne

I observed some odd behaviour, and just wondering why this happens? and if Im doing something wrong.

If @ScriptName = "Test.au3" Then
    ConsoleWrite(@ScriptName & @CRLF) ;writes "Test.au3"
EndIf

If Not @ScriptName = "Tess.au3" Then
    ConsoleWrite("Wrong" & @CRLF) ;does not write "wrong"
EndIf

I also tried

$sName = @ScriptName
If $sName = "Test.au3" Then
    ConsoleWrite(@ScriptName & @CRLF) ;writes "Test.au3"
EndIf

If Not $sName = "Tess.au3" Then
    ConsoleWrite("Wrong" & @CRLF) ;does not write "wrong"
EndIf

With the same result

EDIT: sorry, I guess "Not" only works with boolean type. :idea:

Edited by JohnOne

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Share this post


Link to post
Share on other sites
water

Try this one :idea:

If @ScriptName = "Test.au3" Then
    ConsoleWrite(@ScriptName & @CRLF) ;writes "Test.au3"
EndIf

If Not (@ScriptName = "Tess.au3") Then
    ConsoleWrite("Wrong" & @CRLF) ;does not write "wrong"
EndIf

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2018-09-01 - Version 1.3.4.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
notsure

too late :idea:

Share this post


Link to post
Share on other sites
water

Glad to be of service!


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2018-09-01 - Version 1.3.4.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
MvGulik
whatever Edited by MvGulik

"Straight_and_Crooked_Thinking" : A "classic guide to ferreting out untruths, half-truths, and other distortions of facts in political and social discussions."
"The Secrets of Quantum Physics" : New and excellent 2 part documentary on Quantum Physics by Jim Al-Khalili. (Dec 2014)

"Believing what you know ain't so" ...

Knock Knock ...
 

Share this post


Link to post
Share on other sites
JohnOne

Nope. Not a bad point of view. But "Not $a=$b" => "(Not $a)=$b"

Now Im a little more confused, I came to the conclusion that autoit internally converts the value to boolean type if it is not already of that type.

The following confirmed it (for me anyway)

$100 = 100
$text ="text"
$not100 = (Not $100)
$Nottext = (Not $text)

ConsoleWrite($not100 & @CRLF & $Nottext & @CRLF)

Output

False

False

Edited by JohnOne

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Share this post


Link to post
Share on other sites
MvGulik
whatever Edited by MvGulik

"Straight_and_Crooked_Thinking" : A "classic guide to ferreting out untruths, half-truths, and other distortions of facts in political and social discussions."
"The Secrets of Quantum Physics" : New and excellent 2 part documentary on Quantum Physics by Jim Al-Khalili. (Dec 2014)

"Believing what you know ain't so" ...

Knock Knock ...
 

Share this post


Link to post
Share on other sites
ShawnW

autoit DOES convert to a boolean value but the problem was the order of operations.

If Not @ScriptName = "Tess.au3" Then

is the same as

If (Not @ScriptName) = "Tess.au3" Then

because the Not applies 1st. Since the @ScriptName is a string that when converted to Boolean is True (any non-zero or non-empty string is True)

This basically evaluated to

If Not True = "Tess.au3" Then

then

If Not True = True Then

in other words

If False = True Then

When you change the order of operations by saying

If Not (@ScriptName = "Tess.au3") Then

the strings are compared first. Since they are false the operation becomes

If Not (False) Then

which of course is

If True Then
Edited by ShawnW

Share this post


Link to post
Share on other sites
MvGulik
whatever Edited by MvGulik

"Straight_and_Crooked_Thinking" : A "classic guide to ferreting out untruths, half-truths, and other distortions of facts in political and social discussions."
"The Secrets of Quantum Physics" : New and excellent 2 part documentary on Quantum Physics by Jim Al-Khalili. (Dec 2014)

"Believing what you know ain't so" ...

Knock Knock ...
 

Share this post


Link to post
Share on other sites
notsure

autoit DOES convert to a boolean value but the problem was the order of operations.

Great post!

Edited by notsure

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  

×