FeatureFileEnum Example
InstallShield 2022 ยป InstallScript Language Reference
/*--------------------------------------------------------------*\
*
* InstallShield Example Script
*
* Demonstrates the FeatureFileEnum function.
*
* Notes: To run this example script, create a project with the
* following features (f), subfeatures (sf), and
* components (c):
*
* (f) Program_Files
* (c) Program_DLLS
* (c) Program_EXEs
* (f) Example_Files
* (sf) Graphics
* (c) Graphic_Examples
*
* Be sure to assign files to the components so there
* is something to enumerate.
*
\*--------------------------------------------------------------*/
#define FEAT1 "Program Files"
#define FEAT2 "Example Files"
#define SUBFEAT1 "Graphics"
#define EXECCOMP "Program Executable Files"
#define GRAPHCOMP "Graphic Examples"
#define SDSHOWTITLE "FeatureFileEnum Results"
#define SDSHOWMSG1 FEAT1 + " enumerated files:"
#define SDSHOWMSG2 FEAT2 + " enumerated files:"
prototype HandleFeatureError (NUMBER);
NUMBER nResult;
LIST listList1, listList2;
program
// Create two lists to store file names.
listList1 = ListCreate (STRINGLIST);
listList2 = ListCreate (STRINGLIST);
// Build a list of the program files.
nResult = FeatureFileEnum (MEDIA, FEAT1, EXECCOMP + "\\*.*",
listList1, INCLUDE_SUBDIR);
HandleFeatureError (nResult);
// Build a list of the graphic files.
nResult = FeatureFileEnum (MEDIA, FEAT2 + "\\" + SUBFEAT1,
GRAPHCOMP+"\\*.*", listList2, INCLUDE_SUBDIR);
HandleFeatureError (nResult);
// Display the program files.
SdShowInfoList (SDSHOWTITLE, SDSHOWMSG1, listList1);
// Display the graphic files.
SdShowInfoList (SDSHOWTITLE, SDSHOWMSG2, listList2);
// Release the lists from memory.
ListDestroy (listList1);
ListDestroy (listList2);
endprogram
/*--------------------------------------------------------------------------*\
*
* Function: HandleFeatureError
*
* Purpose: This function evaluates the value returned by a feature
* function and if the value is less than zero, displays the error
* number and aborts the setup.
*
\*--------------------------------------------------------------------------*/
function HandleFeatureError( nResult )
NUMBER nvError;
STRING svFeatureSource, svFeature, svComponent, svFile;
begin
if (nResult < 0) then
FeatureError (svFeatureSource, svFeature, svComponent, svFile, nvError);
SprintfBox (INFORMATION, "Data Transfer Error Information",
"FeatureError returned the following data transfer error.\n" +
"Setup will now abort.\n\n" +
"Media Name: %s\nFeature: %s\nComponent: %s\n" +
"File: %s\nError Number: %ld",
svFeatureSource, svFeature, svComponent, svFile, nvError);
abort;
endif;
end;