FileForums

FileForums (https://fileforums.com/index.php)
-   Conversion Tutorials (https://fileforums.com/forumdisplay.php?f=55)
-   -   INNO TROUBLESHOOT - Questions Here (https://fileforums.com/showthread.php?t=93193)

describe19 24-02-2019 18:48

I have another question: I am trying to make an array of strings I have tried this but it doesn't work:
var
MyArray: array [0..2] of string =('cat','dog','man');
Is it possible to declare and initialize an array of strings in such a way?

Razor12911 24-02-2019 20:03

Quote:

Originally Posted by describe19 (Post 479721)
I have another question: I am trying to make an array of strings I have tried this but it doesn't work:
var
MyArray: array [0..2] of string =('cat','dog','man');
Is it possible to declare and initialize an array of strings in such a way?

var
MyArray: array of string;
begin
MyArray := ['cat','dog','man'];

describe19 26-02-2019 04:36

Quote:

Originally Posted by Razor12911 (Post 479723)
var
MyArray: array of string;
begin
MyArray := ['cat','dog','man'];

Thank you! I could not find the proper syntax for inno pascal anywhere! Is there documentation I can learn from?

Razor12911 26-02-2019 06:45

Quote:

Originally Posted by describe19 (Post 479783)
Thank you! I could not find the proper syntax for inno pascal anywhere! Is there documentation I can learn from?

Try this
https://www.tutorialspoint.com/pascal/

KaktoR 25-03-2019 09:12

Anyone knows if there is SuspendProc for ISDone too?

Respectively to pause TimeStr2.

amin fear 09-11-2019 04:50

unarc.dll error code: -12 check sum error
 
I am getting "unarc.dll error code: -12 check sum error" at first percent/% of my setup decompression phase on SOME windows systems using below XTOOL command :

The decompression goes without error on most systems but on a few systems gives "unarc.dll error code: -12 check sum error" , anybody knows some solution for this ? increasing virtual memory does not help ! the system has 16GB Ram + CPU corei5 ,so the problem is not from computer resources , its very odd

Code:

xZLib+srep:m3f+4x4:b128mb:lzma:ultra:64m:bt4:fb273:lc8:mc1000000

Simorq 09-11-2019 06:28

Quote:

Originally Posted by amin fear (Post 483394)
I am getting "unarc.dll error code: -12 check sum error" at first percent/% of my setup decompression phase on SOME windows systems using below XTOOL command :

The decompression goes without error on most systems but on a few systems gives "unarc.dll error code: -12 check sum error" , anybody knows some solution for this ? increasing virtual memory does not help ! the system has 16GB Ram + CPU corei5 ,so the problem is not from computer resources , its very odd

Code:

xZLib+srep:m3f+4x4:b128mb:lzma:ultra:64m:bt4:fb273:lc8:mc1000000

Use XTool 12_x86 for Decompression

and Edit CLS.ini
Code:

[SREP]
Bufsize=24m
transfer_ReadBufSize=512k
transfer_WriteBufSize=512k
Memory=512m
TempPath=.\


Andu21 09-11-2019 13:48

I'm having this error:
Code:

An error ocurred while unpacking: Unable to write data to disk!
Unarc.dll returned an error code: -11
ERROR: archive data corrupted (decompression fails)

What has me puzzled is that it occurs at random: 1%, 16.7%, 30%, sometimes even 40%, if the source was corrupted shouldn't it always fail at the same progress? I tried searching online and found a few methods(defrag, temp delete, increase page file, copy unarc.dll to game dir) with no success.

amin fear 11-11-2019 00:20

Quote:

Originally Posted by Simorq (Post 483395)
Use XTool 12_x86 for Decompression

and Edit CLS.ini
Code:

[SREP]
Bufsize=24m
transfer_ReadBufSize=512k
transfer_WriteBufSize=512k
Memory=512m
TempPath=.\


Thanks Simorq jan , the following error as i mentioned , resolved by pre-installing Visual C++ 2013 by using below CIU config :

Code:

[LauncherSettings]
-------------------------------------------------------
InstallRedist=1

[Launch1]
Name=Visual C++ 2013
64Exe={src}\vcredist_x64_2013.exe
Argument=/q /passive
BeforeInstall=1
Checked=1

First installed Visual C++ 2013 , then unpacking data process started without any problem !

Is "XTool 12_x86" still dependent to Visual C++ 2013 ?

*************************************************

"unarc.dll error code: -12 check sum error" was very deceiving !:):):)
Nobody can guess the cause at first glimpse !

artexjay 13-11-2019 09:00

Inno Uninshs issue
 
Hello all,

I'm quite new to inno setup and new here as well. I have been having trouble with one of inno's addons mainly the uninshs. It's supposed to modify the uninstaller so that it prompts the user if they want to modify, repair or remove the program.

So the issue I'm having is that when i try to uninstall it doesn't do anything it simply closes the uninstaller but no files are removed. I did my best to follow the readme for properly adding it to the inno setup.

My setup simply installs the default inno myprog.exe. Im trying to understand the addons better first. I haven't done any compression tests yet.

This is what i have so far in my code:

Code:

; Script generated by the Inno Script Studio Wizard.
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!

#define MyAppName "My Program"
#define MyAppVersion "1.5"
#define MyAppPublisher "My Company, Inc."
#define MyAppURL "http://www.example.com/"
#define MyAppExeName "MyProg.exe"

[Setup]
; NOTE: The value of AppId uniquely identifies this application.
; Do not use the same AppId value in installers for other applications.
; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
AppId={{413F3F57-3FFB-4B22-B47C-1D9DE9772114}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
;AppVerName={#MyAppName} {#MyAppVersion}
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
DefaultDirName={commonpf}\{#MyAppName}
DefaultGroupName={#MyAppName}
OutputBaseFilename=mysetup
Compression=lzma
SolidCompression=yes
DisableWelcomePage=False
ShowTasksTreeLines=True
WizardResizable = Yes

#define Use_UninsHs_Default_CustomMessages
#include "uninshs.iss"

[Languages]
Name: "english"; MessagesFile: "compiler:Default.isl"

[Tasks]
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked

[Components]
Name: main; Description: "Main"; Types: full compact custom; Flags: fixed

[Files]

Source: "C:\Users\artex\AppData\Local\Programs\Inno Setup 6\Examples\MyProg.exe"; DestDir: "{app}";
; NOTE: Don't use "Flags: ignoreversion" on any shared system files

[Icons]
Name: "{group}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"
Name: "{commondesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon

[Run]
Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: shellexec skipifdoesntexist nowait skipifsilent postinstall;          \
Check: UninsHs_IsInstallation();

[Codes] //change to [Code (in inno)]
{ RedesignWizardFormBegin } // Don't remove this line!
// Don't modify this section. It is generated automatically.
procedure RedesignWizardForm;
begin
  with WizardForm do
  begin
    AutoScroll := False;
    ClientHeight := ScaleY(366);
    ClientWidth := ScaleX(500);
  end;

  with WizardForm.NextButton do
  begin
    Left := ScaleX(388);
    Top := ScaleY(330);
  end;

  with WizardForm.ProgressGauge do
  begin
    Height := ScaleY(13);
  end;

  with WizardForm.CancelButton do
  begin
    Left := ScaleX(32);
    Top := ScaleY(330);
  end;

  with WizardForm.BackButton do
  begin
    Left := ScaleX(300);
    Top := ScaleY(330);
  end;

{ ReservationBegin }
  // This part is for you. Add your specialized code here.

{ ReservationEnd }
end;
// Don't modify this section. It is generated automatically.
{ RedesignWizardFormEnd } // Don't remove this line!

procedure InitializeWizard();
begin
  UninsHs_InitializeWizard();
  RedesignWizardForm;
end;

procedure CurPageChanged(CurPageID: Integer);
begin
  UninsHs_CurPageChanged(CurPageID);
end;

function ShouldSkipPage(CurPageId: Integer): Boolean;
begin
  Result := False;
  UninsHs_ShouldSkipPage(CurPageId, Result);
end;

function NextButtonClick(CurPageID: Integer): Boolean;
begin
  Result := True;
  UninsHs_NextButtonClick(CurPageID, Result);
end;

procedure CancelButtonClick(CurPageID: Integer; var Cancel, Confirm: Boolean);
begin
  UninsHs_CancelButtonClick(CurPageID, Cancel, Confirm);
end;

function InitializeUninstall(): Boolean;
begin
  Result := True;
  UninsHs_InitializeUninstall(Result);
end;

Any help would be appreciated. Thank you

mixtro 04-01-2020 09:28

Sometimes randomly whenever I repack games and extract/install, I receive this error from Lolz:

Can't open read file mapping

Masquerade 10-02-2020 11:12

BPK giving "Required Features Are Not Supported By DLL"
 
I have compressed an archive using Bink Pack (multiple .bik files). Compression is all good (no FreeArc errors) but whenever I feed it to my installer for decompression, I always get the following error:

https://i.imgur.com/vqpLPCL.png

As far as I know, CLS-BPK.DLL is the only way of decompressing files compressed using BPK (.exe). Not too sure what could be causing this error, I have tried recompressing the files, to no avail. I am using a standalone Arc CLI compressor with only BPK hooked up.

I am using Advanced Simple Installer Script v7.1.3 (if this helps).

If any more info is required I'll happily provide.

mausschieber 11-02-2020 01:47

Quote:

Originally Posted by Masquerade (Post 484599)
I have compressed an archive using Bink Pack (multiple .bik files). Compression is all good (no FreeArc errors) but whenever I feed it to my installer for decompression, I always get the following error:

https://i.imgur.com/vqpLPCL.png

As far as I know, CLS-BPK.DLL is the only way of decompressing files compressed using BPK (.exe). Not too sure what could be causing this error, I have tried recompressing the files, to no avail. I am using a standalone Arc CLI compressor with only BPK hooked up.

I am using Advanced Simple Installer Script v7.1.3 (if this helps).

If any more info is required I'll happily provide.

This feature isn't supported


FREEARC_ERRCODE_NOT_IMPLEMENTED= -8; (* Requested feature isn't supported *)

KaktoR 11-02-2020 07:56

Quote:

Originally Posted by Masquerade (Post 484599)
I have compressed an archive using Bink Pack (multiple .bik files). Compression is all good (no FreeArc errors) but whenever I feed it to my installer for decompression, I always get the following error:

https://i.imgur.com/vqpLPCL.png

As far as I know, CLS-BPK.DLL is the only way of decompressing files compressed using BPK (.exe). Not too sure what could be causing this error, I have tried recompressing the files, to no avail. I am using a standalone Arc CLI compressor with only BPK hooked up.

I am using Advanced Simple Installer Script v7.1.3 (if this helps).

If any more info is required I'll happily provide.

Try to use another compressor with bpk

KaktoR 24-04-2020 06:46

I want to create shortcuts with CreateShellLink function, it works for {commondesktop} but not for {group} nor {userstartmenu} / {commonstartmenu}. Why?

I read the information directly from INI file.

Code:

if IniKeyNotEmpty('Executable', 'Exe') then
begin
  CreateShellLink(
  ExpandConstant('{commonstartmenu}\' + GetIniString('Executable', 'ExeName', '', ExpandConstant('{tmp}\Settings.ini')) + '.lnk'),
  GetIniString('Executable','ExeName','',ExpandConstant('{tmp}\Settings.ini')),
  GetIniString('Executable','Exe','',ExpandConstant('{tmp}\Settings.ini')),
  GetIniString('Executable','ExeParam','',ExpandConstant('{tmp}\Settings.ini')),
  '',
  '',
  0,
  SW_SHOWNORMAL
  );
end;


Cesar82 24-04-2020 07:14

Quote:

Originally Posted by KaktoR (Post 485447)
I want to create shortcuts with CreateShellLink function, it works for {commondesktop} but not for {group} nor {userstartmenu} / {commonstartmenu}. Why?

I read the information directly from INI file.

Post a usage example [Executable] section.
Perhaps because the folder where you are going to create the shortcut does not exist.
Perhaps because the executable does not exist (But I think it should create such randomness).
The path to Exe must be expanded if you use constants like {app}...
If the shortcut destination contains a subfolder, create the folder before calling CreateShellLink using:
ForceDirectories(ExpandConstant( FolderName ));
Code:

if IniKeyNotEmpty('Executable', 'Exe') then
begin
  CreateShellLink(
  ExpandConstant('{commonstartmenu}\' + GetIniString('Executable', 'ExeName', '', ExpandConstant('{tmp}\Settings.ini')) + '.lnk'),
  GetIniString('Executable','ExeName','',ExpandConstant('{tmp}\Settings.ini')),
  ExpandConstant(GetIniString('Executable','Exe','',ExpandConstant('{tmp}\Settings.ini'))),
  GetIniString('Executable','ExeParam','',ExpandConstant('{tmp}\Settings.ini')),
  '',
  '',
  0,
  SW_SHOWNORMAL
  );
end;

Here created correctly.
https://i.imgur.com/5ZO5ImN.jpg

KaktoR 24-04-2020 07:30

Quote:

Originally Posted by Cesar82 (Post 485448)
The path to Exe must be expanded if you use constants like {app}...

This was the error.

Thanks!

For all the code I just overlooked this:D:p

KaktoR 24-04-2020 08:29

So, how to delete the shortcuts after uninstall?

IS help tells me to do this through [UninstallDelete], but how?

DiCaPrIo 24-04-2020 10:10

try it it might delete
Quote:

[UninstallDelete]
Type: FilesAndOrDirs; Name: {app}
Type: Files; Name: {code:GetIconDir}
#define IconName ReadIni(SourcePath + "\Settings.ini", "Executable", "ExeName", "")

[Code]
function GetIconDir(Value:String):string;
begin
Result:=ExpandConstant('{commonstartmenu}\{#IconNa me}.lnk')
end;

KaktoR 24-04-2020 11:09

Thanks. Will look into this later :D

Edit: It works but only for one icon (not for both). Not very smart because I have to create functions for both desktop and group icons ^^

However, I just did it this way until I find a better way

Code:

[UninstallDelete]
Type: files; Name: {userdesktop}\{#Shortcut1Name}.lnk
Type: files; Name: {userstartmenu}\{#Name}\{#Shortcut2Name}.lnk


Cesar82 24-04-2020 16:21

Quote:

Originally Posted by KaktoR (Post 485450)
So, how to delete the shortcuts after uninstall?

IS help tells me to do this through [UninstallDelete], but how?

You can do it through [UninstallDelete].
But as the shortcut was created on installation in the code, you can remove this shortcut using the code in the:
procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep);

Code:

if IniKeyNotEmpty('Executable', 'Exe') then
begin
  DeleteFile(ExpandConstant('{commonstartmenu}\' + GetIniString('Executable', 'ExeName', '', ExpandConstant('{tmp}\Settings.ini')) + '.lnk'));
end;

In this way, the Settings.ini file must be copied to the installation folder during installation and when uninstalling it must be copied to the temp folder at:
function InitializeUninstall (): Boolean;

KaktoR 24-04-2020 16:26

I did it this way too, but doesn't work.

My old code
Code:

procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep);
case of usPostUninstall
begin
DeleteFile(ExpandConstant('{userdesktop}\' + GetIniString('Executable', 'Shortcut1Name', '', ExpandConstant('{tmp}\Settings.ini')) + '.lnk'));
DeleteFile(ExpandConstant('{userstartmenu}\' + GetIniString('Executable', 'Shortcut1Name', '', ExpandConstant('{tmp}\Settings.ini')) + '.lnk'));
end;

Maybe I should have test this with ForceDirectories function?

Edit:
Quote:

Originally Posted by Cesar82 (Post 485461)
In this way, the Settings.ini file must be copied to the installation folder during installation and when uninstalling it must be copied to the temp folder at:
function InitializeUninstall (): Boolean;

Ok, that explains alot. Unfortunatelly not an option for me.

Cesar82 24-04-2020 17:12

1 Attachment(s)
Code:

[UninstallDelete]
#define i 0
#sub RemoveShortcut
  #emit "Type: Files; Name: ""{userdesktop}" + Trim(ReadIni(SourcePath + "\Settings.ini", "Executable" + Str(i), "ExeName", "")) + ".lnk"";"
  #emit "Type: Files; Name: ""{userprograms}" + Trim(ReadIni(SourcePath + "\Settings.ini", "Settings", "Name", "")) + "" + Trim(ReadIni(SourcePath + "\Settings.ini", "Executable" + Str(i), "ExeName", "")) + ".lnk"";"
#endsub
#for {i = 1; Trim(ReadIni(SourcePath + "\Settings.ini", "Executable" + Str(i), "ExeName", "")) != ""; i++} RemoveShortcut

I attached another example using ISPP and the icons section.
Using ISPP it is not possible to change the name of the shortcuts by changing any external ini after compiling the script

KaktoR 27-04-2020 11:50

Thanks Cesar.

But there seems to be a problem with this ispp code.

I have this

Code:

[Executable1]
ShortcutName=Application
ExePath=bin\Application.exe
ExeParam=-Testparameter

Path is always "C:\bin" (I use {sd}\Games constant as default) and my test archive is like this: Archive.arc\bin\application.exe

The shortcut on desktop and startmenu is always C:\bin\application.exe.
I would like it read from INI: DefaultInstallDir={sd}\Games\{#Name}

Cesar82 27-04-2020 16:31

1 Attachment(s)
Quote:

Originally Posted by KaktoR (Post 485492)
Thanks Cesar.

But there seems to be a problem with this ispp code.

I have this

Code:

[Executable1]
ShortcutName=Application
ExePath=bin\Application.exe
ExeParam=-Testparameter

Path is always "C:\bin" (I use {sd}\Games constant as default) and my test archive is like this: Archive.arc\bin\application.exe

The shortcut on desktop and startmenu is always C:\bin\application.exe.
I would like it read from INI: DefaultInstallDir={sd}\Games\{#Name}

Try as in the attachment...
@KaktoR, I changed the attachment.
If you don't want to use tasks for the desktop shortcut, simply remove the [Tasks] section and also + "Tasks: desktopicon;" the shortcut line.
If you do not want to use a URL, simply do not include the lines referring to the URL shortcut.

KaktoR 28-04-2020 05:26

Thanks, this works fine.

I just don't understand all of this ispp things... Will read about it some more.

Cesar82 28-04-2020 05:55

Quote:

Originally Posted by KaktoR (Post 485498)
Thanks, this works fine.

I just don't understand all of this ispp things... Will read about it some more.

The ISPP performs procedures (ISPP Procedures) before compiling the script by changing the script text.

In the example in the above file you are saving a preprocessed script.
This file is used to visualize how the preprocessed code will look.

If using ISPP it is not possible to use an external Settings.ini with settings for shortcuts.
Using ISPP the settings.ini settings are "copied" to script.iss when compiling and cannot be changed afterwards.

doofoo24 25-05-2020 10:54

does the new inno 6.0.5 have Dark theme built-in ?

Masquerade 02-06-2020 05:33

Unknown Type: PChar
 
Hello all, I have been adding the module ITDownload to my installer script, so redist files can be downloaded instead of me having to bundle them into the installer.

I currently have everything integrated, here is an example:

Code:

procedure InstallRedists;
  begin
  itd_init;
  #ifdef directx
  itd_addfile('https://download.microsoft.com/download/1/7/1/1718CCC4-6315-4D8E-9543-8E28A4E18C4C/dxwebsetup.exe',expandconstant('{app}\_Redist\dxwebsetup.exe'));
  #endif

  itd_downloadafter(wpInstalling);

  #ifdef directx
  Exec2(ExpandConstant('{app}\_Redist\dxwebsetup.exe'),'',true);
  #endif
end;

At the start of the script,
Code:

#define directx
exists so this code does apply.

I integrated into the script the iss file and module:

Code:

#include "Resources\Modules\itd\it_download.iss"
However now when compiling, this error appears:

https://i.imgur.com/Ea67Y36.png

Does anyone know what this error could mean? The error lies in the iss script for the ITDownlaod module and not in my installer script.

I am using Inno Setup Unicode 6.0.3

pincoball 02-06-2020 06:15

Seems like the variable type PChar is not anymore compatible with Inno Setup 6.
https://jrsoftware.org/ishelp/index.php?topic=unicode

Quoting:
Quote:

Its 'PChar' type has been renamed to 'PAnsiChar'
and

Quote:

If you want to compile an existing script that imports ANSI Windows API calls with the Unicode compiler, either upgrade to the 'W' Unicode API call or change the parameters from 'String' or 'PChar' to 'AnsiString'. The 'AnsiString' approach will make your [Code] compatible with both the Unicode and the non Unicode version.
Try replacing in the mentioned script from PChar to either PAnsiChar or AnsiString

Masquerade 02-06-2020 07:07

Quote:

Originally Posted by pincoball (Post 486151)
Try replacing in the mentioned script from PChar to either PAnsiChar or AnsiString

Compiling works, brilliant!

On testing though, things get a little nasty:

https://i.imgur.com/4wUj20w.png

The progress bar is at 100% so the redist downloader process is began.

Installing/Uninstalling works without checking redist box so the script still functions. Only with redist selected will cause this.

Edit: the module is loaded, behind the buttons that the text for the module is there (the progress bar, eta etc..).

pincoball 02-06-2020 07:31

I think that this module is pretty old and it might not support newer versions of Inno Setup thus the problem may arise from another incompatibility... but I think that something else can be done.
Have you tried translating the error message? I know that if you cannot copy and paste you should rely on OCR reading from the screenshot but I think you might give it a try if it says something relevant

Also, does it give the same problem with both PAnsiChar and AnsiString?

Cesar82 02-06-2020 16:04

Quote:

Originally Posted by Masquerade (Post 486153)
Compiling works, brilliant!

On testing though, things get a little nasty:

https://i.imgur.com/4wUj20w.png

The progress bar is at 100% so the redist downloader process is began.

Installing/Uninstalling works without checking redist box so the script still functions. Only with redist selected will cause this.

Edit: the module is loaded, behind the buttons that the text for the module is there (the progress bar, eta etc..).

Can you send me the code that is showing this image message?
I would like to analyze this.

Another way to make Unicode and Ansi compatible is to just include this before the functions that PChar uses.
Code:

#ifdef UNICODE
type
  PChar = PAnsiChar;
#endif

I found it much more interesting to download this module DwinsHs.
The FTP, HTTP and HTTPS protocols are supported.

Masquerade 03-06-2020 06:44

Quote:

Originally Posted by Cesar82 (Post 486159)
I found it much more interesting to download this module DwinsHs.
The FTP, HTTP and HTTPS protocols are supported.

Thank you Cesar, I will try and implement this. Is there a way to add an extra page to the installer after installing for the redist downloading? I am using the ASIS script which already has an extra page for CRC checking.

KaktoR 03-06-2020 07:07

Quote:

Originally Posted by Masquerade (Post 486163)
Thank you Cesar, I will try and implement this. Is there a way to add an extra page to the installer after installing for the redist downloading? I am using the ASIS script which already has an extra page for CRC checking.

Sure. Just create a new page :D

Look on how the CRCPage was created. This should guide you in the right direction :p

bunti_o4u 19-06-2020 09:07

Loading items in combobox from text file
 
I am trying to load the items in a combobox from a text file but whats it loading is the last line and not all the lines..

Pl help. Thnx in advance..
Code:

var
  S: String;

function GetFileLines(const FileName: string; out Items: string): Boolean;
var
  FileLines: TArrayOfString;
  LineIndex: Integer;
begin
  Result:= LoadStringsFromFile(FileName, FileLines);
  if Result then
    for LineIndex:=0 to (GetArrayLength(FileLines)-1) do
    Items:= FileLines[LineIndex];
end;

  Combobox1:= TComboBox.Create(WizardForm);
  with Combobox1 do
  begin
    Parent:=WizardForm;
    SetBounds(left, Top, Width, Height);
    Style:=csDropDown;
    Color:=clWhite;
    if GetFileLines(ExpandConstant('{src}\Text.ini'), S) then
      Items.Add(S);
  end;


Cesar82 19-06-2020 11:16

Quote:

Originally Posted by bunti_o4u (Post 486436)
I am trying to load the items in a combobox from a text file but whats it loading is the last line and not all the lines..

Pl help. Thnx in advance..
Code:

var
  S: String;

function GetFileLines(const FileName: string; out Items: string): Boolean;
var
  FileLines: TArrayOfString;
  LineIndex: Integer;
begin
  Result:= LoadStringsFromFile(FileName, FileLines);
  if Result then
    for LineIndex:=0 to (GetArrayLength(FileLines)-1) do
    Items:= FileLines[LineIndex];
end;

  Combobox1:= TComboBox.Create(WizardForm);
  with Combobox1 do
  begin
    Parent:=WizardForm;
    SetBounds(left, Top, Width, Height);
    Style:=csDropDown;
    Color:=clWhite;
    if GetFileLines(ExpandConstant('{src}\Text.ini'), S) then
      Items.Add(S);
  end;


TRY:
Code:

procedure GetFileLines(const FileName: string; var Combo: TComboBox);
var
  FileLines: TArrayOfString;
  LineIndex: Integer;
begin
  if  LoadStringsFromFile(FileName, FileLines) then
    for LineIndex := 0 to GetArrayLength(FileLines) - 1 do
      Combo.Items.Add(FileLines[LineIndex]);
end;

  Combobox1:= TComboBox.Create(WizardForm);
  with Combobox1 do
  begin
    Parent := WizardForm;
    SetBounds(left, Top, Width, Height);
    Style := csDropDown;
    Color := clWhite;
    GetFileLines(ExpandConstant('{src}\Text.ini'), Combobox1)
  end;


bunti_o4u 19-06-2020 13:49

Quote:

Originally Posted by Cesar82 (Post 486439)
TRY:

I have done the same but forgot to put var in the procedure
Code:

procedure GetFileLines(const FileName: string; var Combo: TComboBox);
Thank you.. it worked but now I am facing another problem.

I have second Combobox which is dependent on first combobox for its filename. Procedure is generating Combobox1.Items.Text as Line1Line2Line3(...).ini

Pl tell me how to fix it..
Code:

  Combobox2:= TComboBox.Create(WizardForm);
  with Combobox2 do
  begin
    Parent := WizardForm;
    SetBounds(left, Top, Width, Height);
    Style := csDropDown;
    Color := clWhite;
    GetFileLines(ExpandConstant('{src}\'+ ComboBox1.Items.Text +'.ini'), Combobox2)
  end;


Cesar82 19-06-2020 17:39

Quote:

Originally Posted by bunti_o4u (Post 486442)
I have second Combobox which is dependent on first combobox for its filename. Procedure is generating Combobox1.Items.Text as Line1Line2Line3(...).ini

Pl tell me how to fix it..
Code:

  Combobox2:= TComboBox.Create(WizardForm);
  with Combobox2 do
  begin
    Parent := WizardForm;
    SetBounds(left, Top, Width, Height);
    Style := csDropDown;
    Color := clWhite;
    GetFileLines(ExpandConstant('{src}\'+ ComboBox1.Items.Text +'.ini'), Combobox2)
  end;


TRY
Code:

var
  I: Integer

  Combobox2:= TComboBox.Create(WizardForm);
  with Combobox2 do
  begin
    Parent := WizardForm;
    SetBounds(left, Top, Width, Height);
    Style := csDropDown;
    Color := clWhite;
    for I := 0 to Combobox1.Items.Count - 1 do
      GetFileLines(ExpandConstant('{src}\' + ComboBox1.Items.Strings[I]), Combobox2)
  end;


bunti_o4u 20-06-2020 01:54

1 Attachment(s)
Quote:

Originally Posted by Cesar82 (Post 486444)
TRY

Thank you for helping me out..

This code didn't work.. I am trying something else and I don't know whether it would fix it or not..

Pl have a look at the attached script..


All times are GMT -7. The time now is 08:12.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
FileForums @ https://fileforums.com