Jump to content

String variable in #include?


 Share

Recommended Posts

Hello, I'm writing a program that will include custom files in an addons folder. I can have it list all the files in the addons folder, but then I noticed that I can't use variables (the file names) in #include.

Any way I could get past this? Thanks,

Mini

Edited by Minikori

For those who are asking questions, look in the help file first. I'm tired of people asking stupid questions about how to do things when 10 seconds in the help file could solve their problem.[quote name='JRowe' date='24 January 2010 - 05:58 PM' timestamp='1264381100' post='766337'][quote name='beerman' date='24 January 2010 - 03:28 PM' timestamp='1264372082' post='766300']They already have a punishment system for abuse.[/quote]... and his his name is Valik.[/quote]www.minikori.com

Link to comment
Share on other sites

- make, in an empty include file, say "collection.au3"

- let your script first (before include statements) scan your real include folder,

and construct include statements, that you then write to "collection.au3"

- put an #include pointing at "collection.au3" in your script

sorry, too late to try for me here,

cheers,

whim

Link to comment
Share on other sites

- make, in an empty include file, say "collection.au3"

- let your script first (before include statements) scan your real include folder,

and construct include statements, that you then write to "collection.au3"

- put an #include pointing at "collection.au3" in your script

sorry, too late to try for me here,

cheers,

whim

I think I basically did what you said. The contents of all the .au3 files in the addons folder are put into addons.au3 while the program is running. So I have the problem solved now, thank you.

For those who are asking questions, look in the help file first. I'm tired of people asking stupid questions about how to do things when 10 seconds in the help file could solve their problem.[quote name='JRowe' date='24 January 2010 - 05:58 PM' timestamp='1264381100' post='766337'][quote name='beerman' date='24 January 2010 - 03:28 PM' timestamp='1264372082' post='766300']They already have a punishment system for abuse.[/quote]... and his his name is Valik.[/quote]www.minikori.com

Link to comment
Share on other sites

That won't work for compiled programs though. Keep this in mind.

Uh oh, why not?

EDIT: I know why, but do you know a workaround?

Edited by Minikori

For those who are asking questions, look in the help file first. I'm tired of people asking stupid questions about how to do things when 10 seconds in the help file could solve their problem.[quote name='JRowe' date='24 January 2010 - 05:58 PM' timestamp='1264381100' post='766337'][quote name='beerman' date='24 January 2010 - 03:28 PM' timestamp='1264372082' post='766300']They already have a punishment system for abuse.[/quote]... and his his name is Valik.[/quote]www.minikori.com

Link to comment
Share on other sites

AutoIt doesn't provide support for user modifiable runtime execution. You'd need to set up some kind of plugin system which can't be implemented via includes. Dlls are perfect for this.

I have little to no knowledge as far as Dlls go, are you saying use Dlls to read the plugins or make Dlls for them or what?

For those who are asking questions, look in the help file first. I'm tired of people asking stupid questions about how to do things when 10 seconds in the help file could solve their problem.[quote name='JRowe' date='24 January 2010 - 05:58 PM' timestamp='1264381100' post='766337'][quote name='beerman' date='24 January 2010 - 03:28 PM' timestamp='1264372082' post='766300']They already have a punishment system for abuse.[/quote]... and his his name is Valik.[/quote]www.minikori.com

Link to comment
Share on other sites

Depending on your use, you could just have the script-able plug-ins (as AutoIt scripts) in a folder and use Execute() to run them.

WARNING: Using Execute on the contents of files that the user could potentially modify could be dangerous!

You could avoid this issue altogether by creating the script to generate a plugins include file, and running it (separately) before you compile. You can even create a custom compile step using (i believe) #AutoIt3Wrapper_Run_Before

_________[u]UDFs[/u]_________-Mouse UDF-Math UDF-Misc Constants-Uninstaller Shell

Link to comment
Share on other sites

Depending on your use, you could just have the script-able plug-ins (as AutoIt scripts) in a folder and use Execute() to run them.

The plugin .au3s use variables in the main script, so I can't just execute them.

You could avoid this issue altogether by creating the script to generate a plugins include file, and running it (separately) before you compile. You can even create a custom compile step using (i believe) #AutoIt3Wrapper_Run_Before

That's what I'm already doing, which still poses the problem Richard Robertson pointed out.

For those who are asking questions, look in the help file first. I'm tired of people asking stupid questions about how to do things when 10 seconds in the help file could solve their problem.[quote name='JRowe' date='24 January 2010 - 05:58 PM' timestamp='1264381100' post='766337'][quote name='beerman' date='24 January 2010 - 03:28 PM' timestamp='1264372082' post='766300']They already have a punishment system for abuse.[/quote]... and his his name is Valik.[/quote]www.minikori.com

Link to comment
Share on other sites

That's what I'm already doing, which still poses the problem Richard Robertson pointed out.

Well then distribute your script in source form then. If your users can't install AutoIt, you could distribute the interpreter or compiler with your app.
Link to comment
Share on other sites

Well then distribute your script in source form then. If your users can't install AutoIt, you could distribute the interpreter or compiler with your app.

That's what I'm doing for now, but I'd like a compilable version when it gets farther along.

For those who are asking questions, look in the help file first. I'm tired of people asking stupid questions about how to do things when 10 seconds in the help file could solve their problem.[quote name='JRowe' date='24 January 2010 - 05:58 PM' timestamp='1264381100' post='766337'][quote name='beerman' date='24 January 2010 - 03:28 PM' timestamp='1264372082' post='766300']They already have a punishment system for abuse.[/quote]... and his his name is Valik.[/quote]www.minikori.com

Link to comment
Share on other sites

It's not clear to me. Do you mean you only know what includes are needed after you compile, or do you simply have a problem compiling a script which uses a variable set of includes?

If the later then it is fairly easy to deal with so I suspect it's the former, but thought I would just check.

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

It's not clear to me. Do you mean you only know what includes are needed after you compile, or do you simply have a problem compiling a script which uses a variable set of includes?

If the later then it is fairly easy to deal with so I suspect it's the former, but thought I would just check.

It's the former, lemme see if I can explain this more:

When a user puts a .au3 file in the addons folder and runs my program, the program sees what files are in the folder, and includes them. It then calls the function that is the name of the addon file (ie "notes.au3," it would call Notes()). But when I compile a script, the includes are compiled with it, so I can't have included files that vary.

For those who are asking questions, look in the help file first. I'm tired of people asking stupid questions about how to do things when 10 seconds in the help file could solve their problem.[quote name='JRowe' date='24 January 2010 - 05:58 PM' timestamp='1264381100' post='766337'][quote name='beerman' date='24 January 2010 - 03:28 PM' timestamp='1264372082' post='766300']They already have a punishment system for abuse.[/quote]... and his his name is Valik.[/quote]www.minikori.com

Link to comment
Share on other sites

It's the former, lemme see if I can explain this more:

When a user puts a .au3 file in the addons folder and runs my program, the program sees what files are in the folder, and includes them. It then calls the function that is the name of the addon file (ie "notes.au3," it would call Notes()). But when I compile a script, the includes are compiled with it, so I can't have included files that vary.

But until the program is compiled with the includes that the user selects, the function cannot be called obviously, so couldn't you just have 2 scripts. One is what the user sees and lets him choose the files, the other is compiled using a command in the script which sets all the incudes. Then to call the function you just run the second script with the parameters required. Is that possible?

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

But until the program is compiled with the includes that the user selects, the function cannot be called obviously, so couldn't you just have 2 scripts. One is what the user sees and lets him choose the files, the other is compiled using a command in the script which sets all the incudes. Then to call the function you just run the second script with the parameters required. Is that possible?

Yes but not simple. The user may be getting/deleting new addons really often, so it'd be a pain for them to have to do that every time they add or remove an addon.

For those who are asking questions, look in the help file first. I'm tired of people asking stupid questions about how to do things when 10 seconds in the help file could solve their problem.[quote name='JRowe' date='24 January 2010 - 05:58 PM' timestamp='1264381100' post='766337'][quote name='beerman' date='24 January 2010 - 03:28 PM' timestamp='1264372082' post='766300']They already have a punishment system for abuse.[/quote]... and his his name is Valik.[/quote]www.minikori.com

Link to comment
Share on other sites

Yes but not simple. The user may be getting/deleting new addons really often, so it'd be a pain for them to have to do that every time they add or remove an addon.

So then you must be running the extra function au3 files as separate scripts. I thought you were trying to include them in your original script somehow and you wanted a compiled result.

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

So then you must be running the extra function au3 files as separate scripts. I thought you were trying to include them in your original script somehow and you wanted a compiled result.

As I stated earlier, they can't be ran as separate scripts because they use variables in the main script. Richard Robertson, I still don't get what you meant to do with dlls, could you elaborate on that?

For those who are asking questions, look in the help file first. I'm tired of people asking stupid questions about how to do things when 10 seconds in the help file could solve their problem.[quote name='JRowe' date='24 January 2010 - 05:58 PM' timestamp='1264381100' post='766337'][quote name='beerman' date='24 January 2010 - 03:28 PM' timestamp='1264372082' post='766300']They already have a punishment system for abuse.[/quote]... and his his name is Valik.[/quote]www.minikori.com

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