Identifier expected
Your code would be correct in a Pascal, but it does not compile in Pascal Script.
In Pascal, when you want to assign a return value of a function, you either assign the value to a “variable” with a name of the function or to Result
variable.
So this is correct:
function GetRoot: string;
begin
GetRoot := ROOTPage.Values[0];
end;
And this too (both are equivalent):
function GetRoot: string;
begin
Result := ROOTPage.Values[0];
end;
In the Pascal Script, only the Result
works. When you use the name of the function, you get the “Identifier expected.”
Invalid prototype
You get this when the function is called from outside of the Code
section and a specific parameter list/return value is required. But you didn’t tell us, what you use the GetRoot
function for.
There are two places, where you can use a custom function in Inno Setup:
-
Check
parameter: For this the function must return aBoolean
and take either no parameter or one parameter (the parameter type is determined by a value you provide in theCheck
parameter).function MyProgCheck(): Boolean; function MyDirCheck(DirName: String): Boolean;
-
Scripted Constants: The function must return a
string
and take onestring
parameter, even if no parameter is provided in the scripted constant. I assume this is your use case. If you do not need any parameter, just declare it, but do not use it:function GetRoot(Param: String): string; begin Result := ROOTPage.Values[0]; end;