Jump to content

Hi all

 

I was wondering if someone could help me out.

 

Im making a modpack installer for a game i play and even though the installer im using works im trying to add a bit of code that saves the users component choices to a .ini file.

 

This .ini file can then later be read by the installer to pre select the choices made to make installing the modpack again later more convenient.

 

However im having a bit of issue getting it to work.

 

Im using Inno Setup 6.2.1

 

Here is the code i have in place

 

[INI]
Filename: "{app}/DTUKMPOptions.ini"; Section: "Setup"; Key: "Components"; String: "{code:GetSelectedComponents}"

 

[Code]
function GetSelectedComponents: string;
var
  i: Integer;
begin
  Result := '';
  for i := 0 to WizardForm.ComponentsList.Count - 1 do
  begin
    if WizardForm.ComponentsList.Checked[i] then
    begin
      if Result <> '' then
        Result := Result + ',';
      Result := Result + WizardForm.ComponentsList.Items[i];
    end;
  end;
end;

procedure InitializeWizard;
var
  IniFile: TIniFile;
  SelectedComponents: string;
  i: Integer;
begin
  IniFile := TIniFile.Create(ExpandConstant('{app}/DTUKMPOptions.ini'));
  try
    SelectedComponents := IniFile.ReadString('Setup', 'Components', '');
    if SelectedComponents <> '' then
    begin
      for i := 0 to WizardForm.ComponentsList.Count - 1 do
      begin
        if Pos(WizardForm.ComponentsList.Items[i], SelectedComponents) > 0 then
          WizardForm.ComponentsList.Checked[i] := True;
      end;
    end;
  finally
    IniFile.Free;
  end;
end;

 

However i get this error

 

Quote

Unknown Identifier 'COUNT'

 

 

Does anyone know where im going wrong?

 

The code section is written in Pascal

 

Cheers

 

 

 

Spoiler
  • CPU
  • Motherboard
  • RAM
  • GPU
  • Case
  • Storage
  • PSU
  • Display(s)
  • Cooling
  • Keyboard
  • Mouse
  • Sound
  • Operating System
Link to comment
https://linustechtips.com/topic/1484920-inno-setup-help/
Share on other sites

Link to post
Share on other sites

I'm no expert but it's possible that the line that ends in 

.Count

 

Needs to be replaced with 

.length

 

https://www.freepascal.org/docs-html/rtl/system/length.html

 

Some languages use "count" others use "length" and some use both count and length depending on the context. It's a bit maddening. 

 

Remember to try uppercase and lowercase first letter just in case it doesn't accept 

Length

It might accept 

length

 

If you want to be thorough, this looks like it will get you started in pascal if you don't know it and are just copying things. It's very short though and doesn't cover advanced subjects like the count concept

https://learnxinyminutes.com/docs/pascal/

 

Link to comment
https://linustechtips.com/topic/1484920-inno-setup-help/#findComment-15776049
Share on other sites

Link to post
Share on other sites

13 minutes ago, fpo said:

I'm no expert but it's possible that the line that ends in 

.Count

 

Needs to be replaced with 

.length

 

https://www.freepascal.org/docs-html/rtl/system/length.html

 

Some languages use "count" others use "length" and some use both count and length depending on the context. It's a bit maddening. 

 

Remember to try uppercase and lowercase first letter just in case it doesn't accept 

Length

It might accept 

length

 

If you want to be thorough, this looks like it will get you started in pascal if you don't know it and are just copying things. It's very short though and doesn't cover advanced subjects like the count concept

https://learnxinyminutes.com/docs/pascal/

 

Hey

 

Unfortunately that didn't work 😞

Thanks for the help though 😄

 

Spoiler
  • CPU
  • Motherboard
  • RAM
  • GPU
  • Case
  • Storage
  • PSU
  • Display(s)
  • Cooling
  • Keyboard
  • Mouse
  • Sound
  • Operating System
Link to comment
https://linustechtips.com/topic/1484920-inno-setup-help/#findComment-15776068
Share on other sites

Link to post
Share on other sites

Just now, dtronicsuk said:

Hey

 

Unfortunately that didn't work 😞

Thanks for the help though 😄

there are multiple lines that have . count n them

 

Lastthing I can guess is to just add open close parenthesis like this ()

Immediately after with no spaces from count or length. 

 

Also try lowercase count

 

 

That's all I got from quick Google searching Pascal and educated guesses

Link to comment
https://linustechtips.com/topic/1484920-inno-setup-help/#findComment-15776073
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×