choir
Pilgrim

help with script

Hi, I cannot figure out why this script is not working. It is a very basic file creation based upon a value the user enters. Can someone please see if I am doing something wrong, or if maybe it's a problem with Installshield? The user prompt gets asked, but the newfile.mss does not get created. I am also using Installshield 2009 on windows 7. I have created many similar scripts but this is the first script I've created in IS2009 on windows 7. Many thanks in advance.

NUMBER nvSrYes;
NUMBER nvSrNo;
STRING szSrYes;
STRING szSrNo;
NUMBER nFileHandle;
NUMBER nvFileHandle;
STRING szFileName;
STRING szPath;
STRING szLine;
STRING szLine2;

export prototype SupervisorRelay();

Dlg_SdAskSupvRelay:
ConfSupvRelay:
SetDialogTitle(DLG_ASK_OPTIONS, "ARD supervisor or relay position?");
szMsg = "Is this a relay or supervisor position?";
szSrYes = "Yes";
szSrNo = "No";
nvSrYes = FALSE;
nvSrNo = TRUE;
nValue = EXCLUSIVE;

nResult = AskOptions (nValue, szMsg,
szSrYes, nvSrYes,
szSrNo, nvSrNo);


function SupervisorRelay()
string szFileName[255];
string szPath[255];
string szLine[255];
number nFileHandle;
number nvFileHandle;
begin
OpenFileMode(FILE_MODE_APPEND);

szFileName = "newfile.mss";
szPath = INSTALLDIR;

if ( nvSrYes = TRUE )then
szLine = "REM ARD Relay Supervisor Interface flag: Y = ARD N = Relay/Supv";
szLine2 = "assign $80 'N'";
WriteLine(nFileHandle, szLine);
WriteLine(nFileHandle, szLine2);
endif;

if ( nvSrNo = TRUE )then
szLine = "REM ARD Relay Supervisor Interface flag: Y = ARD N = Relay/Supv";
szLine2 = "assign $80 'Y'";
WriteLine(nFileHandle, szLine);
WriteLine(nFileHandle, szLine2);
endif;

end;
Labels (1)
Tags (1)
0 Kudos
1 Reply
ch_eng
Flexera beginner

Re: help with script

I am unable to get that script to compile as written, but in regards to the SupervisorRelay() function, it looks like you are missing either a CreateFile() or OpenFile() call before your WriteLine()

"The WriteLine function writes a line of text to a text file opened in append mode. You must first set the file mode to append mode with OpenFileMode, and then either create the file with CreateFile, or open the file with OpenFile, before calling WriteLine. This function places the line at the end of the file."

source: http://helpnet.flexerasoftware.com/installshield19helplib/Subsystems/installshield19langref/helplibr...

HTH
0 Kudos