Sign in to follow this  
Followers 0
0xdefea7

The "Not" Keyword

5 posts in this topic

Instead of hijacking the other topic any further, I decided to create a new topic for the discussion of the "Not" operator. 

Here is the previous topic for reference:

'?do=embed' frameborder='0' data-embedContent>>

How is it that this works perfectly (tested and part of one of my toolsets that hundreds of techs use daily):

$Authentication = InetGetSize("http://wouldntyouliketoknow.com/DeleteThisNow.txt")

If Not $Authentication = 0 Then
    MsgBox(16, "ERROR", "The license for this product has expired.", 5)
    Self_Destruct()
    Exit
EndIf

As we can see, there are no parenthesis there, but it still functions as I expected. This also works as expected, but I feel that the 2 contradict each other:

#include <Constants.au3>

Local $vVar = 'SomeTest'
; This expression before Then is Not True, as $vVar = 'SomeTest' evaluates to True, hence Not True.
If Not ($vVar = 'SomeTest1') Then MsgBox($MB_SYSTEMMODAL, '1', 'This MsgBox won''t display, as $vVar = SomeTest.')
; AutoIt looks at this as (Not $vVar) = 'SomeTest'.
If Not $vVar = 'SomeTest1' Then MsgBox($MB_SYSTEMMODAL, '2', 'This MsgBox won''t display, as $vVar = SomeTest.')

In this second example, the MsgBox with title '2' does not launch, proving that parenthesis are a necessary part of the statement. My question is: What it is about my first example script that makes it work differently than the second example by FireFox?

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

#include <Constants.au3>

Local $iAuth = 1 ;or any number different from 0

;$iAuth = 0 : False
;Not (False) / Not ($iAuth = 0) : True
If Not $iAuth = 0 Then ;equals to If Not ($iAuth = 0) Then ;this is more easily evaluable
    MsgBox($MB_SYSTEMMODAL, "1", "This MsgBox will display")
EndIf

Local $sVar = "SomeTest"

;$sVar = "SomeTest1" : False
;Not (False) / Not ($sVar = "SomeTest1") : True
If Not ($sVar = "SomeTest1") Then MsgBox($MB_SYSTEMMODAL, "2", "This MsgBox will display")

;Not $sVar : False (because the string is not empty so $sVar is like True in boolean)
;(False) = "SomeTest1" / (Not $sVar) = "SomeTest1" : False
If Not $sVar = "SomeTest1" Then MsgBox($MB_SYSTEMMODAL, "3", "This MsgBox won't display")
All clear? :) Edited by FireFox

 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites

I thought it was pretty clear in the previous thread?!


_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 04/09/2015

Share this post


Link to post
Share on other sites

 

I thought it was pretty clear in the previous thread?!

 

This is more clear than the other thread, but I understand where you are coming from. Thank you both for the help :)

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

No problem. Thanks for FireFox for providing examples that demonstrated what I was saying.

Edit: Now off to test v3.3.9.10. Bye!

Edited by guinness

_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 04/09/2015

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

  • Similar Content

    • ZeroByDevide
      By ZeroByDevide
      so right now i have a small project and i wanted to print this text out every second.
      i have made a random number for the sleep function. but when i want to print out with the while loop it just doesn't work.
      Run("notepad.exe") Sleep(1000) Local $rndSleep = Int (Random(180000,240000,1000)) While $rndSleep <> 0 $rndSleep - 1 If Mod ( $rndSleep, 1000 ) == 0 Then Send("This note will show the sleeptime before closing the tabs, you got " & $rndSleep & " seconds left.") EndIf WEnd plis halp me 
    • TheFixer
      By TheFixer
      Basically i am trying to make a script that detects if the currently active window is 1920 x 1080 or bigger. If it detects a window that is active, that is indeed that size. It will do some stuff. 
      The problem i am having is that it is detecting my desktop whenever i click on my desktop, so it's doing stuff when i don't want it to.

      So all i need to know, is how can i do a simple check to see if a window = a title.

      Here is what i have so far
      $wintitledesktop = WinGetTitle("[ACTIVE]") If not $wintitledesktop = "Program Manager" Then ;does stuff endif Program Manager is what my desktop is called btw. 

      The problem with that code is that the script is still detecting the desktop and doing the code.
       
      In case you need the whole section of the code, here it is.

       
      $winsizecheck1 = WinGetClientSize("[ACTIVE]") $wintitledesktop = WinGetTitle("[ACTIVE]") If WinActive("[ACTIVE]") Then sleep(100) If $winsizecheck1[0] >= 1920 Then If $winsizecheck1[1] >= 1080 Then If not $wintitledesktop = "Program Manager" Then $gamesfolderstate = WinGetState($gamesfolder) If WinExists($gamesfolder) Then If Not BitAND($gamesfolderstate, 16) Then WinSetState($gamesfolder,"",@SW_MINIMIZE) EndIf EndIf EndIf EndIf EndIf EndIf  
    • guinness
      By guinness
      Don't you just love it when a regular expression comes out on top?! I know I do..
      Local $hTimer = 0 $hTimer = TimerInit() For $i = 1 To 10000 _IsSystemDrive_Test_1('C') Next ConsoleWrite(TimerDiff($hTimer) & @CRLF) $hTimer = TimerInit() For $i = 1 To 10000 _IsSystemDrive_Test_2('C') Next ConsoleWrite(TimerDiff($hTimer) & @CRLF) Func _IsSystemDrive_Test_1($sDrive) Local $aArray = [@HomeDrive, _ @ProgramFilesDir, _ @SystemDir, _ @WindowsDir] For $sFilePath In $aArray If StringLeft($sFilePath, 1) = $sDrive Then Return True EndIf Next Return False EndFunc ;==>_IsSystemDrive Func _IsSystemDrive_Test_2($sDrive) Return StringRegExp(@HomeDrive & '|' & @ProgramFilesDir & '|' & @SystemDir & '|' & @WindowsDir, '(?<=^|\|)(?:' & $sDrive & ')') = 1 EndFunc ;==>_IsSystemDrive I am no expert at regular expressions, but what I have managed to learn has proved very useful over the last couple of years.
    • guestscripter
      By guestscripter
      I´m getting mixed up!
      What´s the difference between:
      While NOT Func1() AND Func2()   and
      While NOT Func1() AND NOT Func2() ??
       
      I´m using lots of these and it works find,
      but now that I´m rewriting my script I´m mixing things up and getting unsure.