Jump to content
TrashBoat

Include an au.3 @scriptDir

Recommended Posts

TrashBoat

How do i add a path to a file in Include.

I want my script to get the udf in the same folder as the script/exe:

Include "@ScriptDir/udf.au3"

can this be done?

Share this post


Link to post
Share on other sites
water

Use

#Include "udf.au3"

The help file explains the search order for <> and ""

Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-01-27 - Version 1.3.3.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites
TrashBoat

Then i compile the script and edit the udf it dosent update 

Share this post


Link to post
Share on other sites
Jos

Why would you expect that to happen?

 Isn't compiling the same as taking the current source and creating a selfcontained executable to you?

Jos


Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
TrashBoat
Just now, Jos said:

Why would you expect that to happen?

 Isn't compiling the same as taking the current source and creating a selfcontained executable to you?

Jos

I wanted that my script would read the udf that i included and execute functions from there, but now then i  compile it seems just to take the udf read it once and dont update if it has been updated

Share this post


Link to post
Share on other sites
water

#Include is processed during compile time. So you need to re-compile your script for the changes to take effect.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-01-27 - Version 1.3.3.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites
TrashBoat

can i make it so it updates somehow? or not?

Share this post


Link to post
Share on other sites
Jos

Yes, but that means you need to run the script each time instead of using a compiled version.
... but why do you need this anyways?   What are you looking for to update in the script?

Jos


Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
TrashBoat

My point here is so a user can put his function in the udf.au3 file and save it launch my program and execute it via function name 

Share this post


Link to post
Share on other sites
TrashBoat

or maybe there is an easier way of executing another script via a gui of some sorts

Share this post


Link to post
Share on other sites
TrashBoat
10 minutes ago, Jos said:

Yes, but that means you need to run the script each time instead of using a compiled version.
... but why do you need this anyways?   What are you looking for to update in the script?

Jos

im looking to update that udf so the program can read it and recognize the newly typed functions

Share this post


Link to post
Share on other sites
Jos

That description  is way to vague for me to consider whether there are alternative ways.
So you really need to code script logic and can't get away with an INI file or something?

Jos


Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
TrashBoat

well ini files cant store scripts and execute them on command can they? Just tell me a way how to execute another script/compiled version of the script via a gui of sorts

Share this post


Link to post
Share on other sites
TrashBoat
14 minutes ago, Jos said:

That description  is way to vague for me to consider whether there are alternative ways.
So you really need to code script logic and can't get away with an INI file or something?

Jos

Think of it like a database that can be updated by the user 

Share this post


Link to post
Share on other sites
Jos

So you want your users to update the script? ...  then as stated, simply run the script with autoit3.exe.

Jos


Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
TrashBoat
9 minutes ago, Jos said:

So you want your users to update the script? ...  then as stated, simply run the script with autoit3.exe.

Jos

but the users wont have autoit installed

Share this post


Link to post
Share on other sites
Jos

So what?  Each compiled script can act as the stub for an script and execute that.

When you want real help you will have to post a real question here with its usecase ..  else I am out.

Jos

Edited by Jos

Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
SlackerAl

Options:

Give your users an uncompiled stub that uses functions that your users can edit - distributed with AutoIt. Whether these functions are in includes or not is just a matter of housekeeping. But if compiled you are locked in to whatever the state was at compile time.

Allow your users to edit a flat file / SQLite DB that is read in by your script at run time. Your script can be compiled or not. Limitation, you can execute some AutoIt code like this:

#include <MsgBoxConstants.au3>
Opt('MustDeclareVars', 1)
Global $MyFunc = "MsgBox(4096, 'Test', 'Hello') & MsgBox(4096, 'Test', 'And me')"
Execute($MyFunc)

but you wont be able to do anything much more complex than that without writing your own script parser within your AutoIt script, and that is going to get ugly fast. 

Equally you could write some functions in your script and expose them to users to activate with parameters from a flat file using conditionals, but as Jos says, you would have to post exactly what the use case was for people to advise you appropriately on that.

What it seems to me you are asking for is a compiled program that reads in some more source code and recompiles itself to include that additional source code: That is not going to happen without more pain than just distributing AutoIt in the first place. 

 


Problem solving step 1: Write a simple, self-contained, running, replicator of your problem.

Share this post


Link to post
Share on other sites
water

If a user is able to write custom functions why shouldn't he be able to compile the script himself?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-01-27 - Version 1.3.3.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

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

  • Similar Content

    • Fr33b0w
      By Fr33b0w
      Func z009() If FileExists("search\009\009.au3") Then #include <search\009\009.au3> EndIf EndFunc This wont work...  Is there any workarround for this or I should do it in a different way?
       
    • ur
      By ur
      I have recorded a gui installation and modified the au3 file as per my requirement.
      But the problem is, whenever I try to compile the au3 file, I am getting a special character on top of the file.

      Can you suggest how to resolve this as it is appearing everytime during compilation.
      And also I am trying to include a au3 file which is separate folder so I am adding the <..\Library.au3> line.
      It is able to pick that but in that file "Library.au3" there is a file install line.
      FileInstall(".\SendMail.ps1", @ScriptDir & "\SendMail.ps1") Library.au3 is being used by many other codes in the previous folder..
      But the current file is looking for the ps1 file in current folder.
      So is there any option to tell the compiler to pick the dependent files relative to Library.au3 instead of the current code.
    • pedrit0
      By pedrit0
      Hi all.
      I have created an external au3 (a library of functions and vars) that is #included in a main script that i must compile.
      I wish that the content of the library is not merged with the main script when compiling.
      My goal is to keep the ability to modify the library even after the main exe is compiled and that these changes are effective when executing the exe.
      I guess this is not possible using the standard #include method.
      Is there a way to do that ?
      thx a lot :-)
    • xiantez
      By xiantez
      Hey AutoIT Community,
      Just wanted to know if there is a way I can #include all *.au3 files in my script without having to #include each individual .au3 file. For instance, currently I have a laundry list of #includes like this:
      #include <IE.au3>
      #include <Inet.au3>
      #include <AutoItConstants.au3>
      #include <GUIConstantsEx.au3>
      #include <GDIPlus.au3>
      #include <GuiMenu.au3> 
      [ECT...ECT...]
      Would there be a way I could include all of the files above or all  .au3 file in a one liner? That way I do not have to burn up a bunch of lines of code for just my includes.... Your help is greatly appreciated...
    • Miliardsto
      By Miliardsto
      Is there possibility to do it like this?
      Cause as I see compiler doesn't see If statement in case of #include functions.
      It includes these two files all time.
      If $var == True Then #include 'func/funcsByTabs/main_Moda.au3' Else #include 'func/funcsByTabs/main_Others.au3' EndIf  
×