tannerli Posted May 13, 2007 Share Posted May 13, 2007 Hi, i want to define a file name at the beginnig of the code wich is later used as the first argument of FileInstall(). Is there a way to do that, maybe with a preprocessor constant (like f.e. #define in C)? Thanks for your replys tannerli Link to comment Share on other sites More sharing options...
PsaltyDS Posted May 13, 2007 Share Posted May 13, 2007 Hi,i want to define a file name at the beginnig of the code wich is later used as the first argument of FileInstall(). Is there a way to do that, maybe with a preprocessor constant (like f.e. #define in C)?Thanks for your replystannerliFrom the help file under FileInstall():The source path of the file to compile. This must be a literal string; it cannot be a variable.From Valik in the AutoIt Feature Requests sticky:FileInstall() accepting variables for the source: The source file used in a FileInstall() statement must be known at compile time. Variables are not evaluated until run-time. Changing this behavior makes no sense and will not be done.Shhhh! ...and don't let Valik hear you... he's kinda cranky and will treat you like the bad orange you are... Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
tannerli Posted May 13, 2007 Author Share Posted May 13, 2007 ... do you know what a preprocessor's job is? preprocessor constants are replaced by their value before the source code is beeing compiled. For the compiler, the value looks like a literal (string). preprocessor constants ARE known at compile time! look at this example in C: #include <stdio.h> #define VALUE 2350 void main() { printf("%d",VALUE); return; } after the preprocessor has parsed the source file, the compiler "sees" the code like this: void main() { printf("%d", 2350); return; } (i don't posted the content of stdio.h ) the topic is only to make the code better readable, what i want is to define the filename at the beginng of the code so its easy to change it - i don't want to use a variable wich can be changed at runtime! that's impossible and doesn't make any sense .... Link to comment Share on other sites More sharing options...
xcal Posted May 13, 2007 Share Posted May 13, 2007 ...what i want is to define the filename at the beginng of the code so its easy to change it...How many times will you need to FileInstall() the same file in a script? How To Ask Questions The Smart Way Link to comment Share on other sites More sharing options...
PsaltyDS Posted May 13, 2007 Share Posted May 13, 2007 I see what you mean, and understood that before. Not being an AutoIt developer, or even a programmer, I don't claim to speak for them (or, Heaven fordid, Valik). But I think their point would be that since changing that preprocessor value requires editing the source file anyway, why can't you just edit it with the current value you want in a literal string. Since AutoIt is a scripting language, and "compile" is really too strong a word for what it does (compressing the expanded script in a file with the interpreter is more like it) maybe it would more appropriate to speak of a "preprocessor" script of your own that you run against your source .au3 file and makes logic based changes to the lines with the FileInstall() statement(s): #include <file.au3> $Current_Install_File = "FileInstall(" & @ScriptDir & "\MyDataFile_" & @YEAR & @MON & @MDAY & ")" $Source_File = @ScriptDir & "\TodaysScriptSrc.au3" $Destination_File = @ScriptDir & "\TodaysScriptDest.au3" _ReplaceStringInFile($Source_File, "FileInstall()", $Current_Install_File) MsgBox(64, "Preprocessor", "You may now compile today's script...") Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
tannerli Posted May 13, 2007 Author Share Posted May 13, 2007 maybe it would more appropriate to speak of a "preprocessor" script of your own that you run against your source .au3 file and makes logic based changes to the lines with the FileInstall() statement(s):yeah, you're right. I just had the same idea, but i thougt perhaps there is an easier way to this thanks anyway Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now