Using CustomMessages in [CODE] section

32 views
Skip to first unread message

Eric Gambert

unread,
Sep 25, 2025, 4:42:18 AM (yesterday) Sep 25
to innosetup

Hello everyone,

I'm using a custom page to obtain a hostname (usable via the installation wizard or via a response file).

For translation purposes, is it possible to use custom messages in a function in the [CODE] section?

The [CustomMessages] uses an #include external file.

This code compiles without any issue but generates an internal error at Runtime.



var
...
ServerHostPage : TInputQueryWizardPage;

Procedure InitializeWizard;
Var
InfFile: string;
...
Begin
   ServerHostPage := CreateInputQueryPage(DataDirPage.ID ,
    ExpandConstant('{cm:ServerHostPageTitle}'),
    ExpandConstant('{cm:ServerHostSubTitle}'),
    ExpandConstant('{cm:ServerHostDesc}');
   
    ServerHostPage.add('{cm:ServerHostPageTitle}', False);
     InfFile := ExpandConstant('{param:LOADINF}');
     if InfFile<>'' then
    ServerHostPage.Values[0] :=GetIniString('Custom', 'ServerHostName', '', ExpandFileName(InfFile));
End;


InternalError.jpg


I miss something or is it just not possible?

Thank you in advance.

Inno Setup Compiler version 6.2.2

Jernej Simončič

unread,
Sep 25, 2025, 5:03:25 AM (yesterday) Sep 25
to Eric Gambert on [innosetup]

On Thursday, September 25, 2025, 10:42:17, Eric Gambert wrote:


I miss something or is it just not possible?

The error is telling you that ServerHostPageTitle custom message isn't defined anywhere.

 

Also, instead of using ExpandConstant('{cm:Foo}') you can use CustomMessage('Foo').

 

-- 
< Jernej Simončič ><><><><>< https://eternallybored.org/ >


There's always one more bug.
       -- Lubarsky's Law of Cybernetic Entomology

Eric Gambert

unread,
Sep 25, 2025, 5:20:10 AM (yesterday) Sep 25
to inno...@googlegroups.com

Got my mistake : no external files for CustomMessages to be used in [CODE], they have to be in the Script.
image.png

Also thank you for the hint Jernej.

Greetings

--
You received this message because you are subscribed to the Google Groups "innosetup" group.
To unsubscribe from this group and stop receiving emails from it, send an email to innosetup+...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/innosetup/84833034.20250925110317%40eternallybored.org.

Martijn Laan

unread,
Sep 25, 2025, 10:47:54 AM (23 hours ago) Sep 25
to innosetup
Hi,

Op 25-9-2025 om 11:19 schreef Eric Gambert:
Got my mistake : no external files for CustomMessages to be used in [CODE], they have to be in the Script.

It's good to hear that your problem is resolved. However, what you wrote above is not correct. You can definitely have custom messages in an included file and still use them in [Code].

There must be something else that was fixed when you moved them. 

Greetings,
Martijn

Eric Gambert

unread,
Sep 25, 2025, 11:32:52 AM (22 hours ago) Sep 25
to innosetup
Hello,

I have done a revert to test again, but still get the error if these particular CustomMessages are not included in the .iss
I will ask a collegue tomorrow.

I take the Opportunity to thank you and all contributors of this forum. 

Greetings.
Reply all
Reply to author
Forward
0 new messages