livingsamurai
livingsamurai

Reputation: 13

How to make empty lines in the created INI file during installation in Inno Setup?

The fact is that the text I have goes one after the other:

[Nancy Data]
CDDrive1=C:
CDDrive2=C:
HDDrive=C:
IDPath=\Program Files (x86)\My Program\Нэнси Дрю. Секреты могут убивать
CifTreePath=\Program Files (x86)\My Program\Нэнси Дрю. Секреты могут убивать\ciftree\
HDVideoPath=\Program Files (x86)\My Program\Нэнси Дрю. Секреты могут убивать\HDVideo\
CDVideoPath=\Program Files (x86)\My Program\Нэнси Дрю. Секреты могут убивать\CDVideo\
HDSoundPath=\Program Files (x86)\My Program\Нэнси Дрю. Секреты могут убивать\HDSound\
CDSoundPath=\Program Files (x86)\My Program\Нэнси Дрю. Секреты могут убивать\CDSound\
LoadSavePath=\Program Files (x86)\My Program\Нэнси Дрю. Секреты могут убивать\Save\
RunEntirelyFromCDDrive=0                ; 1=run all app from cdrom, 0=run normal
CifTreeAndFilesOnCD=0                   ; 1=all cif/tree files on CDROM, 0=tree on hard drive
TestingModeEnabled=0                    ; 1=enable test-only mode, 0=not enabled
ExternalCifFileChecking=1               ; 1=look for cif files external to tree, 0=don't look
DebugOutput=1                           ; 1=enable debug output (huge), 0=not enabled
RunInWindowedMode=0                     ; 1=run in a window, 0=run full-screen exclusive mode
MaxXAxisTravelPerMove=195               ; max x travel per render loop
MaxYAxisTravelPerMove=150               ; max y travel per render loop
SoundSystemIsActive=1           ; 1=sound, 0=no sound
ForceSoundBufSize=0         ; 0=use default, 1=force size
SoundBufSize=4096           ; size used if forced
SoundBufSkip=6              ; raise if sound skips, lower if video not synching
UseDirectSound=1            ; 0=MME, 1=DirectSound
ClosedCaptioning=1
PlayerSpeech=1
CharacterSpeech=1
VoiceMasterVolume=54
MusicMasterVolume=54
SpecialEffectsMasterVolume=51
SwapLeftAndRightSoundChannels=0
PrimaryVideoNonSoundTimeDelay=300
PrimaryVideoNonSoundFrameTime=66
SystemQualityForPrimaryVideo=0
InstallationType=0
PlayerWonTheGame=StillWorkingOnIt
; 640x480 aspect=1.33 : 1

And I need to format the INI file by inserting empty lines between key groups:

[Nancy Data]

CDDrive1=E:\
CDDrive2=E:\
HDDrive=E:

IDPath=\games\Нэнси Дрю. Секреты могут убивать
CifTreePath=\games\Нэнси Дрю. Секреты могут убивать\ciftree\
HDVideoPath=\games\Нэнси Дрю. Секреты могут убивать\HDVideo\
CDVideoPath=\games\Нэнси Дрю. Секреты могут убивать\CDVideo\
HDSoundPath=\games\Нэнси Дрю. Секреты могут убивать\HDSound\
CDSoundPath=\games\Нэнси Дрю. Секреты могут убивать\CDSound\
LoadSavePath=\games\Нэнси Дрю. Секреты могут убивать\Save\

RunEntirelyFromCDDrive=0                ; 1=run all app from cdrom, 0=run normal
CifTreeAndFilesOnCD=0                   ; 1=all cif/tree files on CDROM, 0=tree on hard drive
TestingModeEnabled=0                    ; 1=enable test-only mode, 0=not enabled
ExternalCifFileChecking=1               ; 1=look for cif files external to tree, 0=don't look
DebugOutput=1                           ; 1=enable debug output (huge), 0=not enabled
RunInWindowedMode=0                     ; 1=run in a window, 0=run full-screen exclusive mode

; 640x480 aspect=1.33 : 1
MaxXAxisTravelPerMove=195               ; max x travel per render loop
MaxYAxisTravelPerMove=150               ; max y travel per render loop

SoundSystemIsActive=1           ; 1=sound, 0=no sound
ForceSoundBufSize=0         ; 0=use default, 1=force size
SoundBufSize=4096           ; size used if forced
SoundBufSkip=6              ; raise if sound skips, lower if video not synching
UseDirectSound=1            ; 0=MME, 1=DirectSound

ClosedCaptioning=1
PlayerSpeech=1
CharacterSpeech=1

VoiceMasterVolume=54
MusicMasterVolume=54
SpecialEffectsMasterVolume=51
SwapLeftAndRightSoundChannels=0

PrimaryVideoNonSoundTimeDelay=300
PrimaryVideoNonSoundFrameTime=66

SystemQualityForPrimaryVideo=0
InstallationType=0
PlayerWonTheGame=StillWorkingOnIt

I am creating an INI file using the INI section:

[INI]
Filename: "{app}\game.ini"; Section: "Nancy Data"; Key: "CDDrive1"; String: "{drive:{src}}"; Flags: createkeyifdoesntexist
Filename: "{app}\game.ini"; Section: "Nancy Data"; Key: "CDDrive2"; String: "{drive:{src}}"; Flags: createkeyifdoesntexist
Filename: "{app}\game.ini"; Section: "Nancy Data"; Key: "HDDrive"; String: "{drive:{src}}"; Flags: createkeyifdoesntexist

Filename: "{app}\game.ini"; Section: "Nancy Data"; Key: "IDPath"; \
  String: "{code:RemoveDrive|{app}\Нэнси Дрю. Секреты могут убивать}"; \
  Flags: createkeyifdoesntexist
Filename: "{app}\game.ini"; Section: "Nancy Data"; Key: "CifTreePath"; \
  String: "{code:RemoveDrive|{app}\Нэнси Дрю. Секреты могут убивать\ciftree\}"; \
  Flags: createkeyifdoesntexist
Filename: "{app}\game.ini"; Section: "Nancy Data"; Key: "HDVideoPath"; \
  String: "{code:RemoveDrive|{app}\Нэнси Дрю. Секреты могут убивать\HDVideo\}"; \
  Flags: createkeyifdoesntexist
Filename: "{app}\game.ini"; Section: "Nancy Data"; Key: "CDVideoPath"; \
  String: "{code:RemoveDrive|{app}\Нэнси Дрю. Секреты могут убивать\CDVideo\}"; \
  Flags: createkeyifdoesntexist
Filename: "{app}\game.ini"; Section: "Nancy Data"; Key: "HDSoundPath"; \
  String: "{code:RemoveDrive|{app}\Нэнси Дрю. Секреты могут убивать\HDSound\}"; \
  Flags: createkeyifdoesntexist
Filename: "{app}\game.ini"; Section: "Nancy Data"; Key: "CDSoundPath"; \
  String: "{code:RemoveDrive|{app}\Нэнси Дрю. Секреты могут убивать\CDSound\}"; \
  Flags: createkeyifdoesntexist
Filename: "{app}\game.ini"; Section: "Nancy Data"; Key: "LoadSavePath"; \
  String: "{code:RemoveDrive|{app}\Нэнси Дрю. Секреты могут убивать\Save\}"; \
  Flags: createkeyifdoesntexist

Filename: "{app}\game.ini"; Section: "Nancy Data"; Key: "RunEntirelyFromCDDrive"; String: "0                ; 1=run all app from cdrom, 0=run normal"; Flags: createkeyifdoesntexist
Filename: "{app}\game.ini"; Section: "Nancy Data"; Key: "CifTreeAndFilesOnCD"; String: "0                   ; 1=all cif/tree files on CDROM, 0=tree on hard drive"; Flags: createkeyifdoesntexist
Filename: "{app}\game.ini"; Section: "Nancy Data"; Key: "TestingModeEnabled"; String: "0                    ; 1=enable test-only mode, 0=not enabled"; Flags: createkeyifdoesntexist
Filename: "{app}\game.ini"; Section: "Nancy Data"; Key: "ExternalCifFileChecking"; String: "1               ; 1=look for cif files external to tree, 0=don't look"; Flags: createkeyifdoesntexist
Filename: "{app}\game.ini"; Section: "Nancy Data"; Key: "DebugOutput"; String: "1                           ; 1=enable debug output (huge), 0=not enabled"; Flags: createkeyifdoesntexist
Filename: "{app}\game.ini"; Section: "Nancy Data"; Key: "RunInWindowedMode"; String: "0                     ; 1=run in a window, 0=run full-screen exclusive mode"; Flags: createkeyifdoesntexist

Filename: "{app}\game.ini"; Section: "Nancy Data"; Key: "; 640x480 aspect"; String: "1.33 : 1"; Flags: createkeyifdoesntexist
Filename: "{app}\game.ini"; Section: "Nancy Data"; Key: "MaxXAxisTravelPerMove"; String: "195               ; max x travel per render loop"; Flags: createkeyifdoesntexist
Filename: "{app}\game.ini"; Section: "Nancy Data"; Key: "MaxYAxisTravelPerMove"; String: "150               ; max y travel per render loop"; Flags: createkeyifdoesntexist

Filename: "{app}\game.ini"; Section: "Nancy Data"; Key: "SoundSystemIsActive"; String: "1           ; 1=sound, 0=no sound"; Flags: createkeyifdoesntexist
Filename: "{app}\game.ini"; Section: "Nancy Data"; Key: "ForceSoundBufSize"; String: "0         ; 0=use default, 1=force size"; Flags: createkeyifdoesntexist
Filename: "{app}\game.ini"; Section: "Nancy Data"; Key: "SoundBufSize"; String: "4096           ; size used if forced"; Flags: createkeyifdoesntexist
Filename: "{app}\game.ini"; Section: "Nancy Data"; Key: "SoundBufSkip"; String: "6              ; raise if sound skips, lower if video not synching"; Flags: createkeyifdoesntexist
Filename: "{app}\game.ini"; Section: "Nancy Data"; Key: "UseDirectSound"; String: "1            ; 0=MME, 1=DirectSound"; Flags: createkeyifdoesntexist

Filename: "{app}\game.ini"; Section: "Nancy Data"; Key: "ClosedCaptioning"; String: "1"; Flags: createkeyifdoesntexist
Filename: "{app}\game.ini"; Section: "Nancy Data"; Key: "PlayerSpeech"; String: "1"; Flags: createkeyifdoesntexist
Filename: "{app}\game.ini"; Section: "Nancy Data"; Key: "CharacterSpeech"; String: "1"; Flags: createkeyifdoesntexist

Filename: "{app}\game.ini"; Section: "Nancy Data"; Key: "VoiceMasterVolume"; String: "54"; Flags: createkeyifdoesntexist
Filename: "{app}\game.ini"; Section: "Nancy Data"; Key: "MusicMasterVolume"; String: "54"; Flags: createkeyifdoesntexist
Filename: "{app}\game.ini"; Section: "Nancy Data"; Key: "SpecialEffectsMasterVolume"; String: "51"; Flags: createkeyifdoesntexist
Filename: "{app}\game.ini"; Section: "Nancy Data"; Key: "SwapLeftAndRightSoundChannels"; String: "0"; Flags: createkeyifdoesntexist

Filename: "{app}\game.ini"; Section: "Nancy Data"; Key: "PrimaryVideoNonSoundTimeDelay"; String: "300"; Flags: createkeyifdoesntexist
Filename: "{app}\game.ini"; Section: "Nancy Data"; Key: "PrimaryVideoNonSoundFrameTime"; String: "66"; Flags: createkeyifdoesntexist

Filename: "{app}\game.ini"; Section: "Nancy Data"; Key: "SystemQualityForPrimaryVideo"; String: "0"; Flags: createkeyifdoesntexist
Filename: "{app}\game.ini"; Section: "Nancy Data"; Key: "InstallationType"; String: "0"; Flags: createkeyifdoesntexist
Filename: "{app}\game.ini"; Section: "Nancy Data"; Key: "PlayerWonTheGame"; String: "StillWorkingOnIt"; Flags: createkeyifdoesntexist

I found the Format function with this example:

var
  S: String;
  I: Integer;
begin
  S := Format('%d files found', [10]);
  // S = '10 files found'

  S := Format('Filename: %s', ['file.txt']);
  // S = 'Filename: file.txt'

  I := 64;
  S := Format('%d in hex, padded to 8 digits: %.8x', [I, I]);
  // S = '64 in hex, padded to 8 digits: 00000040'
end;

But I didn't understand how I could use it.

Upvotes: 0

Views: 157

Answers (1)

Martin Prikryl
Martin Prikryl

Reputation: 202108

While you didn't even told us, I assume that you use [INI] section to create your INI file. As empty lines have no meaning in INI file, neither does Windows INI file API have any means to add empty lines (and consequently neither does Inno Setup API, which is build on top of Windows API).

If you want to make custom modifications to the INI file, you have to treat it as an unstructured text file, not as an INI file.

For some examples, see:


Another thing that you can do, if you are creating a new INI file, is to deploy a template INI file with the formatting you want to achieve. And then use the [INI] section to only modify the keys.

[Files]
; Deploy INI file template
Source: "config.ini"; DestDir: "{app}"

[INI]
; Modify the key values, which are determined during installation only
Filename: "{app}\config.ini"; Section: "Section"; Key: "Key"; \
    String: "{code:GetValue}";

Upvotes: 1

Related Questions