2013-10-04 134 views
3

我一直在创建Inno Setup的自定义页面。我有下面的示例代码示例,但是当我在Inno安装脚本编辑器中运行时,弹出一个编译器错误。它说:“编译器错误:第63行:第3列:未知标识符”authentication_form_CreatePage“。 我看不到任何错误,但有一个,如果有人能看到它并知道它,请你帮我解决这个问题?Inno Setup的自定义页面向导

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

#define MyAppName "NewSampleSetup" 
#define MyAppVersion "1.0" 
#define MyAppPublisher "Example" 
#define MyAppURL "http://www.example.com/" 
#define MyAppExeName "BarChartExample2.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={{8226770F-1270-434F-B53E-5539E78AD05B} 
AppName={#MyAppName} 
AppVersion={#MyAppVersion} 
;AppVerName={#MyAppName} {#MyAppVersion} 
AppPublisher={#MyAppPublisher} 
AppPublisherURL={#MyAppURL} 
AppSupportURL={#MyAppURL} 
AppUpdatesURL={#MyAppURL} 
DefaultDirName={pf}\{#MyAppName} 
DefaultGroupName={#MyAppName} 
AllowNoIcons=yes 
OutputDir=C:\Users\Intern1\Documents\Inno Setup Examples Output 
OutputBaseFilename=Setup 
Compression=lzma 
SolidCompression=yes 

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

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

[Files] 
Source: "C:\Users\stajyer1\Documents\Visual Studio    2012\Projects\BarChartExample2\BarChartExample2\bin\Debug\BarChartExample2.exe"; DestDir: "  {app}"; Flags: ignoreversion 
; 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: nowait postinstall skipifsilent 

[CustomMessages] 
authentication_form_Caption=SQL Server Database Setup 
authentication_form_Description=Choose SQL Server database you will be using (ask your  administrator about its parameters) 
authentication_form_Label1_Caption0=Server Name: 
authentication_form_Label2_Caption0=Enter Path to SQL Server (e.g. .\SQLEXPRESS; DEVSERVER) 
authentication_form_Label3_Caption0=User name: 
authentication_form_Label4_Caption0=Password: 
authentication_form_ServerNameEdit_Text0=- 
authentication_form_WindowsRadioButton_Caption0=Use Windows Authentication 
authentication_form_SqlRadioButton_Caption0=Use SQL Authentication 
authentication_form_UserEdit_Text0=- 
authentication_form_PasswordEdit_Text0=- 

[Code] 
procedure InitializeWizard(); 
begin 
authentication_form_CreatePage(wpLicense); 
end; 

var 
Label1: TLabel; 
Label2: TLabel; 
Label3: TLabel; 
Label4: TLabel; 
ServerNameEdit: TEdit; 
WindowsRadioButton: TRadioButton; 
SqlRadioButton: TRadioButton; 
UserEdit: TEdit; 
PasswordEdit: TEdit; 

function authentication_form_CreatePage(PreviousPageId: Integer): Integer; 
var 
Page: TWizardPage; 
begin 
Page := CreateCustomPage(
PreviousPageId, 
ExpandConstant('{cm:authentication_form_Caption}'), 
ExpandConstant('{cm:authentication_form_Description}') 
); 
Label1 := TLabel.Create(Page); 
with Label1 do 
begin 
Parent := Page.Surface; 
Caption := ExpandConstant('{cm:authentication_form_Label1_Caption0}'); 
Left := ScaleX(16); 
Top := ScaleY(0); 
Width := ScaleX(84); 
Height := ScaleY(17); 
end; 

Label2 := TLabel.Create(Page); 
with Label2 do 
begin 
Parent := Page.Surface; 
Caption := ExpandConstant('{cm: authentication_form_Label2_Caption0}'); 
Left := ScaleX(16); 
Top := ScaleY(56); 
Width := ScaleX(300); 
Height := ScaleY(17); 
end; 

Label3 := TLabel.Create(Page); 
with Label3 do 
begin 
Parent := Page.Surface; 
Caption := ExpandConstant('{cm: authentication_form_Label3_Caption0}'); 
Left := ScaleX(56); 
Top := ScaleY(136); 
Width := ScaleX(70); 
Height := ScaleY(17); 
end; 

Label4 := TLabel.Create(Page); 
with Label4 do 
begin 
Parent := Page.Surface; 
Caption := ExpandConstant('{cm: authentication_form_Label4_Caption0}'); 
Left := ScaleX(56); 
Top := ScaleY(168); 
Width := ScaleX(63); 
Height := ScaleY(17); 
end; 

ServerNameEdit := TEdit.Create(Page); 
with ServerNameEdit do 
begin 
Parent := Page.Surface; 
Left := ScaleX(16); 
Top := ScaleY(24); 
Width := ScaleX(257); 
Height := ScaleY(25); 
TabOrder := 0; 
Text := ExpandConstant('{cm: authentication_form_ServerNameEdit_Text0}'); 
end; 

WindowsRadioButton := TRadioButton.Create(Page); 
with WindowsRadioButton do 
begin 
Parent := Page.Surface; 
Caption := ExpandConstant('{cm: authentication_form_WindowsRadioButton_Caption0}'); 
Left := ScaleX(16); 
Top := ScaleY(88); 
Width := ScaleX(225); 
Height := ScaleY(17); 
Checked := True; 
TabOrder := 1; 
TabStop := True; 
end; 

SqlRadioButton := TRadioButton.Create(Page); 
with SqlRadioButton do 
begin 
Parent := Page.Surface; 
Caption := ExpandConstant('{cm: authentication_form_SqlRadioButton_Caption0}'); 
Left := ScaleX(16); 
Top := ScaleY(112); 
Width := ScaleX(193); 
Height := ScaleY(17); 
TabOrder := 2; 
end; 

UserEdit := TEdit.Create(Page); 
with UserEdit do 
begin 
Parent := Page.Surface; 
Left := ScaleX(136); 
Top := ScaleY(136); 
Width := ScaleX(121); 
Height := ScaleY(25); 
TabOrder := 3; 
Text := ExpandConstant('{cm: authentication_form_UserEdit_Text0}'); 
end; 

PasswordEdit := TEdit.Create(Page); 
with PasswordEdit do 
begin 
Parent := Page.Surface; 
Left := ScaleX(136); 
Top := ScaleY(168); 
Width := ScaleX(121); 
Height := ScaleY(25); 
TabOrder := 4; 
PasswordChar := '*'; 
Text := ExpandConstant('{cm: authentication_form_PasswordEdit_Text0}'); 
end; 

with Page do 
begin 
    OnNextButtonClick := @authentication_form_NextButtonClick; 
end; 

Result := Page.ID; 
end; 

function authentication_form_NextButtonClick(Page: TWizardPage): Boolean; 
begin 
Result := True; 
if ServerNameEdit.Text <> '' then 
begin 
    if SqlRadioButton.Checked then 
    begin 
     if UserEdit.Text = '' then 
     begin 
     MsgBox('You should enter user name', mbError, MB_OK); 
     Result := False; 
     end 
     else 
     begin 
     if PasswordEdit.Text = '' then 
     begin 
      MsgBox('You should enter password', mbError, MB_OK); 
      Result := False; 
     end 
     end 
    end 
end 
else 
begin 
MsgBox('You should enter path to SQL Server Database', mbError, MB_OK); 
Result := False; 
end; 
end; 

回答

1

试试这个:

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

#define MyAppName "NewSampleSetup" 
#define MyAppVersion "1.0" 
#define MyAppPublisher "Example" 
#define MyAppURL "http://www.example.com/" 
#define MyAppExeName "BarChartExample2.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={{8226770F-1270-434F-B53E-5539E78AD05B} 
AppName={#MyAppName} 
AppVersion={#MyAppVersion} 
;AppVerName={#MyAppName} {#MyAppVersion} 
AppPublisher={#MyAppPublisher} 
AppPublisherURL={#MyAppURL} 
AppSupportURL={#MyAppURL} 
AppUpdatesURL={#MyAppURL} 
DefaultDirName={pf}\{#MyAppName} 
DefaultGroupName={#MyAppName} 
AllowNoIcons=yes 
OutputDir=C:\Users\sandaa\Desktop 
OutputBaseFilename=Setup 
Compression=lzma 
SolidCompression=yes 

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

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

[Files] 
;Source: "C:\Users\stajyer1\Documents\Visual Studio 2012\Projects\BarChartExample2\BarChartExample2\bin\Debug\BarChartExample2.exe"; DestDir: "  {app}"; Flags: ignoreversion 
; 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: nowait postinstall skipifsilent 


[Code] 
var 

    FirstLabel: TLabel; 
    SecondLabel: TLabel; 
    ThirdLabel: TLabel; 
    FourthLabel: TLabel; 
    ServerNameTextBox: TEdit; 
    WindowsRadioButton: TRadioButton; 
    SQLRadioButton: TRadioButton; 
    txtUserName: TEdit; 
    txtPassword: TEdit; 


function AuthenticateDataPage(Page: TWizardPage): Boolean; 
begin 
    Result :=True; 
    if ServerNameTextBox.Text <> '' then 
    begin 
     if SQLRadioButton.Checked then 
      begin 
       if txtUserName.Text ='' then 
        begin 
         MsgBox('You should enter user name', mbError, MB_OK); 
          Result :=False; 
         end 
        else 
         begin 
          if txtPassword.Text ='' then 
           begin 
            MsgBox('You should enter password', mbError, MB_OK); 
            Result :=False; 
          end 
         end 
        end 
       end 
      else 
      begin 
       MsgBox('You should enter path to SQL Server Database', mbError, MB_OK); 
       Result :=False; 
    end; 
end; 


function CreateDataPage(PreviousPageId: Integer): Integer; 
var 
    Page: TWizardPage; 
begin 
    Page :=CreateCustomPage(PreviousPageId,'SQL Server Database Setup', 
    'Choose SQL Server database you will be using (ask your administrator about its parameters'); 

    FirstLabel :=TLabel.Create(Page); 
    with FirstLabel do 
    begin 
     Parent :=Page.Surface; 
     Caption :='Server Name'; 
     Left :=ScaleX(16); 
     Top :=ScaleY(0); 
     Width :=ScaleX(84); 
     Height :=ScaleY(17); 
    end; 

    SecondLabel :=TLabel.Create(Page); 
    With SecondLabel Do 
    begin 
     Parent :=Page.Surface; 
     Caption :='Enter Path to SQL Server (e.g. .\SQLEXPRESS; DEVSERVER)'; 
     Left :=ScaleX(16); 
     Top :=ScaleY(56); 
     Width :=ScaleX(300); 
     Height :=ScaleY(17); 
    end; 

    ThirdLabel :=TLabel.Create(Page); 
    with ThirdLabel do 
     begin 
      Parent :=Page.Surface; 
      Caption :='User name'; 
      Left :=ScaleX(56); 
      Top :=ScaleY(136); 
      Width :=ScaleX(70); 
      Height :=ScaleY(17); 
     end; 

    FourthLabel :=TLabel.Create(Page); 
    with FourthLabel do 
    begin 
      Parent :=Page.Surface; 
      Caption :='Password'; 
      Left :=ScaleX(56); 
      Top :=ScaleY(168); 
      Width :=ScaleX(63); 
      Height :=ScaleY(17); 
    end; 

    ServerNameTextBox :=TEdit.Create(Page); 
    with ServerNameTextBox do 
    begin 
      Parent :=Page.Surface; 
      Left :=ScaleX(16); 
      Top :=ScaleY(24); 
      Width :=ScaleX(257); 
      Height :=ScaleY(25); 
      TabOrder :=0; 
      Text :=''; 
    end; 


    WindowsRadioButton :=TRadioButton.Create(Page); 
    with WindowsRadioButton do 
    begin 
     Parent :=Page.Surface; 
     Caption :='Use Windows Authentication'; 
     Left :=ScaleX(16); 
     Top :=ScaleY(88); 
     Width :=ScaleX(225); 
     Height :=ScaleY(17); 
     Checked :=True; 
     TabOrder :=1; 
     TabStop :=True; 
    end; 

    SQLRadioButton :=TRadioButton.Create(Page); 
    with SQLRadioButton do 
     begin 
     Parent :=Page.Surface; 
     Caption :='Use SQL Authentication'; 
     Left :=ScaleX(16); 
     Top :=ScaleY(112); 
     Width :=ScaleX(193); 
     Height :=ScaleY(17); 
     TabOrder :=2; 
    end; 


    txtUserName :=TEdit.Create(Page); 
    with txtUserName do 
    begin 
     Parent :=Page.Surface; 
     Left :=ScaleX(136); 
     Top :=ScaleY(136); 
     Width :=ScaleX(121); 
     Height :=ScaleY(25); 
     TabOrder :=3; 
     Text :=''; 
    end; 

    txtPassword :=TEdit.Create(Page); 
    with txtPassword do 
    begin 
     Parent :=Page.Surface; 
     Left :=ScaleX(136); 
     Top :=ScaleY(168); 
     Width :=ScaleX(121); 
     Height :=ScaleY(25); 
     TabOrder :=4; 
     PasswordChar :='*'; 
     Text :=''; 
    end; 


    with Page do 
    begin 
     OnNextButtonClick :[email protected]; 
    end; 

    Result :=Page.ID; 

end; 

procedure InitializeWizard(); 
begin 
    CreateDataPage(wpLicense); 
end; 

我离开的唯一的事情就是custommessages

+0

谢谢它正常工作 – hburakceng

+0

将很好扩展为什么,顺便说一句... – TLama

+0

我认为这是关于帕斯卡尔脚本的范围。它具有静态范围。 – hburakceng

1

,您可以转发,声明的方法,像authentication_form_CreatePage如果你不喜欢重新排序。你的方法:

//forward declaration 
function authentication_form_CreatePage(PreviousPageId: Integer): Integer; forward; 

procedure InitializeWizard(); 
begin 
    //the method is known to the compiler, even before he looked into it 
    authentication_form_CreatePage(wpLicense); 
end; 

function authentication_form_CreatePage(PreviousPageId: Integer): Integer; 
begin 
    ... actual implementation ... 
end; 
+0

为什么不呢? :) –

相关问题