Here are examples from the #emit
directive documentation:
[Files] #emit 'Source: "file1.ext"; DestDir: {' + MyDestDir + '}' Source: "file2.ext"; DestDir: {#MyDestDir} #emit GenerateVisualCppFilesEntries ; user defined function
In the first line I don't understand the DestDir
part. Looks like the #
symbol is missing there.
I understand the second line. But why do we need to use the #emit
directive like in line 1 anyway?
Inno Setup preprocessor directives can be invoked using two syntaxes.
A basic syntax:
#directive params
And an inline syntax:
{#directive params}
On top of that, the #emit
directive is the default inline directive, assumed, when no explicit directive name is specified.
So these three are equivalent:
#emit MyDestDir
{#emit MyDestDir}
{#MyDestDir}
Though the first does not make sense with a path variable, as it would result in invalid script syntax – but it can be used with a variable that contains a valid script syntax:
#define FileSectionEntry 'Source: ' + MySource + '; DestDir: ' + MyDestDir
#emit FileSectionEntry
While the other two inline examples can make sense, but only with other code on the same line, like in the code from your question:
Source: "file2.ext"; DestDir: {#MyDestDir}
Additionally an #emit
with a (string) constant is basically pointless, as you can achieve the same without preprocessor.
These three are equivalent:
Source: "file2.ext"; DestDir: "{app}"
#emit 'Source: "file2.ext"; DestDir: "{app}"'
{#'Source: "file2.ext"; DestDir: "{app}"'}
So getting back to the code in your script, these are (almost) equivalent:
#emit 'Source: "file1.ext"; DestDir: {' + MyDestDir + '}'
Source: "file1.ext"; DestDir: {#MyDestDir}
The only problem is that I believe the curly brackets in the first line should not be there. The line should be:
#emit 'Source: "file1.ext"; DestDir: ' + MyDestDir
I have submitted a fix for this. It's basically another copy of the typo from your previous question: Why is there an additional pair of curly braces on the Inno Setup Preprocessor:#emit page?