Jump to content

How to Call function from different directory


 Share

Recommended Posts

Hi all,

I have 2 function in script1.au3 and I want to call function from this file in another file script2.au3.

As both the scripts are located in different directories #include "script1.au3" doesnt work

Please help immediately.

Link to comment
Share on other sites

HI,

First script saved as funca.au3

Func a()
    MsgBox(0,"info", "works")
EndFunc
oÝ÷ Ù'¢wlr¸©µ«­¢+Ø(¥¹±Õ±ÐíÕ¹¹ÔÌÐì) ¤(

Both saved in same folder, otherwise you need the complete path like: c:\ ....

So long,

Mega

@Valuater: Maybe you could explain how to use two funcs in two scripts with same name :">

Edited by th.meger

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Link to comment
Share on other sites

note

In an AutoIt script, other scripts can be included using the #include" command.

If "..." is used, the filename is taken to be relative to the current script.

#include<funca.au3> must be placed in the running autoit versions \include folder

8)

Edited by Valuater

NEWHeader1.png

Link to comment
Share on other sites

Please help immediately.

Yes master, I'll get right on it :P

A little rude don't you think, and not even a 'Thank You'.

There are 3 things you need to learn before requesting 'immediate' help

  • ALWAYS show your code and be specific with your questions.
  • ALWAYS read the help file and/or search the forums before posting.
  • NEVER act like you deserve to have a code wrote for you.
Following these guidelines when posting will get you both quicker and more accurate results Plus more respect on the forum

----------

Anyway,

To include a script, simply copy it in the include directory of the autoit3 folder in Program Files

Then call it like this:

#Include <*YourScript.au3*>

Otherwise, as said before, call an include with the full path to the target file

Link to comment
Share on other sites

;This file is present in c:\scripts folder

script1.au3

Func Myfunction()

msgbox(0,"r","hi")

Endfunc

;I have another script in d:\scripts folder

script2.au3

#include"script1.au3"

Myfunction()

When I executes script2.au3, it gives error "function not found" and also I dont want give full path of script1.au3 in #include,

I hope this clears the problem

Link to comment
Share on other sites

;This file is present in c:\scripts folder

script1.au3

Func Myfunction()

msgbox(0,"r","hi")

Endfunc

;I have another script in d:\scripts folder

script2.au3

#include"script1.au3"

Myfunction()

When I executes script2.au3, it gives error "function not found" and also I dont want give full path of script1.au3 in #include,

I hope this clears the problem

your question has been answered already... see above posts

8)

NEWHeader1.png

Link to comment
Share on other sites

...I dont want give full path of script1.au3 in #include

Well then, You have 2 choices
  • Take a copy of the script to be included and put it in your include folder(C:\Program Files\Autoit3\Include)
  • copy the contents of the script to be included into you other script
Link to comment
Share on other sites

Well then, You have 2 choices

  • Take a copy of the script to be included and put it in your include folder(C:\Program Files\Autoit3\Include)
  • copy the contents of the script to be included into you other script

Paulie... there is the one additional choice

include"filename.au3"

the OP should look at the help file for "inlude"

8)

NEWHeader1.png

Link to comment
Share on other sites

note

#include<funca.au3> must be placed in the running autoit versions \include folder

8)

HI,

I would say no, because it works for me, this way #include<funca.au3> (when saved in same folder).

and this way anytime.

#include<c:\Downloads\AutoIt-Skripte\Entwicklung\ForumTests\funca.au3>
a()

Still left:

Maybe you could explain how to use two funcs in two scripts with same name :">

So long,

Mega

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Link to comment
Share on other sites

.....otherwise you need the complete path like: c:\ ....

Edit:

If your include folder in "D:\scripts" is a permanent main usage include folder for any script, then SciteConfig in Scite4AutoIt3 has an option to add an additional include folder into registry so AutoIt3 may look there for includes also as well as the standard includes.

Edited by MHz
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...