Можно ли использовать ISPP для автоматического создания этих строк сценария в Inno Setup? - PullRequest
1 голос
/ 05 июня 2019

У меня есть эти ISPP определяет:

; Language combo index values
#define MDB_AFK_INDEX "0"
#define MDB_TWI_INDEX "1"
#define MDB_DAN_INDEX "2"
#define MDB_DEU_INDEX "3"
#define MDB_ENG_INDEX "4"
#define MDB_ESP_INDEX "5"
#define MDB_FRA_INDEX "6"
#define MDB_IND_INDEX "7"
#define MDB_ITA_INDEX "8"
#define MDB_SWK_INDEX "9"
#define MDB_NLD_INDEX "10"
#define MDB_PLK_INDEX "11"
#define MDB_PTB_INDEX "12"
#define MDB_RUS_INDEX "13"
#define MDB_SQI_INDEX "14"
#define MDB_FIN_INDEX "15"
#define MDB_SRN_INDEX "16"
#define MDB_SVE_INDEX "17"
#define MDB_FPO_INDEX "18"
#define MDB_TRK_INDEX "19"
#define MDB_CHS_INDEX "20"
#define MDB_BGR_INDEX "21"
#define MDB_ELL_INDEX "22"
#define MDB_UKR_INDEX "23"
#define MDB_KHM_INDEX "24"
#define MDB_ROM_INDEX "25"
#define MDB_SMO_INDEX "26"
#define MDB_VIT_INDEX "27"
#define MDB_ARA_INDEX "28"

И у меня есть эта функция Pascal Code Check:

{ Returns True if the user selected the same database language in the combo }
function CheckMDBLang(iMDBLangIndex: integer): boolean;
begin
  result := (cbDatabase.ItemIndex = iMDBLangIndex);
end;

Это текущие файлы сценариев, которые используют выше:

; default database
Source: "..\inno\Databases\English.mdb"; DestDir: "{app}"; DestName: "Default.mdb"; Flags: overwritereadonly uninsremovereadonly; Attribs: readonly; Check: CheckMDBLang({#MDB_ENG_INDEX})
Source: "..\inno\Databases\Spanish.mdb"; DestDir: "{app}"; DestName: "Default.mdb"; Flags: overwritereadonly uninsremovereadonly; Attribs: readonly; Check: CheckMDBLang({#MDB_ESP_INDEX})
Source: "..\inno\Databases\German.mdb"; DestDir: "{app}"; DestName: "Default.mdb"; Flags: overwritereadonly uninsremovereadonly; Attribs: readonly; Check: CheckMDBLang({#MDB_DEU_INDEX})
Source: "..\inno\Databases\Italian.mdb"; DestDir: "{app}"; DestName: "Default.mdb"; Flags: overwritereadonly uninsremovereadonly; Attribs: readonly; Check: CheckMDBLang({#MDB_ITA_INDEX})
Source: "..\inno\Databases\Dutch.mdb"; DestDir: "{app}"; DestName: "Default.mdb"; Flags: overwritereadonly uninsremovereadonly; Attribs: readonly; Check: CheckMDBLang({#MDB_NLD_INDEX})
Source: "..\inno\Databases\Turkish.mdb"; DestDir: "{app}"; DestName: "Default.mdb"; Flags: overwritereadonly uninsremovereadonly; Attribs: readonly; Check: CheckMDBLang({#MDB_TRK_INDEX})
Source: "..\inno\Databases\Portuguese.mdb"; DestDir: "{app}"; DestName: "Default.mdb"; Flags: overwritereadonly uninsremovereadonly; Attribs: readonly; Check: CheckMDBLang({#MDB_PTB_INDEX})
Source: "..\inno\Databases\Swedish.mdb"; DestDir: "{app}"; DestName: "Default.mdb"; Flags: overwritereadonly uninsremovereadonly; Attribs: readonly; Check: CheckMDBLang({#MDB_SVE_INDEX})
Source: "..\inno\Databases\Danish.mdb"; DestDir: "{app}"; DestName: "Default.mdb"; Flags: overwritereadonly uninsremovereadonly; Attribs: readonly; Check: CheckMDBLang({#MDB_DAN_INDEX})
Source: "..\inno\Databases\Russian.mdb"; DestDir: "{app}"; DestName: "Default.mdb"; Flags: overwritereadonly uninsremovereadonly; Attribs: readonly; Check: CheckMDBLang({#MDB_RUS_INDEX})
Source: "..\inno\Databases\Finnish.mdb"; DestDir: "{app}"; DestName: "Default.mdb"; Flags: overwritereadonly uninsremovereadonly; Attribs: readonly; Check: CheckMDBLang({#MDB_FIN_INDEX})
Source: "..\inno\Databases\Afrikaans.mdb"; DestDir: "{app}"; DestName: "Default.mdb"; Flags: overwritereadonly uninsremovereadonly; Attribs: readonly; Check: CheckMDBLang({#MDB_AFK_INDEX})
Source: "..\inno\Databases\Chinese Simplified.mdb"; DestDir: "{app}"; DestName: "Default.mdb"; Flags: overwritereadonly uninsremovereadonly; Attribs: readonly; Check: CheckMDBLang({#MDB_CHS_INDEX})
Source: "..\inno\Databases\Albanian.mdb"; DestDir: "{app}"; DestName: "Default.mdb"; Flags: overwritereadonly uninsremovereadonly; Attribs: readonly; Check: CheckMDBLang({#MDB_SQI_INDEX})
Source: "..\inno\Databases\French.mdb"; DestDir: "{app}"; DestName: "Default.mdb"; Flags: overwritereadonly uninsremovereadonly; Attribs: readonly; Check: CheckMDBLang({#MDB_FRA_INDEX})
Source: "..\inno\Databases\Bulgarian.mdb"; DestDir: "{app}"; DestName: "Default.mdb"; Flags: overwritereadonly uninsremovereadonly; Attribs: readonly; Check: CheckMDBLang({#MDB_BGR_INDEX})
Source: "..\inno\Databases\Twi.mdb"; DestDir: "{app}"; DestName: "Default.mdb"; Flags: overwritereadonly uninsremovereadonly; Attribs: readonly; Check: CheckMDBLang({#MDB_TWI_INDEX})
Source: "..\inno\Databases\Tagalog.mdb"; DestDir: "{app}"; DestName: "Default.mdb"; Flags: overwritereadonly uninsremovereadonly; Attribs: readonly; Check: CheckMDBLang({#MDB_FPO_INDEX})
Source: "..\inno\Databases\Swahili.mdb"; DestDir: "{app}"; DestName: "Default.mdb"; Flags: overwritereadonly uninsremovereadonly; Attribs: readonly; Check: CheckMDBLang({#MDB_SWK_INDEX})
Source: "..\inno\Databases\Greek.mdb"; DestDir: "{app}"; DestName: "Default.mdb"; Flags: overwritereadonly uninsremovereadonly; Attribs: readonly; Check: CheckMDBLang({#MDB_ELL_INDEX})
Source: "..\inno\Databases\Ukrainian.mdb"; DestDir: "{app}"; DestName: "Default.mdb"; Flags: overwritereadonly uninsremovereadonly; Attribs: readonly; Check: CheckMDBLang({#MDB_UKR_INDEX})
Source: "..\inno\Databases\Cambodian.mdb"; DestDir: "{app}"; DestName: "Default.mdb"; Flags: overwritereadonly uninsremovereadonly; Attribs: readonly; Check: CheckMDBLang({#MDB_KHM_INDEX})
Source: "..\inno\Databases\Romanian.mdb"; DestDir: "{app}"; DestName: "Default.mdb"; Flags: overwritereadonly uninsremovereadonly; Attribs: readonly; Check: CheckMDBLang({#MDB_ROM_INDEX})
Source: "..\inno\Databases\Samoan.mdb"; DestDir: "{app}"; DestName: "Default.mdb"; Flags: overwritereadonly uninsremovereadonly; Attribs: readonly; Check: CheckMDBLang({#MDB_SMO_INDEX})
Source: "..\inno\Databases\Indonesian.mdb"; DestDir: "{app}"; DestName: "Default.mdb"; Flags: overwritereadonly uninsremovereadonly; Attribs: readonly; Check: CheckMDBLang({#MDB_IND_INDEX})
Source: "..\inno\Databases\Vietnamese.mdb"; DestDir: "{app}"; DestName: "Default.mdb"; Flags: overwritereadonly uninsremovereadonly; Attribs: readonly; Check: CheckMDBLang({#MDB_VIT_INDEX})
Source: "..\inno\Databases\Arabic.mdb"; DestDir: "{app}"; DestName: "Default.mdb"; Flags: overwritereadonly uninsremovereadonly; Attribs: readonly; Check: CheckMDBLang({#MDB_ARA_INDEX})
Source: "..\inno\Databases\Polish.mdb"; DestDir: "{app}"; DestName: "Default.mdb"; Flags: overwritereadonly uninsremovereadonly; Attribs: readonly; Check: CheckMDBLang({#MDB_PLK_INDEX})
Source: "..\inno\Databases\Srnantongo.mdb"; DestDir: "{app}"; DestName: "Default.mdb"; Flags: overwritereadonly uninsremovereadonly; Attribs: readonly; Check: CheckMDBLang({#MDB_SRN_INDEX})

; default database (ACCDB format)
Source: "..\inno\Databases\English.accdb"; DestDir: "{app}"; DestName: "Default.accdb"; Flags: overwritereadonly uninsremovereadonly; Attribs: readonly; Check: CheckMDBLang({#MDB_ENG_INDEX})
Source: "..\inno\Databases\Spanish.accdb"; DestDir: "{app}"; DestName: "Default.accdb"; Flags: overwritereadonly uninsremovereadonly; Attribs: readonly; Check: CheckMDBLang({#MDB_ESP_INDEX})
Source: "..\inno\Databases\German.accdb"; DestDir: "{app}"; DestName: "Default.accdb"; Flags: overwritereadonly uninsremovereadonly; Attribs: readonly; Check: CheckMDBLang({#MDB_DEU_INDEX})
Source: "..\inno\Databases\Italian.accdb"; DestDir: "{app}"; DestName: "Default.accdb"; Flags: overwritereadonly uninsremovereadonly; Attribs: readonly; Check: CheckMDBLang({#MDB_ITA_INDEX})
Source: "..\inno\Databases\Dutch.accdb"; DestDir: "{app}"; DestName: "Default.accdb"; Flags: overwritereadonly uninsremovereadonly; Attribs: readonly; Check: CheckMDBLang({#MDB_NLD_INDEX})
Source: "..\inno\Databases\Turkish.accdb"; DestDir: "{app}"; DestName: "Default.accdb"; Flags: overwritereadonly uninsremovereadonly; Attribs: readonly; Check: CheckMDBLang({#MDB_TRK_INDEX})
Source: "..\inno\Databases\Portuguese.accdb"; DestDir: "{app}"; DestName: "Default.accdb"; Flags: overwritereadonly uninsremovereadonly; Attribs: readonly; Check: CheckMDBLang({#MDB_PTB_INDEX})
Source: "..\inno\Databases\Swedish.accdb"; DestDir: "{app}"; DestName: "Default.accdb"; Flags: overwritereadonly uninsremovereadonly; Attribs: readonly; Check: CheckMDBLang({#MDB_SVE_INDEX})
Source: "..\inno\Databases\Danish.accdb"; DestDir: "{app}"; DestName: "Default.accdb"; Flags: overwritereadonly uninsremovereadonly; Attribs: readonly; Check: CheckMDBLang({#MDB_DAN_INDEX})
Source: "..\inno\Databases\Russian.accdb"; DestDir: "{app}"; DestName: "Default.accdb"; Flags: overwritereadonly uninsremovereadonly; Attribs: readonly; Check: CheckMDBLang({#MDB_RUS_INDEX})
Source: "..\inno\Databases\Finnish.accdb"; DestDir: "{app}"; DestName: "Default.accdb"; Flags: overwritereadonly uninsremovereadonly; Attribs: readonly; Check: CheckMDBLang({#MDB_FIN_INDEX})
Source: "..\inno\Databases\Afrikaans.accdb"; DestDir: "{app}"; DestName: "Default.accdb"; Flags: overwritereadonly uninsremovereadonly; Attribs: readonly; Check: CheckMDBLang({#MDB_AFK_INDEX})
Source: "..\inno\Databases\Chinese Simplified.accdb"; DestDir: "{app}"; DestName: "Default.accdb"; Flags: overwritereadonly uninsremovereadonly; Attribs: readonly; Check: CheckMDBLang({#MDB_CHS_INDEX})
Source: "..\inno\Databases\Albanian.accdb"; DestDir: "{app}"; DestName: "Default.accdb"; Flags: overwritereadonly uninsremovereadonly; Attribs: readonly; Check: CheckMDBLang({#MDB_SQI_INDEX})
Source: "..\inno\Databases\French.accdb"; DestDir: "{app}"; DestName: "Default.accdb"; Flags: overwritereadonly uninsremovereadonly; Attribs: readonly; Check: CheckMDBLang({#MDB_FRA_INDEX})
Source: "..\inno\Databases\Bulgarian.accdb"; DestDir: "{app}"; DestName: "Default.accdb"; Flags: overwritereadonly uninsremovereadonly; Attribs: readonly; Check: CheckMDBLang({#MDB_BGR_INDEX})
Source: "..\inno\Databases\Twi.accdb"; DestDir: "{app}"; DestName: "Default.accdb"; Flags: overwritereadonly uninsremovereadonly; Attribs: readonly; Check: CheckMDBLang({#MDB_TWI_INDEX})
Source: "..\inno\Databases\Tagalog.accdb"; DestDir: "{app}"; DestName: "Default.accdb"; Flags: overwritereadonly uninsremovereadonly; Attribs: readonly; Check: CheckMDBLang({#MDB_FPO_INDEX})
Source: "..\inno\Databases\Swahili.accdb"; DestDir: "{app}"; DestName: "Default.accdb"; Flags: overwritereadonly uninsremovereadonly; Attribs: readonly; Check: CheckMDBLang({#MDB_SWK_INDEX})
Source: "..\inno\Databases\Greek.accdb"; DestDir: "{app}"; DestName: "Default.accdb"; Flags: overwritereadonly uninsremovereadonly; Attribs: readonly; Check: CheckMDBLang({#MDB_ELL_INDEX})
Source: "..\inno\Databases\Ukrainian.accdb"; DestDir: "{app}"; DestName: "Default.accdb"; Flags: overwritereadonly uninsremovereadonly; Attribs: readonly; Check: CheckMDBLang({#MDB_UKR_INDEX})
Source: "..\inno\Databases\Cambodian.accdb"; DestDir: "{app}"; DestName: "Default.accdb"; Flags: overwritereadonly uninsremovereadonly; Attribs: readonly; Check: CheckMDBLang({#MDB_KHM_INDEX})
Source: "..\inno\Databases\Romanian.accdb"; DestDir: "{app}"; DestName: "Default.accdb"; Flags: overwritereadonly uninsremovereadonly; Attribs: readonly; Check: CheckMDBLang({#MDB_ROM_INDEX})
Source: "..\inno\Databases\Samoan.accdb"; DestDir: "{app}"; DestName: "Default.accdb"; Flags: overwritereadonly uninsremovereadonly; Attribs: readonly; Check: CheckMDBLang({#MDB_SMO_INDEX})
Source: "..\inno\Databases\Indonesian.accdb"; DestDir: "{app}"; DestName: "Default.accdb"; Flags: overwritereadonly uninsremovereadonly; Attribs: readonly; Check: CheckMDBLang({#MDB_IND_INDEX})
Source: "..\inno\Databases\Vietnamese.accdb"; DestDir: "{app}"; DestName: "Default.accdb"; Flags: overwritereadonly uninsremovereadonly; Attribs: readonly; Check: CheckMDBLang({#MDB_VIT_INDEX})
Source: "..\inno\Databases\Arabic.accdb"; DestDir: "{app}"; DestName: "Default.accdb"; Flags: overwritereadonly uninsremovereadonly; Attribs: readonly; Check: CheckMDBLang({#MDB_ARA_INDEX})
Source: "..\inno\Databases\Polish.accdb"; DestDir: "{app}"; DestName: "Default.accdb"; Flags: overwritereadonly uninsremovereadonly; Attribs: readonly; Check: CheckMDBLang({#MDB_PLK_INDEX})
Source: "..\inno\Databases\Srnantongo.accdb"; DestDir: "{app}"; DestName: "Default.accdb"; Flags: overwritereadonly uninsremovereadonly; Attribs: readonly; Check: CheckMDBLang({#MDB_SRN_INDEX})

Можно ли использовать ISPP для автоматизации создания этих строк сценария?


Обновление

Согласно комментариям, cbDatabase является частьюпользовательская страница.Это то, что у меня есть на данный момент:

function AppSettings_CreatePage(PreviousPageId: Integer): Integer;
var
    Page: TWizardPage;
    iUserValue: Cardinal;
    strPath: String;
begin
    Page := CreateCustomPage(
        PreviousPageId,
        ExpandConstant('{cm:ApplicationPreferences}'),
        ExpandConstant('{cm:DefaultSettings}')
    );

    { lblInfo }
    lblInfo := TLabel.Create(Page);
    with lblInfo do
    begin
        Parent := Page.Surface;
        Caption := ExpandConstant('{cm:SpecifyDefaultSettings}');
        Left := ScaleX(8);
        Top := ScaleY(8);
        Width := ScaleX(387);
        Height := ScaleY(29);
    end;

    { chkRememberLastCong }
    chkRememberLastCong := TCheckBox.Create(Page);
    with chkRememberLastCong do
    begin
        Parent := Page.Surface;
        Caption := ExpandConstant('{cm:UserRememberCongregation}');
        Left := ScaleX(8);
        Top := ScaleY(32);
        Width := ScaleX(385);
        Height := ScaleY(25);
        TabOrder := 0;

        { Set default value (for when registry value does not exist) }
        iUserValue := 1;
        { Get registry value }
        RegQueryDWordValue(HKLM,
                     'Software\Community Talks\Public Talks\Preferences',
                     'ReuseCong', iUserValue);
        { Update option on page. }
        Checked := iUserValue = 1;
    end;

    { chkDuplicates }
    chkDuplicates := TCheckBox.Create(Page);
    with chkDuplicates do
    begin
        Parent := Page.Surface;
        Caption := ExpandConstant('{cm:UserCheckDuplicates}');
        Left := ScaleX(8);
        Top := ScaleY(56);
        Width := ScaleX(393);
        Height := ScaleY(17);
        TabOrder := 1;

        { Set default value (for when registry value does not exist) }
        iUserValue := 0;    { Default }
        { Get registry value }
        RegQueryDWordValue(HKLM,
                     'Software\Community Talks\Public Talks\Preferences',
                     'Duplicate', iUserValue);
        { Update option on page. }
        Checked := iUserValue = 1;
    end;

    { lblDatabase }
    lblDatabase := TLabel.Create(Page);
    with lblDatabase do
    begin
        Parent := Page.Surface;
        Caption := ExpandConstant('{cm:DatabaseLanguage}');
        Left := ScaleX(8);
        Top := ScaleY(112);
        Width := ScaleX(385);
        Height := ScaleY(13);
    end;

    { cbDatabase }
    cbDatabase := TNewComboBox.Create(Page);
    with cbDatabase do
    begin
        Parent := Page.Surface;
        Left := ScaleX(8);
        Top := ScaleY(128);
        Width := ScaleX(177);
        Height := ScaleY(21);
        Style := csDropDownList;
        TabOrder := 3;

        { Languages }
        Items.Add({#LANG_AFK});
        Items.Add({#LANG_TWI});
        Items.Add({#LANG_DAN});
        Items.Add({#LANG_DEU});
        Items.Add({#LANG_ENG});
        Items.Add({#LANG_ESP});
        Items.Add({#LANG_FRA});
        Items.Add({#LANG_IND});
        Items.Add({#LANG_ITA});
        Items.Add({#LANG_SWK});
        Items.Add({#LANG_NLD});
        Items.Add({#LANG_PLK});
        Items.Add({#LANG_PTB});
        Items.Add({#LANG_RUS});
        Items.Add({#LANG_SQI});
        Items.Add({#LANG_FIN});
        Items.Add({#LANG_SRN});
        Items.Add({#LANG_SVE});
        Items.Add({#LANG_FPO});
        Items.Add({#LANG_TRK});
        Items.Add({#LANG_CHS});
        Items.Add({#LANG_BGR});
        Items.Add({#LANG_ELL});
        Items.Add({#LANG_UKR});
        Items.Add({#LANG_KHM});
        Items.Add({#LANG_ROM});
        Items.Add({#LANG_SMO});
        Items.Add({#LANG_VIT});
        Items.Add({#LANG_ARA});

        { Get path where the program was last install }
        strPath := GetPathInstalled('Public Talks');

        { Afrikaans has no dedicated language }
        { Chinese Simplified has no dedicated language }
        { Bulgarian has no dedicated language }
        { Twi has no dedicated language }
        { Swahili has no dedicated language }
        { Ukrainian has no dedicated language }
        { Cambodian has no dedicated language }
        { Samoan has no dedicated language }
        { Indonesian has no dedicated language }
        { Vietnamese has no dedicated language }
        { Arabic has no dedicated language }
        { Polish has no dedicated language }
        { Srnantongo has no dedicated language }
        if ActiveLanguage = 'English' then ItemIndex := {#MDB_ENG_INDEX};
        if ActiveLanguage = 'German' then ItemIndex := {#MDB_DEU_INDEX};
        if ActiveLanguage = 'Spanish' then ItemIndex := {#MDB_ESP_INDEX};
        if ActiveLanguage = 'Italian' then ItemIndex := {#MDB_ITA_INDEX};
        if ActiveLanguage = 'Dutch' then ItemIndex := {#MDB_NLD_INDEX};
        if ActiveLanguage = 'Turkish' then ItemIndex := {#MDB_TRK_INDEX};
        if ActiveLanguage = 'Portuguese' then ItemIndex := {#MDB_PTB_INDEX};
        if ActiveLanguage = 'Swedish' then ItemIndex := {#MDB_SVE_INDEX};
        if ActiveLanguage = 'Danish' then ItemIndex := {#MDB_DAN_INDEX};
        if ActiveLanguage = 'Russian' then ItemIndex := {#MDB_RUS_INDEX};
        if ActiveLanguage = 'Finnish' then ItemIndex := {#MDB_FIN_INDEX};
        if ActiveLanguage = 'Albanian' then ItemIndex := {#MDB_SQI_INDEX};
        if ActiveLanguage = 'French' then ItemIndex := {#MDB_FRA_INDEX};
        if ActiveLanguage = 'Greek' then ItemIndex := {#MDB_ELL_INDEX};
        if ActiveLanguage = 'Romanian' then ItemIndex := {#MDB_ROM_INDEX};

  end;

  Result := Page.ID;
end;

Приложение

На приведенной выше пользовательской странице необходимо следующее:

; Language descriptions
#define LANG_ENG "'English'"
#define LANG_ESP "'Español'"
#define LANG_DEU "'Deutsch'"
#define LANG_ITA "'Italiano'"
#define LANG_NLD "'Nederlands'"
#define LANG_TRK "'Türkçe'"
#define LANG_PTB "'Português'"
#define LANG_SVE "'Svenska'"
#define LANG_DAN "'Dansk'"
#define LANG_RUS "'Русский'"
#define LANG_FIN "'Suomi'"
#define LANG_AFK "'Afrikaans'"
#define LANG_CHS "'汉语(简化字)'"
#define LANG_SQI "'Shqip'"
#define LANG_FRA "'Française'"
#define LANG_BGR "'Български'"
#define LANG_TWI "'Akan'"
#define LANG_FPO "'Tagalog'"
#define LANG_SWK "'Kiswahili'"
#define LANG_ELL "'Ελληνική'"
#define LANG_UKR "'Українська'"
#define LANG_KHM "'Cambodian'"
#define LANG_ROM "'Română'"
#define LANG_SMO "'Faa-Sāmoa'"
#define LANG_IND "'Indonesia'"
#define LANG_VIT "'Vietnamese'"
#define LANG_ARA "'العربية'"
#define LANG_PLK "'Polski'"
#define LANG_SRN "'Sranantongo'"

Если мы удалим MDB_XXX_LANGКонстанты

Тогда мы должны также рассмотреть:

{ event called when the Ready page (summary) is about to be displayed }
function UpdateReadyMemo(Space, NewLine, MemoUserInfoInfo, MemoDirInfo, MemoTypeInfo, MemoComponentsInfo, MemoGroupInfo, MemoTasksInfo: String): String;
var
    strText: String;
begin
  { Fill the 'Ready Memo' with the normal settings and the custom settings }
  strText := '';

  strText := strText + MemoDirInfo + NewLine + NewLine;
  strText := strText + MemoGroupInfo + NewLine + NewLine;
  strText := strText + MemoTasksInfo + NewLine + NewLine;

  if (not IsUpgrading) then
  begin
    strText := strText + ExpandConstant('{cm:Defaultsettings}') + NewLine;

    { We now test against user settings directly from the page. }
    { Memo text strings are expanding directly. }
    if chkRememberLastCong.Checked = True then
    begin
        strText := strText + Space;
        strText := strText + ExpandConstant('{cm:MemoRememberCongregation}');
        strText := strText + NewLine;
    end;

    if chkDuplicates.Checked = True then
    begin
        strText := strText + Space;
        strText := strText + ExpandConstant('{cm:MemoCheckDuplicates}');
        strText := strText + NewLine;
    end;

    { Database language }
    strText := strText + Space;
    strText := strText + ExpandConstant('{cm:DatabaseLanguage} ');
    if cbDatabase.ItemIndex = {#MDB_ENG_INDEX} then begin
        strText := strText + {#LANG_ENG};
    end else if cbDatabase.ItemIndex = {#MDB_DEU_INDEX} then begin
        strText := strText + {#LANG_DEU};
    end else if cbDatabase.ItemIndex = {#MDB_ESP_INDEX} then begin
        strText := strText + {#LANG_ESP};
    end else if cbDatabase.ItemIndex = {#MDB_ITA_INDEX} then begin
        strText := strText + {#LANG_ITA};
    end else if cbDatabase.ItemIndex = {#MDB_NLD_INDEX} then begin
        strText := strText + {#LANG_NLD};
    end else if cbDatabase.ItemIndex = {#MDB_TRK_INDEX} then begin
        strText := strText + {#LANG_TRK};
    end else if cbDatabase.ItemIndex = {#MDB_SVE_INDEX} then begin
        strText := strText + {#LANG_SVE};
    end else if cbDatabase.ItemIndex = {#MDB_PTB_INDEX} then begin
        strText := strText + {#LANG_PTB};
    end else if cbDatabase.ItemIndex = {#MDB_DAN_INDEX} then begin
        strText := strText + {#LANG_DAN};
    end else if cbDatabase.ItemIndex = {#MDB_RUS_INDEX} then begin
        strText := strText + {#LANG_RUS};
    end else if cbDatabase.ItemIndex = {#MDB_FIN_INDEX} then begin
        strText := strText + {#LANG_FIN};
    end else if cbDatabase.ItemIndex = {#MDB_AFK_INDEX} then begin
        strText := strText + {#LANG_AFK};
    end else if cbDatabase.ItemIndex = {#MDB_CHS_INDEX} then begin
        strText := strText + {#LANG_CHS};
    end else if cbDatabase.ItemIndex = {#MDB_SQI_INDEX} then begin
        strText := strText + {#LANG_SQI};
    end else if cbDatabase.ItemIndex = {#MDB_FRA_INDEX} then begin
        strText := strText + {#LANG_FRA};
    end else if cbDatabase.ItemIndex = {#MDB_BGR_INDEX} then begin
        strText := strText + {#LANG_BGR};
    end else if cbDatabase.ItemIndex = {#MDB_TWI_INDEX} then begin
        strText := strText + {#LANG_TWI};
    end else if cbDatabase.ItemIndex = {#MDB_FPO_INDEX} then begin
        strText := strText + {#LANG_FPO};
    end else if cbDatabase.ItemIndex = {#MDB_SWK_INDEX} then begin
        strText := strText + {#LANG_SWK};
    end else if cbDatabase.ItemIndex = {#MDB_ELL_INDEX} then begin
        strText := strText + {#LANG_ELL};
    end else if cbDatabase.ItemIndex = {#MDB_UKR_INDEX} then begin
        strText := strText + {#LANG_UKR};
    end else if cbDatabase.ItemIndex = {#MDB_KHM_INDEX} then begin
        strText := strText + {#LANG_KHM};
    end else if cbDatabase.ItemIndex = {#MDB_ROM_INDEX} then begin
        strText := strText + {#LANG_ROM};
    end else if cbDatabase.ItemIndex = {#MDB_SMO_INDEX} then begin
        strText := strText + {#LANG_SMO};
    end else if cbDatabase.ItemIndex = {#MDB_IND_INDEX} then begin
        strText := strText + {#LANG_IND};
    end else if cbDatabase.ItemIndex = {#MDB_VIT_INDEX} then begin
        strText := strText + {#LANG_VIT};
    end else if cbDatabase.ItemIndex = {#MDB_ARA_INDEX} then begin
        strText := strText + {#LANG_ARA};
    end else if cbDatabase.ItemIndex = {#MDB_PLK_INDEX} then begin
        strText := strText + {#LANG_PLK};
    end else if cbDatabase.ItemIndex = {#MDB_SRN_INDEX} then begin
        strText := strText + {#LANG_SRN};
    end;
    strText := strText + NewLine;
  end;

  Result := strText;
end;

1 Ответ

1 голос
/ 05 июня 2019

С этим кодом препроцессора:

[Code]
var
  cbDatabase: TNewListBox;

{ Returns True if the user selected the same database language in the combo }
function CheckMDBLang(LangText: string): boolean;
begin
  Result := (cbDatabase.Text = LangText);
end;

#define DatabaseFiles() \
    DatabaseFile('English', 'English') + \
    DatabaseFile('Spanish', 'Español')

[Files]
#define DatabaseFile(Name, Text) \
    'Source: "..\inno\Databases\' + Name + '.mdb"; DestDir: "{app}"; ' + \
    'DestName: "Default.mdb"; Flags: overwritereadonly uninsremovereadonly; ' + \
    'Attribs: readonly; Check: CheckMDBLang(''' + Text + ''')' + NewLine + \
    'Source: "..\inno\Databases\' + Name + '.accdb"; DestDir: "{app}"; ' + \
    'DestName: "Default.accdb"; Flags: overwritereadonly uninsremovereadonly; ' + \
    'Attribs: readonly; Check: CheckMDBLang(''' + Text + ''')' + NewLine

{#DatabaseFiles}

[Code]

function AppSettings_CreatePage(PreviousPageId: Integer): Integer;
begin
  cbDatabase := TNewComboBox.Create(Page);
  with cbDatabase do
  begin
    #define DatabaseFile(Name, Text) \
        'Items.Add(''' + Text + ''');' + NewLine + \
        'if ActiveLanguage = ''' + Name + ''' then ItemIndex := Items.Count - 1;' + NewLine

    {#DatabaseFiles}
  end;
end;

Вы получите:

[Files]
Source: "..\inno\Databases\English.mdb"; DestDir: "{app}"; DestName: "Default.mdb"; Flags: overwritereadonly uninsremovereadonly; Attribs: readonly; Check: CheckMDBLang('English')
Source: "..\inno\Databases\English.accdb"; DestDir: "{app}"; DestName: "Default.accdb"; Flags: overwritereadonly uninsremovereadonly; Attribs: readonly; Check: CheckMDBLang('English')
Source: "..\inno\Databases\Spanish.mdb"; DestDir: "{app}"; DestName: "Default.mdb"; Flags: overwritereadonly uninsremovereadonly; Attribs: readonly; Check: CheckMDBLang('Spanish')
Source: "..\inno\Databases\Spanish.accdb"; DestDir: "{app}"; DestName: "Default.accdb"; Flags: overwritereadonly uninsremovereadonly; Attribs: readonly; Check: CheckMDBLang('Spanish')

[Code]

function AppSettings_CreatePage(PreviousPageId: Integer): Integer;
begin
  cbDatabase := TNewComboBox.Create(Page);
  with cbDatabase do
  begin
    Items.Add('English');
    if ActiveLanguage = 'English' then ItemIndex := Items.Count - 1;
    Items.Add('Español');
    if ActiveLanguage = 'Spanish' then ItemIndex := Items.Count - 1;
  end;
end;

И вам вообще не нужно определять все эти индексы.

(непроверенные)

В UpdateReadyMemo вы можете заменить весь код языка одной строкой:

strText := strText + cbDatabase.Text;
...