Jump to content

Best Coding Practices


PeteF
 Share

Recommended Posts

Hi all, I'm new at AutoIT (wrote a few small scripts so far), and experienced with VB6 and VBA for about 20 years. I have read the Welcome Wiki, the FAQ & the Best Coding Practices at the links below as well as viewed a few hours of beginner AutoIT tutorials on youtube.

Welcome to the AutoIt Wiki.. https://www.autoitscript.com/wiki/

FAQ.. https://www.autoitscript.com/wiki/FAQ#In_SciTE

Best Coding Practices.. https://www.autoitscript.com/wiki/Best_coding_practices

----

My first questions relate to proper coding and standard coding practices that I have not found in any of the above resources.

1.) I have noticed in other people's code, that sometimes a function name is prefixed with "_" (see example below) and other times they are not.  What does the "_"  signify?  What does it mean to NOT use the "_" ?

Func _ChangeTime($iHour, $iMin)
    Local $sTime = $iHour & RegRead("HKEY_CURRENT_USER\Control Panel\International", "sTime") & $iMin
    RunWait(@ComSpec & " /c Time " & $sTime, "", @SW_HIDE)
    Return $sTime
EndFunc   ;==>_ChangeTime

2.) In the example above, I understand the importance of.. ;==>_ChangeTime,   but I have not been able to find any info on that coding practice. Is it something done voluntarily by the programmer or is it somehow built into SciTE to automatically add that standard notation?   Also are there other similar standard notations used for IF/THEN's or While/Wend's, For/Next's that I should be using?

3.)  Taking into consideration my 20 years experience with VB6 and VBA programming as an intermediate skill level programmer, what book on AutoIT programming would suit me best?

--pete

 

Link to comment
Share on other sites

@1) This is a convention and used to show that a function is a non-built-in function. (It doesn't have any functional effect.)

@2) It's the result of the "Tidy AutoIt Source" application, reachable by Ctrl+T (or Tools > Tidy AutoIt Source or tidy.exe in the install dir) in the full version of SciTE for AutoIt. It suffixes functions by that comment, among many many other functionalities.

Nothing to suggest for 3. But it's a very accessible language and this forum is very lively. I would say start out reading through the example scripts and the UDF's and just play around a bit. Maybe others can suggest actual study material.

Roses are FF0000, violets are 0000FF... All my base are belong to you.

Link to comment
Share on other sites

  • Moderators

As far as #3, no you won't find a book worth purchasing. There have been a few published, but they almost immediately become outdated as the language is evolving all the time. Your best resource is right here on the forum; there is very little you could want to do with AutoIt that someone has not already attempted, and you have the real time advice and knowledge of users, devs and even the owner from time to time.

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

13 hours ago, SadBunny said:
Quote

@1) This is a convention and used to show that a function is a non-built-in function. (It doesn't have any functional effect.)

@2) It's the result of the "Tidy AutoIt Source" application, reachable by Ctrl+T (or Tools > Tidy AutoIt Source or tidy.exe in the install dir) in the full version of SciTE for AutoIt. It suffixes functions by that comment, among many many other functionalities.

Ok, thank you,  "convention" , that's the word I was looking for. :)  Thanks for the answers, I'll put them to good use.

FYI: As a newbie to AutoIT, I'm documenting all my questions & answers as they arise and creating a kind of Quick Start Reference Guide for AutoIT for the VB6 programmer.  It should be a very useful document when I'm done and something I'll share with the community.

-pete

 

Link to comment
Share on other sites

12 hours ago, JLogan3o13 said:

As far as #3, no you won't find a book worth purchasing. There have been a few published, but they almost immediately become outdated as the language is evolving all the time.

Yeah, from reading the reviews of AutoIT books on amazon.com I was getting the feeling that there weren't too many really good books on the subject. As I mentioned in a previous post, I'm writing an AutoIT/SciTE quick start & reference guide for my own use from the perspective of an experienced VB6 programmer totally new to AutoIT and SciTE.

Does anyone here know roughly what percentage of members here on the forum fall into the category of experienced in VB6 or other similar language and relatively new to AutoIT?

-pete

Link to comment
Share on other sites

I dev'd in VB6 for a few years, writing a few major applications w/database/file access.  Autoit was an easy pickup for me (I had dabbled in it for years) and it continues to be easy to learn/understand most code.  A TON of code is available online if you do enough digging.  A lot of my VB6 code was hobbled together with excel sheets, so its fantastic to see that code is available in autoit and its very well supported (although I don't use Autoit to write to excel, I've moved to other things)

If you knew how to code VB6 well, I doubt you'll struggle with Autoit.  WMI queries, objects and ptr's are certainly more advanced, but very doable in autoit as well.

 

Edit:  Personally I've always used Functions prefixed with a _ to be functions that return something, and no _ is a function that does not return.  Just what I do.

Edited by kaisies
Link to comment
Share on other sites

18 hours ago, PeteF said:

3.)  Taking into consideration my 20 years experience with VB6 and VBA programming as an intermediate skill level programmer, what book on AutoIT programming would suit me best?

--pete

 

Help File is the best book I used for autoit... :P

ill get to that... i still need to learn and understand a lot of codes graduated.gif

Correct answer, learn to walk before you take on that marathon.

Link to comment
Share on other sites

4 hours ago, 232showtime said:

Help File is the best book I used for autoit... :P

I am self taught in many areas and my typical approach is to obtain 2 to 3 books by different authors, read one book for the basics and dig in actually doing what I'm trying to learn. Then when I hit a snag, I'll go to book 1 for the answer. If the answer is not quite clear, I go to book 2 and/or book 3 and the answer usually comes quickly because different authors explain things in slightly different ways which helps greatly to fill in any missing information. 

The AutoIt Help file is acceptable, but so far, it often leaves me with more questions that could probably be filled in with a well written book.  With a physical book, I can highlight things, place sticky notes, and browse through them in a manner that the electronic versions cannot.

I'd say, the electronic versions of HELP have more advantages over a physical book, but having both is the ideal situation.

-pete

Edited by PeteF
Link to comment
Share on other sites

6 hours ago, kaisies said:

If you knew how to code VB6 well, I doubt you'll struggle with Autoit.  WMI queries, objects and ptr's are certainly more advanced, but very doable in autoit as well.

Yeah, so far my biggest frustration is the absence of seamless debugging features I had in VB6. I miss the "immediate window" and it's ability to query variables or issue commands as the program is running.

I have installed dbug.au3, but it's a bit awkward compared to the VB6 IDE debugging features. It's just going to take some practice and getting used to.

Info on Debugging is the one area I found greatly lacking  among all the AutoIt and SciTE help resources. I searched the  HELP file in SciTE on debug and found nothing useful at all. Spent hours searching and viewing  youtube videos and only found one video on using dBug.au3 .  That's why I was hoping for 1 good thorough book that covered all the bases for an AutoIt newbie.

I'll figure it out, it's just going to take more time than I originally planned for, especially since I'm taking the time to document all the questions & answers as I encounter them. I've got about  7 pages so far of my own custom AutoIt Quick start & Reference guide. :)

Thanks to you and EVERYONE for the help & encouragement to date.

-pete

Link to comment
Share on other sites

4 hours ago, TheDcoder said:

As you are new, the correct capitalization of AutoIT is AutoIt :thumbsup:

Thanks for the clarification.

In listening to AutoIt videos I hear people pronounce it differently. 

What is the most widely used pronunciation of AutoIt?

-pete

Link to comment
Share on other sites

Just now, PeteF said:

What is the most widely used pronunciation of AutoIt?

According to the creator of AutoIt, @Jon, its "Aww-Toe-It"

EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time)

DcodingTheWeb Forum - Follow for updates and Join for discussion

Link to comment
Share on other sites

Are you planning to make your guide publically available or is it just a quick reference for yourself?

EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time)

DcodingTheWeb Forum - Follow for updates and Join for discussion

Link to comment
Share on other sites

2 minutes ago, TheDcoder said:

Are you planning to make your guide publically available or is it just a quick reference for yourself?

I'd like to submit it to the AutoIt community leaders for review and change it as needed and then release it to the forum for all to share.

Link to comment
Share on other sites

Link to comment
Share on other sites

  • Moderators
2 hours ago, PeteF said:

I'd like to submit it to the AutoIt community leaders for review and change it as needed and then release it to the forum for all to share.

Just realize that the Wiki really serves as our "Quick Start Guide" because it is continually updated. I would suggest (if you have not already done so) familiarizing yourself with the Wiki to see what subjects you plan to cover that aren't covered there. There is also the Welcome to AutoIt 1-2-3 (currently undergoing retooling) that serves as a training tool for people new to AutoIt.

No intention to discourage your work, of course, just an awareness of what the forum standards are for new users wanting to learn the language.

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

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