FileInstall - error in help file?

Recommended Posts

Angel 0

Angel 0

I am trying to use FileInstall to add some files to an executable. The problem is that it seems to be an error in the documentation.

The FileInstall function is supposed to have up to 3 arguments. The help file says that the 2nd argument must be a PATH finished with a backslash. BUT the example on the bottom of the help is the following:

FileInstall("C:\test.au3", "D:\mydir\test.au3")

So the 2nd is not a PATH! What must be done?

Also, the help file says that the "source" argument must not be a variable, but a string, in order to let the compiler find the file, which makes sense to me.

However, is it possible to use one of the folder macros like @ScriptDir or @ProgramsDir for instance? This would be very handy as who wants to hard code the "Program Files" folder into the script?

Otherwise, if it does not work, it would be great if at least we could use a "relative" path (or no path at all) and then the compiler would simply look for the file in the script folder (or some other folder relative to it). I think that this would make this function much more useful and easy to use.

Share this post

Link to post

Share on other sites

Angel 0

Angel 0

Nova told me that it was alright to use macros, so I am using a macro, not a variable.

If this is not possible, then I think that it would be a great idea to allow this in the future, as it is so much convenient to include files by using macros like @ProgramsDir, for instance.

At least I've verified that it is possible to use relative paths to include files which are in the same folder as the script. I think that that should be explained in the documentation, as it is not clear enough.

Also, it seems that there is an error in the documentation, as in one part it says that the target is a folder and in another it says that the target is a filename.

Share this post

Link to post

Share on other sites

therks 16

therks 16

Variables and other interpreted values cannot be used in FileInstall because they are not evaluated at compile time. The compiler is not the interpreter, if it sees FileInstall($variable, ...) it doesn't know where to look. And no, it will not be changed, many people have asked and it's not feasible.

Share this post

Link to post

Share on other sites

BrettF 26

BrettF 26

Variables and other interpreted values cannot be used in FileInstall because they are not evaluated at compile time. The compiler is not the interpreter, if it sees FileInstall($variable, ...) it doesn't know where to look. And no, it will not be changed, many people have asked and it's not feasible.

Share this post

Link to post

Share on other sites

MHz 73

MHz 73

Somebody please tell me I'm doing this wrong, and there's a way that I can do this that is much closer to my first version.

Unfortunately, as the others have mentioned about the limitations of FileInstall, you are unable to use the array concept to change the first literal parameter. I would do something closer to the below example as your last attempt looks confusing to me.

Share this post

Link to post

Share on other sites

Swift 0

Swift 0

I wish they could fix that problem, because then I could make a all-around installer. But, theres really no chance for it, because as i've been told, The FileInstall() Is read at compilation time, NOT when the script runs (Which is where the variables are).

Share this post

Link to post

Share on other sites

JustinReno 0

JustinReno 0

I wish they could fix that problem, because then I could make a all-around installer. But, theres really no chance for it, because as i've been told, The FileInstall() Is read at compilation time, NOT when the script runs (Which is where the variables are).

Ensure that $DATA_DIR has a trailing backspace with the declaration or the FileInstall above may fail.

Yeah, it should be confusing, that's what happens when you're a cobol programmer and you're writing java code. I'm carrying the style of another language into AutoIt code. This shall pass, it was only day 2

Here's what I ended up with - added a couple of wrapper functions to reduce repetition.

Share this post

Link to post

Share on other sites

MHz 73

MHz 73

Here's what I ended up with - added a couple of wrapper functions to reduce repetition.

Looks better but notice that FileInstall is hardcoded with a literal string within the PutFile function so you are FileInstalling the same file to different filenames. If that is your original intention then looks good.

Share this post

Link to post

Share on other sites

aGorilla 1

aGorilla 1

Looks better but notice that FileInstall is hardcoded with a literal string within the PutFile function so you are FileInstalling the same file to different filenames. If that is your original intention then looks good.

Shite! Nope, I done broke it again. Need more coffee...

edit: Ok, so I dropped 'PutFile', and reverted to individual FileInstalls. All that damned repetition still makes me want to cry. Such is life.