Language InstallScript
Date: | 04/20/05 |
Author: | Andrew Rich |
URL: | n/a |
Comments: | 2 |
Info: | n/a |
Score: | (2.84 in 19 votes) |
/************************************************************ 99 Bottles of Beer in InstallScript (c) 2003 Andrew Rich / Project Insomnia Released under GPL for http://99-bottles-of-beer.ls-la.net/ Requires: InstallShield Professional 5 or greater *************************************************************/ #include "ifx.h" NUMBER nBottles; STRING szTitle, szStatus, szTitleS, szStatusS; program Disable ( BACKGROUND ); Enable ( STATUSDLG ); for nBottles = 99 downto 0 switch ( nBottles ) case 1: szTitleS = ""; szStatusS = "s"; default: szTitleS = "s"; switch ( nBottles ) case 2: szStatusS = ""; default: szStatusS = "s"; endswitch; endswitch; Sprintf ( szTitle, "%d bottle%s of beer on the wall, %d bottle%s of beer", nBottles, szTitleS, nBottles, szTitleS ); if ( nBottles ) then Sprintf ( szStatus, "Take one down, pass it around, %d bottle%s of beer on the wall.", nBottles - 1, szStatusS ); else szStatus = ""; endif; SetDialogTitle ( DLG_STATUS, szTitle ); SetStatusWindow ( nBottles, szStatus ); Delay ( 1 ); endfor; Disable ( STATUSDLG ); endprogram
Download Source | Write Comment
Download Source | Write Comment
Add Comment
Please provide a value for the fields Name,
Comment and Security Code.
This is a gravatar-friendly website.
E-mail addresses will never be shown.
Enter your e-mail address to use your gravatar.
Please don't post large portions of code here! Use the form to submit new examples or updates instead!
Comments
Andrew Rich said on 05/26/06 06:36:16
Looking at this several years later (by the way, I submitted it to the original archive in '99, so I don't know how the copyright got to be 2003 and submission date to 2005) I would write the switch block like this:
switch ( nBottles )
case 1:
szTitleS = "";
szStatusS = "s";
case 2:
szTitleS = "s";
szStatusS = "";
default:
szTitleS = "s";
szStatusS = "s";
endswitch;
Aside from that it holds up well and still works in InstallShield 11.5.
Tim Owers said on 10/23/06 16:00:47
Slightly modified code that runs in a Basic MSI project with InstallScript.
for nBottles = 10 downto 1
switch ( nBottles )
case 1:
sMsg = "1 bottle of beer on the wall, take it down pass it around, no bottles of beer on the wall.";
case 2:
sMsg = "2 bottles of beer on the wall, take it down pass it around, 1 bottle of beer on the wall.";
default:
NumToStr (sBottles , nBottles);
sMsg = sBottles + " bottles of beer on the wall, ";
NumToStr (sBottles , nBottles -1);
sMsg = sMsg + "take it down, pass it around, " + sBottles + " bottles of beer on the wall.";
endswitch;
MessageBox (sMsg, INFORMATION);
endfor;
Tested in InstallShield 12 Proffessional.