Member Avatar

I am string to convert a string to a constant as the StringChangeEx function takes the second argument as a const but i have it as a string and am unsure how to get this function working as i am new to pascal.

The problem is in the BackupFile function when calling the StringChangeEx function.

#define Name "Misery Mod"
#define Description "Misery Mod Installer"
#define Version "2.0"
#define Author "Misery Mod Development Team"
#define Website "http://miserymod.com"
#define Support "support@miserymod.com"
#define Copyright "Copyright [c] 2013 Misery Mod. All Rights Reserved."
#define Executable "Stalker-COP.exe"

[Setup]
AppId={{6423E48F-04F4-4E99-9420-FDD9165A6A90}
AppName={#Name}
AppVersion={#Version}
AppVerName={#Name} {#Version}
AppPublisher={#Author}
AppPublisherURL={#Website}
AppSupportURL={#Website}
AppUpdatesURL={#Website}
AppContact={#Support}
AppComments={#Description}
AppCopyright={#Copyright}

DefaultDirName={code:DetectIP}
DirExistsWarning=no
OutputDir=debug
OutputBaseFilename=mm2-installer

Compression=lzma2/ultra64
SolidCompression=yes
InternalCompressLevel=ultra
CompressionThreads=2

VersionInfoVersion={#Version}
VersionInfoCompany={#Author}
VersionInfoDescription={#Description}
VersionInfoTextVersion={#Name} {#Version}
VersionInfoCopyright={#Copyright}
VersionInfoProductName={#Name}
VersionInfoProductVersion={#Version}
VersionInfoProductTextVersion={#Name} {#Version}

DiskSpanning=True
DiskSliceSize=1566000000
SlicesPerDisk=1

MinVersion=0,5.01
SetupIconFile=C:\Users\Nathaniel\Desktop\MM2\mm2.ico
UninstallDisplayIcon={uninstallexe}
ShowTasksTreeLines=True
AlwaysShowGroupOnReadyPage=True
AlwaysShowDirOnReadyPage=True
LicenseFile=C:\Users\Nathaniel\Desktop\MM2\agreement.rtf
WizardImageFile=C:\Users\Nathaniel\Desktop\MM2\mm2-sidebar.bmp
WizardSmallImageFile=C:\Users\Nathaniel\Desktop\MM2\mm2-header.bmp
AllowCancelDuringInstall=False
DisableProgramGroupPage=yes
UninstallDisplayName={#Name}

[Run]
Filename: {app}\{#Executable}; Description: {cm:LaunchProgram, {#Name}}; Flags: nowait postinstall skipifsilent unchecked
Filename: {#Website}; Description: {cm:VisitWebsite, {#Name}}; Flags: nowait shellexec postinstall skipifsilent unchecked

[CustomMessages]
LaunchProgram=Enter the Wasteland.
VisitWebsite=Visit {#Website}.

[Languages]
Name: "English"; MessagesFile: "compiler:Default.isl"
Name: "Ukrainian"; MessagesFile: "compiler:Languages\Ukrainian.isl"

[Dirs]
Name: "{app}\_mm2"

[Files]
Source: "C:\Users\Nathaniel\Misery Mod v2.0\gamedata\anims\*"; DestDir: {app}; Flags: ignoreversion createallsubdirs recursesubdirs; BeforeInstall: BackupFile

[Code]
var Base:String;
var Backup:String;

function DetectIP(Path:String): string;

var Steam:String;
var Retail:String;

Begin

    Base:=ExpandConstant('{pf}')+'\';
    Steam:=ExpandConstant('{pf}')+'\Steam\SteamApps\common\Stalker Call of Pripyat';
    Retail:=ExpandConstant('{pf}')+'\Steam\SteamApps\common\Stalker Call of Pripyat';

    Begin
        if DirExists(Steam) then
            Base:=Steam;
    End;

    Begin
        if DirExists(Retail) then
            Base:=Retail;
    End;

    Result:=Base;

End;

procedure BackupFile();

var Folder:String;
var File:String;

Begin

    Folder:=ExpandConstant(ExtractFilePath(CurrentFileName));
    File:=ExpandConstant(CurrentFileName);

    Backup:=StringChangeEx(Folder, Base, Base+'_mm2\', False);

    MsgBox(Folder, mbInformation, MB_OK);

    Begin
        if not DirExists(Backup) then
            CreateDir(Backup);
    End;

End;

Any help would be great as i am trying to build a better installer for everyone's favorite S.T.A.L.K.E.R mod.

Recommended Answers

What line in the above code are you talking about? 116?

What is the function parameter definition for StringChangeEx?

Jump to Post

Do you get an error then? Your code looks fine to me?

Jump to Post

Not sure. I don't think you can define a const the way you assign Base.

What's the error?

Jump to Post

All 10 Replies

What line in the above code are you talking about? 116?

What is the function parameter definition for StringChangeEx?

Do you get an error then? Your code looks fine to me?

Member Avatar

As far as i am aware the error is caused by the second argument not being a const but i am not sure how to cast it as one or update my code to change Base and Backup to const without breaking it.

Not sure. I don't think you can define a const the way you assign Base.

What's the error?

Member Avatar
Compiler Error!
Line 116: Column 62: Type mismatch.

Which looks as though i was right with my assumtions. Could you show me an example on how to change my code so that it uses consts instead of strings?.

A const is just defined like this:

const 
  Base = 'my string constant';

But I'm not sure that this works:

const
  Base = ExpandConstant('{pf}') + '\';
Member Avatar
Compiler Error!
Line 89: Column 5: Identifier expected.

Thanks, your right about that not working, thats what i get now...

I think your best bet now is at the INNO forums/newsgroup.

Member Avatar

Posted but it doesn't seem too active so i might not get a reply.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.21 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.