Jump to content

Question about “Best Coding Practices” Wiki page


 Share

Recommended Posts

I am going through the AutoIt Wiki and soaking up a lot of great information.  On the “Best Coding Practices” page at https://www.autoitscript.com/wiki/Best_coding_practices#Scopes_of_Variables there seems to be a minor detail missing.  In the “Variable Initialization” section at https://www.autoitscript.com/wiki/Best_coding_practices#Variable_Initialization , there are references to a data type $o, but in the table listing prefixes and their data types, there does not appear to be a prefix “o”.  I assume that this is for Object?

Link to comment
Share on other sites

8 hours ago, mlazovjp said:

... there are references to a data type $o, but in the table listing prefixes and their data types, there does not appear to be a prefix “o”.  I assume that this is for Object?

Yes, "o" (sometimes "obj") stands for Object !

As described in the Wiki, these are 'only' naming conventions. AutoIt itself does not perform any special checks on these prefixes. So you can give a variable the name $sStringValue ($s... for string) and still specify an integer value :

Local $sStringValue = 1000

It is similar with $g_sStringValue. "$g_..." does not declare a variable in the global context. This is defined by the keyword Global ! These naming conventions only provide better readability.

Edited by Musashi

Musashi-C64.png

"In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move."

Link to comment
Share on other sites

I have added prefix "o" for objects as this is widely used in AutoIt UDFs (like Word, Excel) and hence "best practice" ;)

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.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 (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

Thank you, @Musashi and @water, for your explanations and for updating the table to include “object”.  I have been using AutoIt for nearly 20 years, but I hadn’t paid much attention to the coding best practices until now; I will be teaching a 400-level Computer Science special topics course that I am currently developing for this coming Spring semester, and a significant chunk of it will be focused on writing AutoIt scripts.  I am systematically reading through all of the Wiki pages for content I would like to cover in the course, and I figured it would be a good idea to make sure I understand the coding best practices as set out in the Wiki so I can teach and emphasize them early on so that we are consistent.

I love the AutoIt help file, but I am only now realizing how useful the Wiki is, too.

Reading the coding best practices Wiki makes me realize how sloppy my AutoIt code is.  I am actually excited to start using the coding best practices in my next scripts!

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

×
×
  • Create New...