Jump to content

@ScriptName [Solved]


Recommended Posts

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.

Link to comment
Share on other sites

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 (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Glad to be of service!

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

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 ...
 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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 ...
 

Link to comment
Share on other sites

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

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 ...
 

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...