Jump to content

Structuring Scripts


Guest win286
 Share

Recommended Posts

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

Link to comment
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?
Link to comment
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!
Link to comment
Share on other sites

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
Link to comment
Share on other sites

  • 1 year later...

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