visitor (0 QPoints)
  • FR
  • EN
  • NL
  • DE
  • ES
315 experts, 1193 registered users, 1659 questions already answered
European Experts Exchange, the very best site for high-quality IT solutions

New Improved Search!

 


05/10/2011 1h30 : Steve Jobs is dead, the father of Apple ][ is gone, we are all orphaned.

Languages :: Pascal :: testing user-entered values


By: danielletx U.S.A.  Date: 13/07/2003 00:00:00  English  Points: 100 Status: Answered
Quality : Excellent
i am using inno setup version 4 beta and attempting to make my setup script invoke a pascal

n in which i would like to make a special screen to ask whether to perform a client or a server install. if the user selects a client install, then i want to change the target field of my shortcut to point to the network drive of the server (i.e., h:\program files\myapp)--or whereever the user has installed the application. i have all of that actually working. but i don't understand the if/then syntax of pascal well enough to check user-enter values and make certain screens dependent upon that.

this is what i have so far (...the second part of the case statement needs to be conditional upon performing a client install, but i can't get the syntax of the if statement to test the value of the radio button):

---
[Code]
function ScriptDlgPages(CurPage: Integer; BackClicked: Boolean): Boolean;
var
CurSubPage: Integer;
Next: Boolean;
CheckListBox: TNewCheckListBox;
DirectoryListBox: TNewDirectoryListBox;
DriveComboBox: TNewDriveComboBox;
begin
if (not BackClicked and (CurPage = wpWelcome)) or (BackClicked and (CurPage = wpReady)) then begin
if not BackClicked then
CurSubPage := 0
else
CurSubPage := 4;
ScriptDlgPageOpen();
ScriptDlgPageSetCaption('Select Install Type');
ScriptDlgPageSetSubCaption2('');
while (CurSubPage >= 0) and (CurSubPage <= 4) and not Terminated do begin
case CurSubPage of
0:
begin
ScriptDlgPageClearCustom();

CheckListBox := TNewCheckListBox.Create(WizardForm.ScriptDlgPanel);
CheckListBox.BorderStyle := bsNone;
CheckListBox.Color := WizardForm.Color;
CheckListBox.MinItemHeight := WizardForm.TasksList.MinItemHeight;
CheckListBox.ShowLines := False;
CheckListBox.WantTabs := True;
CheckListBox.Flat := True;
CheckListBox.Width := WizardForm.ScriptDlgPanel.Width;
CheckListBox.Parent := WizardForm.ScriptDlgPanel;
CheckListBox.AddGroup('Are you installing this copy of IVY BackOffice on your company server?', '', 0, nil);
CheckListBox.AddRadioButton('Yes', '', 0, 0, True, True, nil);
CheckListBox.AddRadioButton('No', '', 0, 0, False, True, nil);

Next := ScriptDlgPageProcessCustom();
end;
1:
begin
ScriptDlgPageSetCaption('Client Installation');
ScriptDlgPageSetSubCaption1('Please locate the installation of IVY BackOffice on your server.');
ScriptDlgPageClearCustom();

DriveComboBox := TNewDriveComboBox.Create(WizardForm.ScriptDlgPanel);
DriveComboBox.Width := WizardForm.ScriptDlgPanel.Width;
DriveComboBox.Parent := WizardForm.ScriptDlgPanel;

DirectoryListBox := TNewDirectoryListBox.Create(WizardForm.ScriptDlgPanel);
DirectoryListBox.Top := DriveComboBox.Top + DriveComboBox.Height + 8;
DirectoryListBox.Width := WizardForm.ScriptDlgPanel.Width;
DirectoryListBox.Height := WizardForm.ScriptDlgPanel.Height - DirectoryListBox.Top;
DirectoryListBox.Parent := WizardForm.ScriptDlgPanel;
DirectoryListBox.Directory := ExpandConstant('{src}');

DriveComboBox.DirList := DirectoryListBox;

Next := ScriptDlgPageProcessCustom();
end;
end;
if Next then
CurSubPage := CurSubPage + 1
else
CurSubPage := CurSubPage - 1;
end;
if not BackClicked then
Result := Next
else
Result := not Next;
ScriptDlgPageClose(not Result);
end else
Result := True;
end;

function NextButtonClick(CurPage: Integer): Boolean;
begin
Result := ScriptDlgPages(CurPage, False);
end;

function BackButtonClick(CurPage: Integer): Boolean;
begin
Result := ScriptDlgPages(CurPage, True);
end;
---

...i haven't programmed any pascal since college (ten years ago!), and so i'm afraid i'm a bit rusty. can anyone help?

thank you very much!
danielle
<A HREF="http://www.brownflower.com/danielletx">http://www.brownflower.com/danielletx</a>
By: VGR Date: 13/07/2003 03:47:00 English  Type : Comment
the if..then..else... of Pascal is 3000% the same as any if...then...else around the World
By: VGR Date: 13/07/2003 03:47:00 English  Type : Comment
if (condition) then (this) else (that)
By: VGR Date: 13/07/2003 03:49:00 English  Type : Comment
so your problem becomes : how am I suppsoed to devinate the condition expressing programmatically the condition expressed humanly (above) : "am I performing a client install?"
By: VGR Date: 13/07/2003 03:53:00 English  Type : Answer
I simplify your function back to its semantics :

function ScriptDlgPages(CurPage: Integer; BackClicked: Boolean): Boolean;
var CurSubPage: Integer; // blahblahbla
begin
if (not BackClicked and (CurPage = wpWelcome)) or (BackClicked and (CurPage = wpReady)) then begin
if not BackClicked then CurSubPage := 0 else CurSubPage := 4;
// blablbalbah on ScriptDlgPageOpen();
while (CurSubPage >= 0) and (CurSubPage <= 4) and not Terminated do begin
case CurSubPage of
0: // blahblablah on ScriptDlgPageClearCustom();
1: // idem on ??? with ScriptDlgPageSetCaption('Client Installation');
end; // case of
if Next then CurSubPage := CurSubPage + 1 else CurSubPage := CurSubPage - 1;
end; // while
if not BackClicked then Result := Next else Result := not Next;
ScriptDlgPageClose(not Result);
end else Result := True;
end;

// so now, please tell me what is the problem exactly
By: danielletx Date: 13/07/2003 12:52:00 English  Type : Comment
well, using the code:

MsgBox('You selected: ''' + DirectoryListBox.Directory + '''.', mbInformation, MB_OK);

...i was able to pass the user-selected directory to a msgbox. the problem is that i want to pass whatever directory the user selects to a windows shortcut icon (i.e., the target part of the shortcut) so that the shortcut will point to the program installation on the server. (even though the program is installed in c:\program files on the server, i can't predict what network drive letter the user will have mapped to the server...or what server volume name i might need to use...)

so. that's my specific problem. here's the full inno setup script file--(the

n is where all my pascal goes).

thank you for your help! :)
danielle

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

[Setup]
AppName=IVY BackOffice
AppVerName=IVY BackOffice Beta 2.1
AppPublisher=The Brownflower Creative Group
AppPublisherURL=<A HREF="http://www.brownflower.com/ivy">http://www.brownflower.com/ivy</a>
AppSupportURL=<A HREF="http://www.brownflower.com/ivy">http://www.brownflower.com/ivy</a>
AppUpdatesURL=<A HREF="http://www.brownflower.com/ivy">http://www.brownflower.com/ivy</a>
DefaultDirName={pf}\IVY BackOffice
DisableDirPage=true
DefaultGroupName=IVY BackOffice
AllowNoIcons=true
LicenseFile=C:\work\school\abc\scheduler\beta versions\beta 2.1 distribution\license.txt
InfoBeforeFile=C:\work\school\abc\scheduler\beta versions\beta 2.1 distribution\readme.txt
Password=abcllen
MinVersion=95,4.0
AppCopyright=The Brownflower Creative Group
AppVersion=Beta 2.1
UninstallDisplayIcon={app}\ivyicon.ico
UninstallDisplayName=IVY BackOffice Beta 2.1
UsePreviousSetupType=false
UsePreviousTasks=false

[Tasks]
; NOTE: The following entry contains English phrases ("Create a desktop icon" and "Additional icons"). You are free to translate them into another language if required.
Name: desktopicon; Description: Create a &desktop icon; GroupDescription: Additional icons:
; NOTE: The following entry contains English phrases ("Create a Quick Launch icon" and "Additional icons"). You are free to translate them into another language if required.
Name: quicklaunchicon; Description: Create a &Quick Launch icon; GroupDescription: Additional icons:; Flags: unchecked

[Dirs]
Name: {app}\backup; Flags: uninsneveruninstall

[Files]
Source: "{app}\ivy.mdb"; DestDir: "{app}\backup"; Flags: external skipifsourcedoesntexist uninsneveruninstall
Source: "C:\work\school\abc\scheduler\beta versions\beta 2.1 distribution\ivy.mdb"; DestDir: "{app}"; Flags: ignoreversion
Source: "C:\work\school\abc\scheduler\beta versions\beta 2.1 distribution\*.*"; DestDir: "{app}"; Flags: ignoreversion
; NOTE: Don't use "Flags: ignoreversion" on any shared system files

[Icons]
Name: {group}\IVY BackOffice; Filename: {app}\IVY BackOffice.lnk
; NOTE: The following entry contains an English phrase ("Uninstall"). You are free to translate it into another language if required.
Name: {group}\Uninstall IVY BackOffice; Filename: {uninstallexe}
Name: {userdesktop}\IVY BackOffice; Filename: {app}\IVY BackOffice.lnk; Tasks: desktopicon
Name: {userappdata}\Microsoft\Internet Explorer\Quick Launch\IVY BackOffice; Filename: {app}\IVY BackOffice.lnk; Tasks: quicklaunchicon

[Run]
; NOTE: The following entry contains an English phrase ("Launch"). You are free to translate it into another language if required.
Filename: {app}\ivy.mdb; Description: Launch IVY BackOffice; Flags: shellexec postinstall skipifsilent

[Code]
function ScriptDlgPages(CurPage: Integer; BackClicked: Boolean): Boolean;
var
CurSubPage: Integer;
Next: Boolean;
CheckListBox: TNewCheckListBox;
DirectoryListBox: TNewDirectoryListBox;
DriveComboBox: TNewDriveComboBox;
begin
if (not BackClicked and (CurPage = wpWelcome)) or (BackClicked and (CurPage = wpReady)) then begin
if not BackClicked then
CurSubPage := 0
else
CurSubPage := 4;
ScriptDlgPageOpen();
ScriptDlgPageSetCaption('Select Install Type');
ScriptDlgPageSetSubCaption2('');
while (CurSubPage >= 0) and (CurSubPage <= 4) and not Terminated do begin
case CurSubPage of
0:
begin
ScriptDlgPageClearCustom();
ScriptDlgPageSetCaption('Select Install Type');
ScriptDlgPageSetSubCaption1('Server or Workstation Installation');

CheckListBox := TNewCheckListBox.Create(WizardForm.ScriptDlgPanel);
CheckListBox.BorderStyle := bsNone;
CheckListBox.Color := WizardForm.Color;
CheckListBox.MinItemHeight := WizardForm.TasksList.MinItemHeight;
CheckListBox.ShowLines := False;
CheckListBox.WantTabs := True;
CheckListBox.Flat := True;
CheckListBox.Width := WizardForm.ScriptDlgPanel.Width;
CheckListBox.Parent := WizardForm.ScriptDlgPanel;
CheckListBox.AddGroup('Are you installing this copy of IVY BackOffice on your company server?', '', 0, nil);
CheckListBox.AddRadioButton('Yes', '', 0, 0, True, True, nil);
CheckListBox.AddRadioButton('No', '', 0, 0, False, True, nil);
Next := ScriptDlgPageProcessCustom();
end;
1:
begin
if not CheckListBox.Checked[1] then
begin
ScriptDlgPageSetCaption('Client Installation');
ScriptDlgPageSetSubCaption1('Please locate the installation of IVY BackOffice on your server.');
ScriptDlgPageClearCustom();

DriveComboBox := TNewDriveComboBox.Create(WizardForm.ScriptDlgPanel);
DriveComboBox.Width := WizardForm.ScriptDlgPanel.Width;
DriveComboBox.Parent := WizardForm.ScriptDlgPanel;

DirectoryListBox := TNewDirectoryListBox.Create(WizardForm.ScriptDlgPanel);
DirectoryListBox.Top := DriveComboBox.Top + DriveComboBox.Height + 8;
DirectoryListBox.Width := WizardForm.ScriptDlgPanel.Width;
DirectoryListBox.Height := WizardForm.ScriptDlgPanel.Height - DirectoryListBox.Top;
DirectoryListBox.Parent := WizardForm.ScriptDlgPanel;
DirectoryListBox.Directory := ExpandConstant('{src}');

DriveComboBox.DirList := DirectoryListBox;

Next := ScriptDlgPageProcessCustom();
MsgBox('You selected: ''' + DirectoryListBox.Directory + '''.', mbInformation, MB_OK);
end;
end;
end;
if Next then
CurSubPage := CurSubPage + 1
else
CurSubPage := CurSubPage - 1;
end;
if not BackClicked then
Result := Next
else
Result := not Next;
ScriptDlgPageClose(not Result);
end else
Result := True;
end;

function NextButtonClick(CurPage: Integer): Boolean;
begin
Result := ScriptDlgPages(CurPage, False);
end;

function BackButtonClick(CurPage: Integer): Boolean;
begin
Result := ScriptDlgPages(CurPage, True);
end;

Do register to be able to answer

EContact
browser fav
page generated in 102.710010 milliseconds

Why Google AdSense ads ?

compteur
 Ranking-Hits PageRank for this page