Jump to content

Search the Community

Showing results for tags 'autoit syntax good bad'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • General
    • Announcements and Site News
    • Administration
  • AutoIt v3
    • AutoIt Help and Support
    • AutoIt Technical Discussion
    • AutoIt Example Scripts
  • Scripting and Development
    • Developer General Discussion
    • Language Specific Discussion
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Categories

  • AutoIt Team
    • Beta
    • MVP
  • AutoIt
    • Automation
    • Databases and web connections
    • Data compression
    • Encryption and hash
    • Games
    • GUI Additions
    • Hardware
    • Information gathering
    • Internet protocol suite
    • Maths
    • Media
    • PDF
    • Security
    • Social Media and other Website API
    • Windows
  • Scripting and Development
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Member Title


Location


WWW


Interests

Found 1 result

  1. We see a lot of examples submitted by users but rarely do we see threads about good coding practice. Post below if you have an example which exhibits the "dos and don'ts" of coding in AutoIt. Why using Dim over Local/Global is not always a good option: #include <MsgBoxConstants.au3> Dim $vVariableThatIsGlobal = "This is a variable that has ""Program Scope"" aka Global." MsgBox($MB_SYSTEMMODAL, "", "An example of why Dim can cause more problems than solve them.") Example() Func Example() MsgBox($MB_SYSTEMMODAL, "", $vVariableThatIsGlobal) ; That looks alright to me as it displays the following text: This is a variable that has "Program Scope" aka Global. Local $vReturn = SomeFunc() ; Call some random function. MsgBox($MB_SYSTEMMODAL, $vReturn, $vVariableThatIsGlobal) ; The Global variable ($vVariableThatIsGlobal) changed because I totally forgot I had a duplicate variable name in "SomeFunc". EndFunc ;==>Example Func SomeFunc() ; This should create a variable in Local scope if the variable name doesn"t already exist. ; For argument sake I totally forgot that I declared a variable already with the same name. ; Well I only want this to be changed in the function and not the variable at the top of the script. ; Should be OK right? Think again. Dim $vVariableThatIsGlobal = "" For $i = 1 To 10 $vVariableThatIsGlobal &= $i ; This will return 12345678910 totally wiping the previous contents of $vVariableThatIsGlobal. Next Return $vVariableThatIsGlobal EndFunc ;==>SomeFunc
×
×
  • Create New...