2016-11-09 5 views
1

私は今、私が望むスクリプトを組み合わせていますが、エラーがあります。異なるソースからのイベント関数(InitializeWizard)実装のマージ

Screenshot

私は期間を置いた場合、それが実行されても、他の機能が不足しているだろう。

procedure InitializeWizard; 
begin 
    MessageBoxTimeout(WizardForm.Handle, 'MsgBox ' + 
    Timeout 'Setup', MB_OK or MB_ICONINFORMATION, 0, 2000); 
end; 

var 
    TuneLabel: TLabel; 

begin 
    ExtractTemporaryFile('tune.xm'); 
    if BASS_Init(-1, 44100, 0, 0, 0) then 
    begin 
    SoundCtrlButton := TNewButton.Create(WizardForm); 
    Music := BASS_MusicLoad(False, 
     ExpandConstant('{tmp}\tune.xm'), 0, 0, 
     EncodingFlag or BASS_SAMPLE_LOOP, 0); 
    BASS_SetConfig(BASS_CONFIG_GVOL_STREAM, 10000); 
    BASS_ChannelPlay(Music, False); 

    SoundCtrlButton := TNewButton.Create(WizardForm); 
    SoundCtrlButton.Parent := WizardForm; 
    SoundCtrlButton.Left := 10; 
    SoundCtrlButton.TabStop := False; 
    SoundCtrlButton.Top := WizardForm.ClientHeight - 
     SoundCtrlButton.Height - 9; 
    SoundCtrlButton.Width := 40; 
    SoundCtrlButton.Caption := 
     ExpandConstant('{cm:SoundCtrlButtonCaptionSoundOff}'); 
    SoundCtrlButton.OnClick := @SoundCtrlButtonClick; 
    TuneLabel := TLabel.Create(WizardForm); 
    TuneLabel.Parent := WizardForm; 
    TuneLabel.Caption := 'Tune'; 
    TuneLabel.Left := SoundCtrlButton.Left + SoundCtrlButton.Width + ScaleX(5); 
    TuneLabel.Top := 
     SoundCtrlButton.Top + ((SoundCtrlButton.Height - TuneLabel.Height) div 2); 
    end; 
end; 

エラーが最後end;後の行を参照:

は、ここに私のコードです。

私を助けてください。

答えて

1

異なるソースからさまざまな機能の実装を再利用する場合、これらは一般的に同じInno Setup event functionsInitializeWizardなど)を実装します。

これらのイベント関数をマージする必要があるのは、関数実装が1つだけであるためです。

異なるインプリメンテーションに一意のサフィックスを追加し、メインのインプリメンテーションからそれらを呼び出すことで可能です。

主な実装は、他の実装より下になければなりません。例えば

つのソースとして実装InitializeWizardイベント機能を有する場合、:

として
var 
    GlobalVariable1: Integer; 

procedure SubProcedure1; 
begin 
    { blah } 
end; 

procedure InitializeWizard; 
var 
    Variable1: Integer; 
    Variable2: Integer; 
begin 
    Variable1 := GlobalVariable1; 
    SubProcedure1; 
end; 

他方のソース:

var 
    GlobalVariableA: Integer; 

procedure SubProcedureA; 
begin 
    { blah } 
end; 

procedure InitializeWizard; 
var 
    VariableA: Integer; 
begin 
    VariableA := GlobalVariableA; 
    SubProcedureA; 
end; 

を次にマージコードがなければならない:

var 
    GlobalVariable1: Integer; 

procedure SubProcedure1; 
begin 
    { blah } 
end; 

procedure InitializeWizard1; 
var 
    Variable1: Integer; 
    Variable2: Integer; 
begin 
    Variable1 := GlobalVariable1; 
    SubProcedure1; 
end; 

var 
    GlobalVariableA: Integer; 

procedure SubProcedureA; 
begin 
    { blah } 
end; 

procedure InitializeWizard2; 
var 
    VariableA: Integer; 
begin 
    VariableA := GlobalVariableA; 
    SubProcedureA; 
end; 

procedure InitializeWizard; 
begin 
    InitializeWizard1; 
    InitializeWizard2; 
end; 

も参照してくださいInno Setup - Merging implementations of event functions that return boolean (like InitializeSetup)


だから、あなたの特定のケースでは、コードは次のようになります。

procedure InitializeWizard1; 
begin 
    MessageBoxTimeout(WizardForm.Handle, 'MsgBox ' + 
    Timeout 'Setup', MB_OK or MB_ICONINFORMATION, 0, 2000); 
end; 

procedure InitializeWizard2; 
var 
    TuneLabel: TLabel; 
begin 
    ExtractTemporaryFile('tune.xm'); 
    if BASS_Init(-1, 44100, 0, 0, 0) then 
    begin 
    SoundCtrlButton := TNewButton.Create(WizardForm); 
    Music := BASS_MusicLoad(False, 
     ExpandConstant('{tmp}\tune.xm'), 0, 0, 
     EncodingFlag or BASS_SAMPLE_LOOP, 0); 
    BASS_SetConfig(BASS_CONFIG_GVOL_STREAM, 10000); 
    BASS_ChannelPlay(Music, False); 

    SoundCtrlButton := TNewButton.Create(WizardForm); 
    SoundCtrlButton.Parent := WizardForm; 
    SoundCtrlButton.Left := 10; 
    SoundCtrlButton.TabStop := False; 
    SoundCtrlButton.Top := WizardForm.ClientHeight - 
     SoundCtrlButton.Height - 9; 
    SoundCtrlButton.Width := 40; 
    SoundCtrlButton.Caption := 
     ExpandConstant('{cm:SoundCtrlButtonCaptionSoundOff}'); 
    SoundCtrlButton.OnClick := @SoundCtrlButtonClick; 
    TuneLabel := TLabel.Create(WizardForm); 
    TuneLabel.Parent := WizardForm; 
    TuneLabel.Caption := 'Tune'; 
    TuneLabel.Left := SoundCtrlButton.Left + SoundCtrlButton.Width + ScaleX(5); 
    TuneLabel.Top := 
     SoundCtrlButton.Top + ((SoundCtrlButton.Height - TuneLabel.Height) div 2); 
    end; 
end; 

procedure InitializeWizard; 
begin 
    InitializeWizard1; 
    InitializeWizard2; 
end; 
関連する問題