Jump to content

#include in middle ?


twelo
 Share

Recommended Posts

is it possible to include extra .au3 files in middle of script like between case scenario ?

because when i added extra .au3 file at the top of script my program goes slow down

it takes same extra time for which .au3 included (that means it loads automatically when programs starts)

i want extra .au3 to load when give input task.

Link to comment
Share on other sites

  • Moderators

Manadar,

While I agree with you 100% when talking about placing UDF #include files in the middle of a script, there is a place for using #include files which merely add a bit of frequently used code. Here is a simple example:

Include file:

If $i = 0 Then
    MsgBox(0, "Error", "Count is zero")
    ExitLoop
EndIf

Main script:

For $i = 5 To 0 Step -1
    #include <mb.au3>
Next

For $i = 5 To 0 Step -1
    #include <mb.au3>
Next

The only problem I ran across the one time I tried to use this technique was that Au3Check complained that I was trying to include the same file more than once and I could not find how to reset the switch to avoid this.

Anyway, just to reiterate for twelo's benefit, I am 100% with you about putting UDF #include files as the beginning of the script. ;)Just do not do it!

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

No, not even for small code snippets. There are work arounds and solutions.

I know you posted an example, but you can always do things like this:

For $i = 5 To 0 Step -1
    If _CheckError($i) Then ExitLoop
Next

For $i = 5 To 0 Step -1
    If _CheckError($i) Then ExitLoop
Next

Func _CheckError($n)
    If $n = 0 Then
        MsgBox(0, "Error", "Count is zero")
        Return 1
    EndIf
    Return 0
EndFunc

Even for 1 liners, you would still have to type #include on each line. It makes your script a pain to maintain.

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