Sign in to follow this  
Followers 0
DXRW4E

Assignment operators ???

35 posts in this topic

#1 ·  Posted (edited)

What does this mean ??, it happens only if $sString = 0

#cs ----------------------------------------------------------------------------

 AutoIt Version: 3.3.12.0
 Author:         myName

 Script Function:
    Template AutoIt script.

#ce ----------------------------------------------------------------------------

; Script Start - Add your code below here
Local $sString = 0
If $sString = @UserName Then
    MsgBox(0, 0, True)
Else
    MsgBox(0, 0, False)
EndIf
Ciao. Edited by DXRW4E

apps-odrive.pngdrive_app_badge.png box-logo.png new_logo.png MEGA_Logo.png

Share this post


Link to post
Share on other sites



DXRW4E,

You assign an integer value to a variable - AutoIt thinks you want to store this as an integer and so it types $sString as Int32 (use VarGetType to check). Then when you compare using the "=" operator, AutoIt sees an integer datatype on one side and converts @UserName to an integer as well - which of course resolves as 0 (unless you happen to have leading numbers in your user name). Hence 0=0 and you get True as a response. :)

If you want to compare the 2 elements as strings, use the "==" operator which will force both sides to string datatype. ;)

All clear? :)

M23

1 person likes this

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Hi Melba23, I understand, you're right

Thanks

Ciao.

Edited by DXRW4E

apps-odrive.pngdrive_app_badge.png box-logo.png new_logo.png MEGA_Logo.png

Share this post


Link to post
Share on other sites

DXRW4E,

Glad I could help. :)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

... Then when you compare using the "=" operator, AutoIt sees an integer datatype on one side and converts @UserName to an integer as well - which of course resolves as 0 (unless you happen to have leading numbers in your user name).

Does this seem as counter intuitive to anyone else or is it just me?

Share this post


Link to post
Share on other sites

Not really.


_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

#7 ·  Posted (edited)

Does this seem as counter intuitive to anyone else or is it just me?

 

It's not just you. It seems counter-intuitive to me too. It's not clear to me what the advantage is. I always thought strings evaluated to TRUE or 1, unless they are empty. DXRW4E it's a comparison operator, not an assignment operator. Is it behaving differently than before? I'm a bit tired right now: I'll test it in the morning.

Edited by czardas

Share this post


Link to post
Share on other sites

czardas, not under the terms of a mathematical comparison. You want to compare string with string, fine. You want to compare number with number, fine. You want to mix types in comparisons, then a set of conditions apply.

In a typed language, comparing a string to a integer would cause a fatal error. You should think yourself lucky that AutoIt does not do the same.

If you want the ability to choose, then cast the type in the comparison.

Global $sString = 0

If String($sString) = @UserName Then
    MsgBox(0, 0, True)
Else
    MsgBox(0, 0, False)
EndIf

The code above is not case sensitive in comparison as to what == forces so it is probably what DXRW4E expects with the result. == is usually good for checking for empty string or case sensitivity with strings.

Global $sString = 0

If $sString == '' Then
    MsgBox(0, 0, True)
Else
    MsgBox(0, 0, False)
EndIf

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

Thanks MHz, I tried comparing False to @UserName, 0 to @UserName, and False to 0. Funny set of results - I've tried something like this previously with similar results. I often think of a string as being True, and True being equivalent to 1 - hence the counter-intuitive nature of this. I would like to know which data types take precedence when these comparisons are made, and if there is a link where I can read about the pecking order.

In a typed language, comparing a string to a integer would cause a fatal error.

 

This seems most logical.

Edited by czardas

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

It makes sense Is logic ehhh, but I do not seen it because i was very tired ehh, the truth is that i was writing a long code since the morning, and it took me 20-30 minutes to understand what was going on, because i did not expect that the problem could be there eh, anyway i just used the "String($sString)" to not lose the case insensitive, how do you know there are a lot of ways to do this such as the StringCompare or the RegExp that i always use, however to chronicle here is a piece of code

 

#include <array.au3>

If Not IsDeclared("arDllCall") Then Global Static $arDllCall

Global Const $hKernel32DLL = DllOpen("Kernel32.dll")
Global Const $hAdvapi32Dll = DllOpen("AdvApi32.dll")

;;
;; Well known SID definitions for lookup.
;;
Global Enum _ ;; $WELL_KNOWN_SID_TYPE
    $WinNullSid                                    = 0, _    ;; Indicates a null SID.
    $WinWorldSid                                   = 1, _    ;; "WD" - $SDDL_EVERYONE - Indicates a SID that matches everyone.
    $WinLocalSid                                   = 2, _    ;; Indicates a local SID.
    $WinCreatorOwnerSid                            = 3, _    ;; "CO" - $SDDL_CREATOR_OWNER - Indicates a SID that matches the owner or creator of an object.
    $WinCreatorGroupSid                            = 4, _    ;; "CG" - $SDDL_CREATOR_GROUP - Indicates a SID that matches the creator group of an object.
    $WinCreatorOwnerServerSid                      = 5, _    ;; Indicates a creator owner server SID.
    $WinCreatorGroupServerSid                      = 6, _    ;; Indicates a creator group server SID.
    $WinNtAuthoritySid                             = 7, _    ;; Indicates a SID for the Windows NT authority account.
    $WinDialupSid                                  = 8, _    ;; Indicates a SID for a dial-up account.
    $WinNetworkSid                                 = 9, _    ;; "NU" - $SDDL_NETWORK - Indicates a SID for a network account. This SID is added to the process of a token when it logs on across a network. The corresponding logon type is LOGON32_LOGON_NETWORK.
    $WinBatchSid                                   = 10, _   ;; Indicates a SID for a batch process. This SID is added to the process of a token when it logs on as a batch job. The corresponding logon type is LOGON32_LOGON_BATCH.
    $WinInteractiveSid                             = 11, _   ;; "IU" - $SDDL_INTERACTIVE - Indicates a SID for an interactive account. This SID is added to the process of a token when it logs on interactively. The corresponding logon type is LOGON32_LOGON_INTERACTIVE.
    $WinServiceSid                                 = 12, _   ;; "SU" - $SDDL_SERVICE - Indicates a SID for a service. This SID is added to the process of a token when it logs on as a service. The corresponding logon type is LOGON32_LOGON_SERVICE.
    $WinAnonymousSid                               = 13, _   ;; "AN" - $SDDL_ANONYMOUS - Indicates a SID for the anonymous account.
    $WinProxySid                                   = 14, _   ;; Indicates a proxy SID.
    $WinEnterpriseControllersSid                   = 15, _   ;; "ED" - $SDDL_ENTERPRISE_DOMAIN_CONTROLLERS - Indicates a SID for an enterprise controller.
    $WinSelfSid                                    = 16, _   ;; "PS" - $SDDL_PERSONAL_SELF - Indicates a SID for self.
    $WinAuthenticatedUserSid                       = 17, _   ;; "AU" - $SDDL_AUTHENTICATED_USERS - Indicates a SID that matches any authenticated user.
    $WinRestrictedCodeSid                          = 18, _   ;; "RC" - $SDDL_RESTRICTED_CODE - Indicates a SID for restricted code.
    $WinTerminalServerSid                          = 19, _   ;; Indicates a SID that matches a terminal server account.
    $WinRemoteLogonIdSid                           = 20, _   ;; Indicates a SID that matches remote logons.
    $WinLogonIdsSid                                = 21, _   ;; Indicates a SID that matches logon IDs.
    $WinLocalSystemSid                             = 22, _   ;; "SY" - $SDDL_LOCAL_SYSTEM - Indicates a SID that matches the local system.
    $WinLocalServiceSid                            = 23, _   ;; "LS" - $SDDL_LOCAL_SERVICE - Indicates a SID that matches a local service.
    $WinNetworkServiceSid                          = 24, _   ;; "NS" - $SDDL_NETWORK_SERVICE - Indicates a SID that matches a network service.
    $WinBuiltinDomainSid                           = 25, _   ;; Indicates a SID that matches the domain account.
    $WinBuiltinAdministratorsSid                   = 26, _   ;; "BA" - $SDDL_BUILTIN_ADMINISTRATORS - Indicates a SID that matches the administrator group.
    $WinBuiltinUsersSid                            = 27, _   ;; "BU" - $SDDL_BUILTIN_USERS - Indicates a SID that matches built-in user accounts.
    $WinBuiltinGuestsSid                           = 28, _   ;; "BG" - $SDDL_BUILTIN_GUESTS - Indicates a SID that matches the guest account.
    $WinBuiltinPowerUsersSid                       = 29, _   ;; "PU" - $SDDL_POWER_USERS - Indicates a SID that matches the power users group.
    $WinBuiltinAccountOperatorsSid                 = 30, _   ;; "AO" - $SDDL_ACCOUNT_OPERATORS - Indicates a SID that matches the account operators account.
    $WinBuiltinSystemOperatorsSid                  = 31, _   ;; "SO" - $SDDL_SERVER_OPERATORS - Indicates a SID that matches the system operators group.
    $WinBuiltinPrintOperatorsSid                   = 32, _   ;; "PO" - $SDDL_PRINTER_OPERATORS - Indicates a SID that matches the print operators group.
    $WinBuiltinBackupOperatorsSid                  = 33, _   ;; "BO" - $SDDL_BACKUP_OPERATORS - Indicates a SID that matches the backup operators group.
    $WinBuiltinReplicatorSid                       = 34, _   ;; "RE" - $SDDL_REPLICATOR - Indicates a SID that matches the replicator account.
    $WinBuiltinPreWindows2000CompatibleAccessSid   = 35, _   ;; "RU" - $SDDL_ALIAS_PREW2KCOMPACC - Indicates a SID that matches pre-Windows 2000 compatible accounts.
    $WinBuiltinRemoteDesktopUsersSid               = 36, _   ;; "RD" - $SDDL_REMOTE_DESKTOP - Indicates a SID that matches remote desktop users.
    $WinBuiltinNetworkConfigurationOperatorsSid    = 37, _   ;; "NO" - $SDDL_NETWORK_CONFIGURATION_OPS - Indicates a SID that matches the network operators group.
    $WinAccountAdministratorSid                    = 38, _   ;; Indicates a SID that matches the account administrator's account.
    $WinAccountGuestSid                            = 39, _   ;; Indicates a SID that matches the account guest group.
    $WinAccountKrbtgtSid                           = 40, _   ;; Indicates a SID that matches account Kerberos target group.
    $WinAccountDomainAdminsSid                     = 41, _   ;; Indicates a SID that matches the account domain administrator group.
    $WinAccountDomainUsersSid                      = 42, _   ;; Indicates a SID that matches the account domain users group.
    $WinAccountDomainGuestsSid                     = 43, _   ;; Indicates a SID that matches the account domain guests group.
    $WinAccountComputersSid                        = 44, _   ;; Indicates a SID that matches the account computer group.
    $WinAccountControllersSid                      = 45, _   ;; Indicates a SID that matches the account controller group.
    $WinAccountCertAdminsSid                       = 46, _   ;; Indicates a SID that matches the certificate administrators group.
    $WinAccountSchemaAdminsSid                     = 47, _   ;; Indicates a SID that matches the schema administrators group.
    $WinAccountEnterpriseAdminsSid                 = 48, _   ;; Indicates a SID that matches the enterprise administrators group.
    $WinAccountPolicyAdminsSid                     = 49, _   ;; Indicates a SID that matches the policy administrators group.
    $WinAccountRasAndIasServersSid                 = 50, _   ;; Indicates a SID that matches the RAS and IAS server account.
    $WinNTLMAuthenticationSid                      = 51, _   ;; Indicates a SID present when the Microsoft NTLM authentication package authenticated the client.
    $WinDigestAuthenticationSid                    = 52, _   ;; Indicates a SID present when the Microsoft Digest authentication package authenticated the client.
    $WinSChannelAuthenticationSid                  = 53, _   ;; Indicates a SID present when the Secure Channel (SSL/TLS) authentication package authenticated the client.
    $WinThisOrganizationSid                        = 54, _   ;; Indicates a SID present when the user authenticated from within the forest or across a trust that does not have the selective authentication option enabled. If this SID is present, then WinOtherOrganizationSid cannot be present.
    $WinOtherOrganizationSid                       = 55, _   ;; Indicates a SID present when the user authenticated across a forest with the selective authentication option enabled. If this SID is present, then WinThisOrganizationSid cannot be present.
    $WinBuiltinIncomingForestTrustBuildersSid      = 56, _   ;; Indicates a SID that allows a user to create incoming forest trusts. It is added to the token of users who are a member of the Incoming Forest Trust Builders built-in group in the root domain of the forest.
    $WinBuiltinPerfMonitoringUsersSid              = 57, _   ;; "MU" - $SDDL_PERFMON_USERS - Indicates a SID that matches the performance monitor user group.
    $WinBuiltinPerfLoggingUsersSid                 = 58, _   ;; "LU" - $SDDL_PERFLOG_USERS - Indicates a SID that matches the performance log user group.
    $WinBuiltinAuthorizationAccessSid              = 59, _   ;; Indicates a SID that matches the Windows Authorization Access group.
    $WinBuiltinTerminalServerLicenseServersSid     = 60, _   ;; Indicates a SID is present in a server that can issue terminal server licenses.
    $WinBuiltinDCOMUsersSid                        = 61, _   ;; Indicates a SID that matches the distributed COM user group.
    $WinBuiltinIUsersSid                           = 62, _   ;; "IS" - $SDDL_IIS_USERS - Indicates a SID that matches the Internet built-in user group.
    $WinIUserSid                                   = 63, _   ;; Indicates a SID that matches the Internet user group.
    $WinBuiltinCryptoOperatorsSid                  = 64, _   ;; "CY" - $SDDL_CRYPTO_OPERATORS - Indicates a SID that allows a user to use cryptographic operations. It is added to the token of users who are a member of the CryptoOperators built-in group.
    $WinUntrustedLabelSid                          = 65, _   ;; Indicates a SID that matches an untrusted label.
    $WinLowLabelSid                                = 66, _   ;; "LW" - $SDDL_ML_LOW - Indicates a SID that matches an low level of trust label.
    $WinMediumLabelSid                             = 67, _   ;; "ME" - $SDDL_ML_MEDIUM - Indicates a SID that matches an medium level of trust label.
    $WinHighLabelSid                               = 68, _   ;; "HI" - $SDDL_ML_HIGH - Indicates a SID that matches a high level of trust label.
    $WinSystemLabelSid                             = 69, _   ;; "SI" - $SDDL_ML_SYSTEM - Indicates a SID that matches a system label.
    $WinWriteRestrictedCodeSid                     = 70, _   ;; "WR" - $SDDL_WRITE_RESTRICTED_CODE - Indicates a SID that matches a write restricted code group.
    $WinCreatorOwnerRightsSid                      = 71, _   ;; "OW" - $SDDL_OWNER_RIGHTS - Indicates a SID that matches a creator and owner rights group.
    $WinCacheablePrincipalsGroupSid                = 72, _   ;; Indicates a SID that matches a cacheable principals group.
    $WinNonCacheablePrincipalsGroupSid             = 73, _   ;; Indicates a SID that matches a non-cacheable principals group.
    $WinEnterpriseReadonlyControllersSid           = 74, _   ;; Indicates a SID that matches an enterprise wide read-only controllers group.
    $WinAccountReadonlyControllersSid              = 75, _   ;; Indicates a SID that matches an account read-only controllers group.
    $WinBuiltinEventLogReadersGroup                = 76, _   ;; "ER" - $SDDL_EVENT_LOG_READERS - Indicates a SID that matches an event log readers group.
    $WinNewEnterpriseReadonlyControllersSid        = 77, _   ;; Indicates a SID that matches a read-only enterprise domain controller.
    $WinBuiltinCertSvcDComAccessGroup              = 78      ;; "CD" - $SDDL_CERTSVC_DCOM_ACCESS - Indicates a SID that matches the built-in DCOM certification services access group.
Global Enum _ ;; $WELL_KNOWN_SID_TYPE - Windows Server 2008 R2, Windows 7, Windows Server 2008, Windows Vista, Windows Server 2003, and Windows XP:  This value is not available.
    $WinMediumPlusLabelSid                         = 79, _   ;; "MP" - $SDDL_ML_MEDIUM_PLUS - Indicates a SID that matches the medium plus integrity label.
    $WinLocalLogonSid                              = 80, _   ;; Indicates a SID that matches a local logon group.
    $WinConsoleLogonSid                            = 81, _   ;; Indicates a SID that matches a console logon group.
    $WinThisOrganizationCertificateSid             = 82, _   ;; Indicates a SID that matches a certificate for the given organization.
    $WinApplicationPackageAuthoritySid             = 83, _   ;; Indicates a SID that matches the application package authority.
    $WinBuiltinAnyPackageSid                       = 84, _   ;; "AC" - $SDDL_ALL_APP_PACKAGES - Indicates a SID that applies to all app containers.
    $WinCapabilityInternetClientSid                = 85, _   ;; Indicates a SID of Internet client capability for app containers.
    $WinCapabilityInternetClientServerSid          = 86, _   ;; Indicates a SID of Internet client and server capability for app containers.
    $WinCapabilityPrivateNetworkClientServerSid    = 87, _   ;; Indicates a SID of private network client and server capability for app containers.
    $WinCapabilityPicturesLibrarySid               = 88, _   ;; Indicates a SID for pictures library capability for app containers.
    $WinCapabilityVideosLibrarySid                 = 89, _   ;; Indicates a SID for videos library capability for app containers.
    $WinCapabilityMusicLibrarySid                  = 90, _   ;; Indicates a SID for music library capability for app containers.
    $WinCapabilityDocumentsLibrarySid              = 91, _   ;; Indicates a SID for documents library capability for app containers.
    $WinCapabilitySharedUserCertificatesSid        = 92, _   ;; Indicates a SID for shared user certificates capability for app containers.
    $WinCapabilityEnterpriseAuthenticationSid      = 93, _   ;; Indicates a SID for Windows credentials capability for app containers.
    $WinCapabilityRemovableStorageSid              = 94, _   ;; Indicates a SID for removable storage capability for app containers.
    $WinBuiltinRDSRemoteAccessServersSid           = 95, _   ;; "RA" - $SDDL_RDS_REMOTE_ACCESS_SERVERS
    $WinBuiltinRDSEndpointServersSid               = 96, _   ;; "ES" - $SDDL_RDS_ENDPOINT_SERVERS
    $WinBuiltinRDSManagementServersSid             = 97, _   ;; "MS" - $SDDL_RDS_MANAGEMENT_SERVERS
    $WinUserModeDriversSid                         = 98, _   ;; "UD" - $SDDL_USER_MODE_DRIVERS
    $WinBuiltinHyperVAdminsSid                     = 99, _   ;; "HA" - $SDDL_HYPER_V_ADMINS
    $WinAccountCloneableControllersSid             = 100, _  ;;
    $WinBuiltinAccessControlAssistanceOperatorsSid = 101, _  ;; "AA" - $SDDL_ACCESS_CONTROL_ASSISTANCE_OPS
    $WinBuiltinRemoteManagementUsersSid            = 102, _  ;; "RM" - $SDDL_REMOTE_MANAGEMENT_USERS
    $WinAuthenticationAuthorityAssertedSid         = 103, _  ;; "AS" - $SDDL_AUTHORITY_ASSERTED
    $WinAuthenticationServiceAssertedSid           = 104, _  ;; "SS" - $SDDL_SERVICE_ASSERTED
    $WinLocalAccountSid                            = 105, _  ;;
    $WinLocalAccountAndAdministratorSid            = 106, _  ;;
    $WinAccountProtectedUsersSid                   = 107     ;;
Global Const $WELL_KNOWN_SID_TYPE                  = "INT"

;;
;; SDDL User aliases
;;
Global Const $SDDL_DOMAIN_ADMINISTRATORS          = "DA"  ;; 0x00000200 - $DOMAIN_GROUP_RID_ADMINS - Domain admins
Global Const $SDDL_DOMAIN_GUESTS                  = "DG"  ;; 0x00000202 - $DOMAIN_GROUP_RID_GUESTS - Domain guests
Global Const $SDDL_DOMAIN_USERS                   = "DU"  ;; 0x00000201 - $DOMAIN_GROUP_RID_USERS - Domain users
Global Const $SDDL_ENTERPRISE_DOMAIN_CONTROLLERS  = "ED"  ;; 0x00000009 - $SECURITY_SERVER_LOGON_RID - Enterprise domain controllers
Global Const $SDDL_DOMAIN_DOMAIN_CONTROLLERS      = "DD"  ;; 0x00000204 - $DOMAIN_GROUP_RID_CONTROLLERS - Domain domain controllers
Global Const $SDDL_DOMAIN_COMPUTERS               = "DC"  ;; 0x00000203 - $DOMAIN_GROUP_RID_COMPUTERS - Domain computers
Global Const $SDDL_BUILTIN_ADMINISTRATORS         = "BA"  ;; 0x00000220 - $DOMAIN_ALIAS_RID_ADMINS - Builtin (local ) administrators
Global Const $SDDL_BUILTIN_GUESTS                 = "BG"  ;; 0x00000222 - $DOMAIN_ALIAS_RID_GUESTS - Builtin (local ) guests
Global Const $SDDL_BUILTIN_USERS                  = "BU"  ;; 0x00000221 - $DOMAIN_ALIAS_RID_USERS - Builtin (local ) users
Global Const $SDDL_LOCAL_ADMIN                    = "LA"  ;; 0x000001F4 - $DOMAIN_USER_RID_ADMIN - Local administrator account
Global Const $SDDL_LOCAL_GUEST                    = "LG"  ;; 0x000001F5 - $DOMAIN_USER_RID_GUEST - Local group account
Global Const $SDDL_ACCOUNT_OPERATORS              = "AO"  ;; 0x00000224 - $DOMAIN_ALIAS_RID_ACCOUNT_OPS - Account operators
Global Const $SDDL_BACKUP_OPERATORS               = "BO"  ;; 0x00000227 - $DOMAIN_ALIAS_RID_BACKUP_OPS - Backup operators
Global Const $SDDL_PRINTER_OPERATORS              = "PO"  ;; 0x00000226 - $DOMAIN_ALIAS_RID_PRINT_OPS - Printer operators
Global Const $SDDL_SERVER_OPERATORS               = "SO"  ;; 0x00000225 - $DOMAIN_ALIAS_RID_SYSTEM_OPS - Server operators
Global Const $SDDL_AUTHENTICATED_USERS            = "AU"  ;; 0x0000000B - $SECURITY_AUTHENTICATED_USER_RID - Authenticated users
Global Const $SDDL_PERSONAL_SELF                  = "PS"  ;; 0x0000000A - $SECURITY_PRINCIPAL_SELF_RID - Personal self .
Global Const $SDDL_CREATOR_OWNER                  = "CO"  ;; 0x00000000 - $SECURITY_CREATOR_OWNER_RID - Creator owner
Global Const $SDDL_CREATOR_GROUP                  = "CG"  ;; 0x00000001 - $SECURITY_CREATOR_GROUP_RID - Creator group
Global Const $SDDL_LOCAL_SYSTEM                   = "SY"  ;; 0x00000012 - $SECURITY_LOCAL_SYSTEM_RID - Local system
Global Const $SDDL_POWER_USERS                    = "PU"  ;; 0x00000223 - $DOMAIN_ALIAS_RID_POWER_USERS - Power users
Global Const $SDDL_EVERYONE                       = "WD"  ;; 0x00000000 - $SECURITY_WORLD_RID - Everyone ( World )
Global Const $SDDL_REPLICATOR                     = "RE"  ;; 0x00000228 - $DOMAIN_ALIAS_RID_REPLICATOR - Replicator
Global Const $SDDL_INTERACTIVE                    = "IU"  ;; 0x00000004 - $SECURITY_INTERACTIVE_RID - Interactive logon user  This is a group identifier added to the token of a process when it was logged on interactively. The corresponding logon type is LOGON32_LOGON_INTERACTIVE
Global Const $SDDL_NETWORK                        = "NU"  ;; 0x00000002 - $SECURITY_NETWORK_RID - Nework logon user  This is a group identifier added to the token of a process when it was logged on across a network. The corresponding logon type is LOGON32_LOGON_NETWORK
Global Const $SDDL_SERVICE                        = "SU"  ;; 0x00000006 - $SECURITY_SERVICE_RID - Service logon user  This is a group identifier added to the token of a process when it was logged as a service. The corresponding logon type is LOGON32_LOGON_SERVICE
Global Const $SDDL_RESTRICTED_CODE                = "RC"  ;; 0x0000000C - $SECURITY_RESTRICTED_CODE_RID - Restricted code  This is a restricted token created using the CreateRestrictedToken function
Global Const $SDDL_WRITE_RESTRICTED_CODE          = "WR"  ;; Write Restricted code
Global Const $SDDL_ANONYMOUS                      = "AN"  ;; 0x00000007 - $SECURITY_ANONYMOUS_LOGON_RID - Anonymous Logon
Global Const $SDDL_SCHEMA_ADMINISTRATORS          = "SA"  ;; 0x00000206 - $DOMAIN_GROUP_RID_SCHEMA_ADMINS - Schema Administrators
Global Const $SDDL_CERT_SERV_ADMINISTRATORS       = "CA"  ;; 0x00000205 - $DOMAIN_GROUP_RID_CERT_ADMINS - Certificate Server Administrators
Global Const $SDDL_RAS_SERVERS                    = "RS"  ;; 0x00000229 - $DOMAIN_ALIAS_RID_RAS_SERVERS - RAS servers group
Global Const $SDDL_ENTERPRISE_ADMINS              = "EA"  ;; 0x00000207 - $DOMAIN_GROUP_RID_ENTERPRISE_ADMINS - Enterprise administrators
Global Const $SDDL_GROUP_POLICY_ADMINS            = "PA"  ;; 0x00000208 - $DOMAIN_GROUP_RID_POLICY_ADMINS - Group Policy administrators
Global Const $SDDL_ALIAS_PREW2KCOMPACC            = "RU"  ;; 0x0000022A - $DOMAIN_ALIAS_RID_PREW2KCOMPACCESS - alias to allow previous windows 2000
Global Const $SDDL_LOCAL_SERVICE                  = "LS"  ;; 0x00000013 - $SECURITY_LOCAL_SERVICE_RID - Local service account (for services)
Global Const $SDDL_NETWORK_SERVICE                = "NS"  ;; 0x00000014 - $SECURITY_NETWORK_SERVICE_RID - Network service account (for services)
Global Const $SDDL_REMOTE_DESKTOP                 = "RD"  ;; 0x0000022B - $DOMAIN_ALIAS_RID_REMOTE_DESKTOP_USERS - Remote desktop users (for terminal server)
Global Const $SDDL_NETWORK_CONFIGURATION_OPS      = "NO"  ;; 0x0000022C - $DOMAIN_ALIAS_RID_NETWORK_CONFIGURATION_OPS - Network configuration operators ( to manage configuration of networking features)
Global Const $SDDL_PERFMON_USERS                  = "MU"  ;; Performance Monitor Users
Global Const $SDDL_PERFLOG_USERS                  = "LU"  ;; Performance Log Users
Global Const $SDDL_IIS_USERS                      = "IS"  ;; Anonymous Internet Users
Global Const $SDDL_CRYPTO_OPERATORS               = "CY"  ;; Crypto Operators
Global Const $SDDL_OWNER_RIGHTS                   = "OW"  ;; Owner Rights SID
Global Const $SDDL_EVENT_LOG_READERS              = "ER"  ;; Event log readers
Global Const $SDDL_ENTERPRISE_RO_DCs              = "RO"  ;; 0x000001F2 - $DOMAIN_GROUP_RID_ENTERPRISE_READONLY_DOMAIN_CONTROLLERS - Enterprise Read-only domain controllers
Global Const $SDDL_CERTSVC_DCOM_ACCESS            = "CD"  ;; 0x0000023E - $DOMAIN_ALIAS_RID_CERTSVC_DCOM_ACCESS_GROUP - Users who can connect to certification authorities using DCOM
Global Const $SDDL_ALL_APP_PACKAGES               = "AC"  ;; All applications running in an app package context
Global Const $SDDL_RDS_REMOTE_ACCESS_SERVERS      = "RA"  ;; Servers in this group enable users of RemoteApp programs and personal virtual desktops access to these resources.
Global Const $SDDL_RDS_ENDPOINT_SERVERS           = "ES"  ;; Servers in this group run virtual machines and host sessions where users RemoteApp programs and personal virtual desktops run.
Global Const $SDDL_RDS_MANAGEMENT_SERVERS         = "MS"  ;; Servers in this group can perform routine administrative actions on servers running Remote Desktop Services.
Global Const $SDDL_USER_MODE_DRIVERS              = "UD"  ;; UserMode driver
Global Const $SDDL_HYPER_V_ADMINS                 = "HA"  ;; Members of this group have complete and unrestricted access to all features of Hyper-V.
Global Const $SDDL_CLONEABLE_CONTROLLERS          = "CN"  ;; Members of this group that are domain controllers may be cloned.
Global Const $SDDL_ACCESS_CONTROL_ASSISTANCE_OPS  = "AA"  ;; Members of this group can remotely query authorization attributes and permissions for resources on this computer.
Global Const $SDDL_REMOTE_MANAGEMENT_USERS        = "RM"  ;; Members of this group can access WMI resources over management protocols (such as WS-Management via the Windows Remote Management service). This applies only to WMI namespaces that grant access to the user.
Global Const $SDDL_AUTHORITY_ASSERTED             = "AS"  ;; Authentication Authority Asserted
Global Const $SDDL_SERVICE_ASSERTED               = "SS"  ;; Authentication Service Asserted
Global Const $SDDL_PROTECTED_USERS                = "AP"  ;; Members of this group are afforded additional protections against authentication security threats.


;; need $pBASID for GetNamedSecurityInfo & SetNamedSecurityInfo or GetSecurityInfo & SetSecurityInfo etc etc 
Global Const $pBASID = _WinAPI_GetWellKnownSidEx("BA")
Global Const $pUPSID = _WinAPI_GetWellKnownSidEx(@UserName)
Global Const $sUPSID = _WinAPI_GetWellKnownSidEx(@UserName, 2) ;;just for test
Local $aSID = _WinAPI_GetWellKnownSidEx(0, 8)
_ArrayDisplay($aSID)

; #FUNCTION# ====================================================================================================================
; Name...........: _WinAPI_GetWellKnownSidEx
; Description ...: Get\Create SID
; Syntax.........: _WinAPI_GetWellKnownSidEx($sWellKnownSid)
; Parameters ....: $sWellKnownSid - Member of the WELL_KNOWN_SID_TYPE enumeration that specifies what the SID will identify
;                                 Or a string containing the string-format SID. The SID string can use either the standard
;                                  S-R-I-S-S… format for SID strings, or the SID string constant format, such as "BA" for built-in
;                                  administrators. For more information about SID string notation, see SDDL User aliases ($SDDL_*) and
;                                  SID Components http://msdn.microsoft.com/en-us/library/windows/desktop/aa379597(v=vs.85).aspx
;                                Or set NULL thi parameter to clean everything, to delete all SID Structure\pointer in $aWellKnownSid
;                  $iFlags - Optional
;                  |0 - (Default) Return pointer of the SID Structure
;                  |1 - Return SID Structure (the SID in a byte structure)
;                  |2 - Return the standard S-R-I-S-S… format for SID strings
;                  |3 - Return SID SDDL User aliases (example BA or BU etc etc)
;                  |4 - Return SID WELL_KNOWN_SID_TYPE (0 to 107)
;                  |8 - Return Array2D ($aWellKnownSid) of SID
; Return values .: Success - A pointer to a SID structure that identifies the object Or see $iFlags option
; Author ........: DXRW4E
; Modified.......:
; Remarks .......:
; Related .......:
; Link ..........:
; Example .......:
; ===============================================================================================================================
Func _WinAPI_GetWellKnownSidEx($sWellKnownSid, $iFlags = 0)
    Local Static $aWellKnownSid[5][5] = [[0,4,@LF, @CR & "0" & @LF]]
    If BitAND($iFlags, 8) Then Return $aWellKnownSid
    If $sWellKnownSid == Null Then
        Local $_aWellKnownSid[5][5] = [[0,4,@LF, @CR & "0" & @LF]]
        $aWellKnownSid = $_aWellKnownSid
        Return
    EndIf
    Local $iType = BitAND($iFlags, ($iFlags > 4 ? 3 : 7)), $iSid = Int(StringRegExp($aWellKnownSid[0][2] & $sWellKnownSid & $aWellKnownSid[0][3], "(?i)\n\K\Q" & $sWellKnownSid & "\E\r(\d+)\n", 1)[0])
    If $iSid Then Return SetError(0, $aWellKnownSid[$iSid][0], $aWellKnownSid[$iSid][$iType])
    If $aWellKnownSid[0][0] = $aWellKnownSid[0][1] Then
        $aWellKnownSid[0][1] *= 2
        ReDim $aWellKnownSid[$aWellKnownSid[0][1] + 1][5]
    EndIf
    Local $iSid = $aWellKnownSid[0][0] + 1
    If String($sWellKnownSid) = @UserName Then
        $sWellKnownSid = DllStructCreate("Byte SID[256]")
        $arDllCall = DllCall($hAdvapi32Dll, "BOOL", "LookupAccountNameW", "WSTR", Null, "WSTR", @UserName, "STRUCT*", $sWellKnownSid, "DWORD*", DllStructGetSize($sWellKnownSid), "WSTR", "", "DWORD*", DllStructGetSize($sWellKnownSid), "INT*", 0)
        If @Error Or Not $arDllCall[0] Then Return SetError((@Error ? @Error : _WinAPI_GetLastErrorEx()), 1, 0)
        $arDllCall = DllCall($hAdvapi32Dll, "INT", "ConvertSidToStringSidW", "STRUCT*", $sWellKnownSid, "PTR*", 0)
        If @Error Or Not $arDllCall[0] Then Return SetError((@Error ? @Error : _WinAPI_GetLastErrorEx()), 2, 0)
        $sWellKnownSid = DllStructGetData(DllStructCreate("WCHAR[256]", $arDllCall[2]), 1)
        DllCall($hKernel32DLL, "PTR", "LocalFree", "PTR", $arDllCall[2])
        $aWellKnownSid[0][2] &= @UserName & @CR & $iSid & @LF
    EndIf
    If StringIsDigit($sWellKnownSid) Then
        $arDllCall = DllCall($hAdvapi32Dll, "BOOL", "CreateWellKnownSid", "INT", Int($sWellKnownSid), "PTR", Null, "PTR", Null, "DWORD*", 0)
        If @Error Or Not $arDllCall[4] Then Return SetError((@Error ? @Error : _WinAPI_GetLastErrorEx()), 3, 0)
        $aWellKnownSid[$iSid][1] = DllStructCreate("Byte SID[" & $arDllCall[4] & "]")
        $arDllCall = DllCall($hAdvapi32Dll, "BOOL", "CreateWellKnownSid", "INT", $arDllCall[1], "PTR", Null, "STRUCT*", $aWellKnownSid[$iSid][1], "DWORD*", $arDllCall[4])
        If Not $arDllCall[0] Then Return SetError(_WinAPI_GetLastErrorEx(), 4, 0)
        $aWellKnownSid[$iSid][4] = $arDllCall[1]
    Else
        $arDllCall = DllCall($hAdvapi32Dll, "BOOL", "ConvertStringSidToSidW", "WSTR", $sWellKnownSid, "PTR*", 0)
        If @Error Or Not $arDllCall[0] Then
            If $sWellKnownSid <> "BA" Then Return SetError((@Error ? @Error : _WinAPI_GetLastErrorEx()), 5, 0)
            $aWellKnownSid[$iSid][1] = DllStructCreate("Byte Data[16]")
            DllStructSetData($aWellKnownSid[$iSid][1], "Data", "0x01020000000000052000000020020000")
        Else
            $arDllCall = DllCall($hAdvapi32Dll, "DWORD", "GetLengthSid", "PTR", $arDllCall[2])
            $aWellKnownSid[$iSid][1] = DllStructCreate("Byte Data[" & $arDllCall[0] & "]")
            DllStructSetData($aWellKnownSid[$iSid][1], "Data", DllStructGetData(DllStructCreate("Byte Data[" & $arDllCall[0] & "]", $arDllCall[1]), "Data"))
            DllCall($hKernel32DLL, "PTR", "LocalFree", "PTR", $arDllCall[1])
        EndIf
        $aWellKnownSid[$iSid][3] = $sWellKnownSid
    EndIf
    $aWellKnownSid[$iSid][2] = DllCall($hAdvapi32Dll, "BOOL", "ConvertSidToStringSidW", "STRUCT*", $aWellKnownSid[$iSid][1], "WSTR*", 0)[2]
    If Not $aWellKnownSid[$iSid][3] Then $aWellKnownSid[$iSid][3] = $aWellKnownSid[$iSid][2]
    If StringRegExp($aWellKnownSid[0][2], "(?i)\n\K\Q" & $aWellKnownSid[$iSid][2] & "\E\r\d+\n") Then
        $iSid = StringRegExp($aWellKnownSid[0][2], "(?i)\n\K\Q" & $aWellKnownSid[$iSid][2] & "\E\r(\d+)\n", 1)[0]
        $aWellKnownSid[0][2] &= $sWellKnownSid & @CR & $iSid & @LF
        $aWellKnownSid[$iSid][(StringIsDigit($sWellKnownSid) ? 4 : 3)] = $sWellKnownSid
        Return SetError(0, $aWellKnownSid[$iSid][0], $aWellKnownSid[$iSid][$iType])
    EndIf
    $aWellKnownSid[0][0] = $iSid
    $aWellKnownSid[$iSid][0] = DllStructGetPtr($aWellKnownSid[$iSid][1])
    $aWellKnownSid[0][2] &= $sWellKnownSid & @CR & $iSid & @LF & $aWellKnownSid[$iSid][2] & @CR & $iSid & @LF
    Return SetError(0, $aWellKnownSid[$iSid][0], $aWellKnownSid[$iSid][$iType])
EndFunc


Func _WinAPI_GetLastErrorEx()
    $arDllCall = DllCall($hKernel32DLL, "LONG", "GetLastError")
    Return (@Error ? @Error : $arDllCall[0])
EndFunc ;==>_WinAPI_GetLastErrorEx
Ciao. Edited by DXRW4E

apps-odrive.pngdrive_app_badge.png box-logo.png new_logo.png MEGA_Logo.png

Share this post


Link to post
Share on other sites

czardas,

The pecking order you mention could change at any time internally in AutoIt for compatibility reasons with i.e. COM usage, DllCall or other. Compatibility is more important compared to what some would prefer. The fact remains that the question of the pecking order can be answered with something unreliable as the pecking order may not be stable at any given time. It is reasonably stable, IMO. If you want assurance with types, then you should consider casting the type and not let AutoIt decide for you if you are in doubt.

DXRW4E,

I see you are doing some checks. That is good. How many checks and casting of types is needed varies. Obviously, you do not want to do too many else it slows down your code and makes it look even more complex. Much of the code is probably controlled with the types so bad things will not be expected to happen. Functions exist to check, to change, to evaluate, to execute... if something is missing which hinders your ability to handle concerns then express the concern so it can be reviewed. I hope you are going to add some comment lines to the code to help with understanding it.

Share this post


Link to post
Share on other sites

How I overcome this "issue" is I stick to a variable naming convention like Hungarian notation, because then I know $iString = $sString might not work as I expect it to, though $string = $thisString, well that's anyone's guess really. This is why I enjoy C#. 


_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

#14 ·  Posted (edited)

My variables change type all the time. If I didn't recast, then I would face memory issues with some scripts. It's when they change sneakily, without you knowing, that causes the most problems for me.

Edited by czardas

Share this post


Link to post
Share on other sites

#15 ·  Posted (edited)

My variables change type all the time. If I didn't recast, then I would face memory issues with some scripts. It's when they change sneakily, without you knowing, that causes the most problems for me.

I guess you don't work in a development team, because that wouldn't be fair on your fellow peers to work in that manner.

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

czardas,

 

It's when they change sneakily, without you knowing

That is a drawback to not having strongly typed variables in AutoIt - a design choice (as discussed in your other thread by Jon a long time ago to prevent problems for inexperienced coders writing simple scripts. ;)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

I agree with the concept, although things can become extremely tricky with more complex scripts. I would probably never have started coding at all if it was not for Jon and AutoIt, so I can't complain. I only say things that I think might be helpful - even when under stress.  :sweating:

Share this post


Link to post
Share on other sites

#18 ·  Posted (edited)

I guess you don't work in a development team, because that wouldn't be fair on your fellow peers to work in that manner.

 

Indeed, much of my code is written in base36.

Edited by czardas

Share this post


Link to post
Share on other sites

czardas,

Could I also make clear that AutoIt does not "sneakily" change the type of variables when making a comparison - AutoIt only changes the type within its comparison parsing and the variables themselves are unaltered as this script shows: :)

#include <MsgBoxConstants.au3>

$iInteger = 1
$sString = "String"

MsgBox($MB_SYSTEMMODAL, "Types 1", VarGetType($iInteger) & @CRLF & $sString)

; Standard numeric comparison - $sString converted to number only for the comparison
If $iInteger = $sString Then
    ; Do nothing
EndIf

MsgBox($MB_SYSTEMMODAL, "Types 2", VarGetType($iInteger) & @CRLF & $sString)

; Forced strign comparison - both sides internally converted to strings only for the comparison
If $iInteger == $sString Then
    ; Do nothing
EndIf

MsgBox($MB_SYSTEMMODAL, "Types 3", VarGetType($iInteger) & @CRLF & $sString)
So this is not like the division case where the type of the variable itself is forced to float. ;)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

I know, I was referring to something else - specifically division - but now I know about that recasting. :)

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