Sign in to follow this  
Followers 0
Guest win286

Structuring Scripts

9 posts in this topic

I'm in the process of learning version 3 and need advice (& explanation) on how to structure scripts so they're maintainable. I found with version 2.x I'd get into trouble with scripts as they grow. I looked at several example scripts but still need guidance.

TIA,

DMS

Share this post


Link to post
Share on other sites

I would recommend breaking all the major functions that can be individualised into include scripts. Then you can include them in the main programs without worry of breaking much if you change the include files. The main script will not have to worry with the implementation of the code, just the calling of it.


Who else would I be?

Share this post


Link to post
Share on other sites

Hi,

The first i learned at school in programming class.

DOCUMENT EVERYTHING !!!!!!

Regards,

Andre


What about Windows without using AutoIt ?It would be the same as driving a car without an steering Wheel!

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Download scite by JdeB (Its an amazing simple to use text editor written for autoit)

http://www.autoitscript.com/forum/index.ph...wtopic=5846&hl=

Everything is colour coded, really easy to understand and to keep maintainable.

Edit:A few pointers, the way I keep things maintained.

-Keep all includes at the top of script

-Keep all opts just under includes

-Keep all varibles together, just under opts.

-When writing functions I keep them all together and space in 2 or 3 times like this

Func One()
   Line 1
   Line 2
   Line 3
EndFunc

Func Two()
   Line 1
   Line 2
   Line 3
EndFunc

-When writing If,Else,Endif statements, do so with tab spacings like so

If whatever = whatever Then
        MsgBox(4096,"", "True")
Else
        MsgBox(4096,"", "False")
EndIf

Hope that helps

Nova

Edited by Nova

Share this post


Link to post
Share on other sites

The things i belive is most important is to describe what it does.

So i use ; very often in my script, that way i can track things easy.

As Andre said, documentation is the key :idiot:


Were ever i lay my script is my home...

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

The things i belive is most important is to describe what it does.

So i use ; very often in my script, that way i can track things easy.

As Andre said, documentation is the key :lmao:

documentation will be more effective if it's the code that gives itself the information

Except when perfomance is the issue it's best to do functions than documentation

for instance :

lines of codes with documentation

....
;find for something in the test array
for $i=0 to ubound($test)-1
   if $test[$i]=$toFind then exit loop
next

;if found
if $i<ubound($test) then 
   msgbox(0,"","found")
else
   msgbox(0,"","not found")
endif
...
oÝ÷ ÚƦyÊy«­¡Úºg§µçZºÚ"µÍ[È[Ý^J ÌÍÝ[ÕÑ[
BÜ ÌÍÚOLÈXÝ[
    ÌÍÝÝ
KLBY    ÌÍÝÝÉÌÍÚWOIÌÍÝ[ÕÑ[[]YB^][ÙB[[ÂY[Ý^J ÌÍÕÑ[
OUYH[ÙØÞ
    ][ÝÉ][ÝË    ][ÝÙÝ[   ][ÝÊB[ÙBÙØÞ
    ][ÝÉ][ÝË    ][ÝÛÝÝ[ ][ÝÊB[YoÝ÷ Ùû«¶¦¢·¢*.Á©í¶æ¦¢·«zënWºw-â·ly«2jëh×6
func InArray($thingToFind,$Array)
  for $i=0 to ubound($Array)-1
    if $Array[$i]=$toFind then return true
  next
  return false
endfunc

func InTestArray($infoToFind)
  return InArray($infoToFind,$Test)
endfunc

....
  if InTestArray($thingToFind)=true then
    msgbox(0,"","found")
  else
    msgbox(0,"","not found")
  endif
......
Edited by tresa

Share this post


Link to post
Share on other sites

Talk about resurrecting an old post. That's got to be some kind or record. :lmao:


Auto3Lib: A library of over 1200 functions for AutoIt

Share this post


Link to post
Share on other sites

"Welcome to Autoit 1-2-3" is very educational and has a great example for what you are asking

Posted Image

in my signature below

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

Talk about resurrecting an old post. That's got to be some kind or record. :lmao:

geeze... you're right!!!

8)


NEWHeader1.png

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