dimanche 22 août 2021

INNO SETUP Using checkboxes

I'm not familiar with Pascal. I would like to show 10 checkbox before installing. The user can check several checkboxes according to the group of catalogs he wants to install (10 checkboxes = 10 groups of catalogs). These checkboxes have to be tested in FILES section and in CODE section. In FILES section only catalogs of a checked group will be installed. In CODE section, the pictures will be downloaded and unzipped according to the group of catalogs checked.

I made 100 hundred tries but an error occurs because the local variables can not be used in other sections.

[Languages]
Name: fr; MessagesFile: compiler:Languages\French.isl; LicenseFile: C:\Dev\Phi8\licensefr.TXT
Name: en; MessagesFile: compiler:Default.isl; LicenseFile: C:\Dev\Phi8\licenseen.TXT



[Setup]


#include "C:\Dev\Inno Download Plugin\idp.iss"
#include "C:\Dev\Inno Download Plugin\french.iss"



[Tasks]
Name: "chkbInstallFR"; Description: "France"; MinVersion: 0.0,5.0
Name: "chkbInstallMO"; Description: "Monaco, Andorre, TAAF, SPM"; MinVersion: 0.0,5.0
Name: "chkbInstallBELUX"; Description: "Belgique, Luxembourg"; MinVersion: 0.0,5.0
Name: "chkbInstallSUI"; Description: "Suisse, Liechtenstein"; MinVersion: 0.0,5.0
Name: "chkbInstallITA"; Description: "Italie"; MinVersion: 0.0,5.0
Name: "chkbInstallALL"; Description: "Allemagne"; MinVersion: 0.0,5.0
Name: "chkbInstallEURONU"; Description: "Europa, Nations Unies, sepac"; MinVersion: 0.0,5.0
Name: "chkbInstallILE"; Description: "Ile des Antilles, Pacifique, Océan indien"; MinVersion: 0.0,5.0
Name: "chkbInstallAFR"; Description: "Anciennes colonies françaises"; MinVersion: 0.0,5.0
Name: "chkbInstallBUR"; Description: "Bureaux français en Europe, Asie, Moyen-Orient"; MinVersion: 0.0,5.0
  


[Dirs]
Name: {app}\Datas
Name: {app}\Pic
Name: {app}\Pic\AN
Name: {app}\Pic\ANE
Name: {app}\Pic\UNY


[Files]

Source: C:\Sources\Phi\Exe\Datas\UNY_BIN20P.s2db; DestDir: {app}\Datas; Flags: ignoreversion; Check: InstallFR;
Source: C:\Sources\Phi\Exe\Datas\UNY_BIN20D.s2db; DestDir: {app}\datas; Flags: onlyifdoesntexist; Check: InstallFR;


Source: C:\Sources\Phi\Exe\Datas\AN_BIN20P.s2db; DestDir: {app}\Datas; Flags: ignoreversion; Check: InstallMO;
Source: C:\Sources\Phi\Exe\Datas\AN_BIN20D.s2db; DestDir: {app}\datas; Flags: onlyifdoesntexist; Check: InstallMO;

Source: C:\Sources\Phi\Exe\Datas\ANE_BIN20P.s2db; DestDir: {app}\Datas; Flags: ignoreversion; Check: InstallMO;
Source: C:\Sources\Phi\Exe\Datas\ANE_BIN20D.s2db; DestDir: {app}\datas; Flags: onlyifdoesntexist; Check: InstallMO;


Source: C:\Dev\Philatelix8\Install\7za.exe; DestDir: "{app}"; Flags: deleteafterinstall;


[Icons]


[Run]
Filename: {app}\7za.exe; Parameters: "x ""{tmp}UNY.zip"" -o""{app}\Pic\UNY"" * -aoa"; Flags: runascurrentuser;

Filename: {app}\7za.exe; Parameters: "x ""{tmp}AN.zip"" -o""{app}\Pic\AN"" * -aoa"; Flags: runascurrentuser; 
Filename: {app}\7za.exe; Parameters: "x ""{tmp}ANE.zip"" -o""{app}\Pic\ANE"" * -aoa"; Flags: runascurrentuser; 

[INI]


[Code] 
{ RedesignWizardFormBegin } // Don't remove this line!
// Don't modify this section. It is generated automatically.
var
  chkbInstallFR: TNewCheckBox;
  chkbInstallMO: TNewCheckBox;
  chkbInstallBELUX: TNewCheckBox;
  chkbInstallSUI: TNewCheckBox;
  chkbInstallITA: TNewCheckBox;
  chkbInstallALL: TNewCheckBox;
  chkbInstallEURONU: TNewCheckBox;
  chkbInstallILE: TNewCheckBox;
  chkbInstallAFR: TNewCheckBox;
  chkbInstallBUR: TNewCheckBox;

procedure RedesignWizardForm;
begin
  with WizardForm.SelectTasksLabel do
  begin
    Visible := False;
    Left := ScaleX(392);
  end;

  { chkbInstallFR }
  chkbInstallFR := TNewCheckBox.Create(WizardForm);
  with chkbInstallFR do
  begin
    Parent := WizardForm.WelcomePage;
    Left := ScaleX(8);
    Top := ScaleY(16);
    Width := ScaleX(97);
    Height := ScaleY(17);
    Checked := True;
    Caption := 'France';
  end;

  { chkbInstallMO }
  chkbInstallMO := TNewCheckBox.Create(WizardForm);
  with chkbInstallMO do
  begin
    Parent := WizardForm.WelcomePage;
    Left := ScaleX(8);
    Top := ScaleY(40);
    Width := ScaleX(97);
    Height := ScaleY(17);
    Checked := True;
    Caption := 'Monaco, Andorre, TAAF, SPM';
  end;

  { chkbInstallBELUX }
  chkbInstallBELUX := TNewCheckBox.Create(WizardForm);
  with chkbInstallBELUX do
  begin
    Parent := WizardForm.WelcomePage;
    Left := ScaleX(8);
    Top := ScaleY(64);
    Width := ScaleX(97);
    Height := ScaleY(17);
    Checked := True;
    Caption := 'Belgique et Luxembourg';
  end;

  { chkbInstallSUI }
  chkbInstallSUI := TNewCheckBox.Create(WizardForm);
  with chkbInstallSUI do
  begin
    Parent := WizardForm.WelcomePage;
    Left := ScaleX(8);
    Top := ScaleY(64);
    Width := ScaleX(97);
    Height := ScaleY(17);
    Checked := True;
    Caption := 'Suisse et Liechtenstein';
  end;

  { chkbInstallITA }
  chkbInstallITA := TNewCheckBox.Create(WizardForm);
  with chkbInstallITA do
  begin
    Parent := WizardForm.WelcomePage;
    Left := ScaleX(8);
    Top := ScaleY(64);
    Width := ScaleX(97);
    Height := ScaleY(17);
    Checked := True;
    Caption := 'Italie';
  end;

  { chkbInstallALL }
  chkbInstallALL := TNewCheckBox.Create(WizardForm);
  with chkbInstallALL do
  begin
    Parent := WizardForm.WelcomePage;
    Left := ScaleX(8);
    Top := ScaleY(64);
    Width := ScaleX(97);
    Height := ScaleY(17);
    Checked := True;
    Caption := 'Allemagne';
  end;

  { chkbInstallEURONU }
  chkbInstallEURONU := TNewCheckBox.Create(WizardForm);
  with chkbInstallEURONU do
  begin
    Parent := WizardForm.WelcomePage;
    Left := ScaleX(8);
    Top := ScaleY(64);
    Width := ScaleX(97);
    Height := ScaleY(17);
    Checked := False;
    Caption := 'Europa, Nations Unies, sepac';
  end;

  { chkbInstallILE }
  chkbInstallILE := TNewCheckBox.Create(WizardForm);
  with chkbInstallILE do
  begin
    Parent := WizardForm.WelcomePage;
    Left := ScaleX(8);
    Top := ScaleY(64);
    Width := ScaleX(97);
    Height := ScaleY(17);
    Checked := True;
    Caption := 'Iles des antilles, Pacifique et Océan indien';
  end;

  { chkbInstallAFR }
  chkbInstallAFR := TNewCheckBox.Create(WizardForm);
  with chkbInstallAFR do
  begin
    Parent := WizardForm.WelcomePage;
    Left := ScaleX(8);
    Top := ScaleY(64);
    Width := ScaleX(97);
    Height := ScaleY(17);
    Checked := True;
    Caption := 'Colonies françaises en Afrique';
  end;

  { chkbInstallBUR }
  chkbInstallBUR := TNewCheckBox.Create(WizardForm);
  with chkbInstallBUR do
  begin
    Parent := WizardForm.WelcomePage;
    Left := ScaleX(8);
    Top := ScaleY(64);
    Width := ScaleX(97);
    Height := ScaleY(17);
    Checked := True;
    Caption := 'Bureaux français en Europe, Asie, Moyen-Orient';
  end;

  chkbInstallFR.TabOrder := 0;
  chkbInstallMO.TabOrder := 1;
  chkbInstallBELUX.TabOrder := 2;
  chkbInstallSUI.TabOrder := 3;
  chkbInstallITA.TabOrder := 4;
  chkbInstallALL.TabOrder := 5;
  chkbInstallEURONU.TabOrder := 6;
  chkbInstallILE.TabOrder := 7;
  chkbInstallAFR.TabOrder := 8;
  chkbInstallBUR.TabOrder := 9;

{ ReservationBegin }
  // This part is for you. Add your specialized code here.
 
   if chkbInstallFR.checked then 
   begin
      idpAddFile('http://www.philatelix.fr/Divers/PHI/UNY.zip', ExpandConstant('{tmp}UNY.zip'));
   end;

   if chkbInstallMO.checked then 
   begin
      idpAddFile('http://www.philatelix.fr/Divers/PHI/AN.zip', ExpandConstant('{tmp}AN.zip'));
      idpAddFile('http://www.philatelix.fr/Divers/PHI/ANE.zip', ExpandConstant('{tmp}ANE.zip'));
   end;

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







procedure InitializeWizard;
 begin


{ Download after "Ready" wizard page }
idpDownloadAfter(wpReady);
end;

procedure CurStepChanged(CurStep: TSetupStep);
begin
    if CurStep = ssPostInstall then 
    begin
      if chkbInstallFR.checked then 
      begin
        FileCopy(ExpandConstant('{tmp}\UNY.zip'), ExpandConstant('{app}\UNY.zip'), false);
      end;
      if chkbInstallMO.checked then 
      begin
        FileCopy(ExpandConstant('{tmp}\AN.zip'), ExpandConstant('{app}\AN.zip'), false);
        FileCopy(ExpandConstant('{tmp}\ANE.zip'), ExpandConstant('{app}\ANE.zip'), false);
      end;

    end;
end;


function InstallFR: Boolean;
begin
     if chkbInstallFR.checked then 
        begin
          Result := TRUE
        end;
      else
        begin
          Result := FALSE
        end;
      else
end;

function InstallMO: Boolean;
begin
     if chkbInstallMO.checked then 
        begin
          Result := TRUE
        end;
      else
        begin
          Result := FALSE
        end;
end;



Aucun commentaire:

Enregistrer un commentaire