The macros ParseVersion
and RemoveBackslash
, for example, are both declared in ISPPBuiltins.iss
. If I attempt to call both from within [Code]:
function InitializeSetup: Boolean;
var
Major, Minor, Rev, Build: Integer;
begin
RemoveBackslash('123\');
ParseVersion('12345', Major, Minor, Rev, Build);
end;
RemoveBackslash
compiles fine, but adding ParseVersion
causes a compiler error:
Unknown identifier 'ParseVersion'"
When part of another macro declaration, ParseVersion
seems to compile fine, just not from [Code]
. Should I be able call it like that?
As @Andrew wrote already, the ParseVersion
(or actually since Inno Setup 6.1, the GetVersionComponents
) is a preprocessor function. So it has to be called using preprocessor directives and its results stored into preprocessor variables.
#define Major
#define Minor
#define Rev
#define Build
#expr GetVersionComponents("C:\path\MyProg.exe", Major, Minor, Rev, Build)
If you need to use the variables in the Pascal Script Code
, you again need to use preprocessor syntax. For example:
[Code]
function InitializeSetup: Boolean;
begin
MsgBox('Version is: {#Major}.{#Minor}.{#Rev}.{#Build}.', mbInformation, MB_OK);
Result := True;
end;
The above is true, if you really want to extract the version numbers on the compile-time. If you actually want to do it in the Code
section, i.e. on the install-time, you have to use Pascal Script support function GetVersionComponents
(yes, the same name, but a different language):
[Code]
function InitializeSetup: Boolean;
var
Major, Minor, Rev, Build: Word;
Msg: string;
begin
GetVersionComponents('C:\path\MyProg.exe', Major, Minor, Rev, Build);
Msg := Format('Version is: %d.%d.%d.%d', [Major, Minor, Rev, Build]);
MsgBox(Msg, mbInformation, MB_OK);
Result := True;
end;
The Pascal Script function GetVersionComponents
is available since Inno Setup 6.1 only.
The RemoveBackslash
works in both contexts, as there's both Pascal Script RemoveBackslash
and Preprocessor RemoveBackslash
.
In the Change Log (for 6.1.x) it mentioned:
Support function
GetFileVersion
andParseVersion
have been renamed toGetVersionNumbersString
andGetVersionComponents
respectively. The old names are still supported, but it is recommended to update your scripts to the new names and the compiler will issue a warning if you don't.
So be wary of that when you upgrade. But as you rightly say, these are Inno Setup Preprocessor (ISPP) functions. With respects to the Pascal Script section there is nothing listed in the Support Function Reference.
Someone else might be able to shed more insight about this, or offer a workaround, but you might have to request the feature in the Info Setup forum.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With