Jump to content

New user: Help with UDFs


hlcit
 Share

Recommended Posts

Hi,

I'm new to AutoIt and was wondering if I could have some advice. I have written one program that calls another, and I have made a user defined function with modules that I have added to the Include file. At the top of the second file is #include and at the top of my modules file is #include-once.

If I run the calling program from SciTE then I dont get any errors. If I run the calling program from a windows explorer window, it throws up and AutoIt error "Error opening file". But it does pick up the other UDFs that came with AutoIT. What else do I need to set?

Thank you for your help in advance!

Edited by hlcit
Link to comment
Share on other sites

Where is the include file you wrote yourself stored?

Is it stored in the same folder as the main script file?

Thank you for your help.

They are both in different folders. The include file I wrote is in the AutoIt include file with the rest of the UDFs that AutoIt comes with. Id prefer it this way if possible. I've found that it will pick up the include file if I give it the full path but I'd rather not have to do that.

Link to comment
Share on other sites

Thank you for your help.

They are both in different folders. The include file I wrote is in the AutoIt include file with the rest of the UDFs that AutoIt comes with. Id prefer it this way if possible. I've found that it will pick up the include file if I give it the full path but I'd rather not have to do that.

I store my include files always together with my script file in the same folder.

This way I don't need to add the path to my include code.

Edited by Scriptonize

If you learn from It, it's not a mistake

Link to comment
Share on other sites

I store my include files always together with my script file in the same folder.

This way I don't need to add the path to my include code.

Once again thank you. My problem is that what I'm doing is for work so certain test script files have to be in certain folders and these all use the standard modules that I have been put together. To keep the file in the AutoIt\Include folder is it an environment variable or something that I need to set? I don't understand why it will pick up the AutoIt UDFs but not mine.

Link to comment
Share on other sites

At the top of the file to be included I have:

#include-once

At the top of the files to use the modules I have

#include <ATELog.au3>

And the ATELog.au3 file resides in the common include folder (something like C:\Program Files\AutoIt3\Include)?

[[EDIT]]

Just to be shure.

In the main script file you should use the line:

#include <ATELog.au3>

In the included file (ATELog.au3) you may add the line:

#include-once

Edited by Scriptonize

If you learn from It, it's not a mistake

Link to comment
Share on other sites

Sorry, I was editing my lats post while you replied.

Did you see my [[EDIT]]?

Sorry for that!

Those are the lines that I already have in place in the files

Is there a file anywhere that I have to put the name of my file in or something to allow AutoIt to find it?

Link to comment
Share on other sites

If you have all in place as it should, it should be working.

It's not such difficult thing to do.

The help files says:

--------------------------------------

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

For the include library syntax (#include <file>) to work AutoIt must have been installed using the supplied installer otherwise the installation directory will not be known and the current script directory (@ScriptDir\Include) will be used instead.

If you include the same file containing a user-function more than once you will get a "Duplicate function" error. When writing an include file that may be used in this way, make sure that the top line contains #include-once to prevent that file from being included more than once.

There is a special registry value that can be created at "HKEY_CURRENT_USER\Software\AutoIt v3\AutoIt" called "Include". It should be a REG_SZ (string) value. The contents of this value are a semi-colon delimited list of directories that should be searched for files when resolving #include's in addition to the standard locations.

-----------------------------------------

If you use "Include" this way (and it sounds like you do it this way), all should be working.

If you learn from It, it's not a mistake

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