Jump to content

Split project into files


Recommended Posts

I started a little autoit project. I didn't think I would make it big, so I putted all of my functions and includes in one unique au3 file (I know it's a bad idea).
I have a file that is like
 

#include <lib1>
#include <lib2>
#include <lib3>
;...
Global $var1 = 1
Global $var2 = "df"

Func a()
; do thinghs
endfunc

Func b()
;do things
$something = a()
endfunc

Func c()
;do things
$something = a()
$else = b()
endfunc

;and so on

func main()
;...
endfunc

main()

The problem is that the file is now 3000 lines and it became very difficult to move through. I would love to split my project into more files
I tried splitting the function "by category", like

;; FILE funcs1.au3
func a()
;...
endfunc

func b()
;...
a()
endfunc
;FILE funcs2.au3

Func c()
a()
b()
;..
endfunc

Func d()
e()
;...
Endfunc
;FILE funcs3.au3
Func e()
c()
;...
endfunc

Func f()
a()
d()
;...
endfunc

But you see that when I need to include one another there is a problem: in function "d" (from funcs2.au3) I call function "e" which is in funcs3.au3, but in funcs3.au3 there is function "f" which call "a" and "d", so I need to include funcs1.au3 and funcs2 again. 
The function I wrote are nested and I can think a way to include all of them from one file to another. 
How can I achive this? 
Thank you and sorry for bad English. 

 

Link to comment
Share on other sites

  • Moderators

francesco9696,

I have a 4500 line script which I manage using the #region/#endregion directives which condense it down to a single line, quickly expandable to 16 sub-regions, each of which contain many functions. Using these directives means that you can retain everything in one file and yet still easily navigate around. More details are in the SciTE4Autoit3 help file - you doo use the full SciTE package?

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Just now, mikell said:

Suggestion : have a look at the  #include-once  directive  :)

I tried using #include-once and including every file in every file, but I get "Duplicate function name." errors. 
 

 

Just now, Melba23 said:

francesco9696,

I have a 4500 line script which I manage using the #region/#endregion directives which condense it down to a single line, quickly expandable to 16 sub-regions, each of which contain many functions. Using these directives means that you can retain everything in one file and yet still easily navigate around. More details are in the SciTE4Autoit3 help file - you doo use the full SciTE package?

M23

Yeah, it I could do like that, but sometimes I don't remember a function and when I need to call it, I need to scroll from the line where I'm coding back to the function I'm calling (also using the search feature) and then back to the original line and it's very annoying and time wasting. I use full SciTE, but I miss the quick goto function list feature that is present on other ide (in other languages). 

Link to comment
Share on other sites

  • Moderators

francesco9696,

Do you use guinness' SciTEJump utility which is included in the package? Using that, along with the bookmark feature of SciTE, I find that I can very quickly move around inside my very large file.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Hey @francesco9696, I understand what you are experiencing.

@Melba23 has given good advice that I also use.

In addition I make comments where I am working, eg 

If x=y Then ; 2017.01.23 added IF
;do something
ELSE
; do somehting else
; 2017.01.23 - TODO add FOR loop here
Endif

Now I can search for TODO and the date, so I can jump to my workspace quickly.  

Skysnake

Why is the snake in the sky?

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