FeatureValidate Example

InstallShield 2020 ยป InstallScript Language Reference

/*--------------------------------------------------------------*\    

*    

* InstallShield Example Script    

*    

* Demonstrates the functions SdSetupTypeEx, SdFeatureDialog,    

* FeatureIsItemSelected, FeatureGetData, and FeatureValidate.  

*    

* 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) Small Documents    

*                      (c) Small Document Examples    

*                 (sf) Books    

*                      (c) Book Examples    

*                 (sf) Graphics    

*                      (c) Graphic Examples    

*             (f) Help Files    

*                 (c) Help Files    

*             (f) Utilities    

*                 (sf) Grammar Checker    

*                      (c) Grammar Checker    

*                 (sf) Art Studio    

*                      (c) Art Studio    

*             (f) Evaluation Copy    

*                 (c) Evaluation Copy    

*                 (c) Help Files    

*    

* Insert "dummy" files into the components.  Make sure you    

* define the correct file name for the main EXE (MAIN_EXE,    

* below) that you insert into the Program EXEs components.    

* Run the setup with and without a password assigned to the    

* Program Files feature (remember to rebuild your media    

* each time).    

*    

* You can also create billboards (name them Bbrd1.bmp,    

* Bbrd2.bmp, and Bbrd3.bmp) and add them to the project in    

* the Support Files/Billboards's Language Independent folder.    

*    

* This example script installs files, adds an icon to the    

* Start Programs menu, and provides uninstallation    

* functionality.    

*    

\*--------------------------------------------------------------*/  

 

// Define strings. In a real installation, you would define these in the String Editor

// view and precede each string identifier in the script with the at symbol (@).

#define FEATURE_SELECT_TITLE               "Select Features"    

#define FEATURE_SELECT_MSG                 "Select features and subfeatures to install."    

#define FEATURE_PROGRAMFILES_DISPLAYNAME   "Program Files"    

#define PASSWORD_PROMPT                 "Please enter the password."    

#define PASSWORD_ERRMSG                 "Password incorrect. Please enter again."    

 

 

// Global variable declarations.    

STRING  svData, svLogFile,  szProgram, szFeature, svResult, svSetupType,

svDir;    

BOOL    bInitStepsDone, bPwdValid;    

NUMBER  nvData, nResult;    

 

#include "ifx.h"    

 

function OnFirstUIBefore()

begin    

    // Disable the Back button in setup dialogs.    

    Disable (BACKBUTTON);    

 

    // Get the setup type.    

    svDir = TARGETDIR;    

    SdSetupTypeEx (SETUPTYPE_TITLE, SETUPTYPE_MSG, "", svSetupType, 0);    

 

    // If user selected Custom setup type, display feature selection dialog.    

    if  (svSetupType = SETUPTYPE_CUSTOM) then    

        SdFeatureDialog (FEATURE_SELECT_TITLE, FEATURE_SELECT_MSG, svDir, "");    

    endif;    

 

    // Enable the Back button in setup dialogs.    

    Enable (BACKBUTTON);    

 

    // If the Program Files feature is selected and there is a password    

    // associated with it, the user must input the password and    

    // it must be validated.    

    nResult = FALSE;    

    nvData = FALSE;    

    nResult = FeatureIsItemSelected (MEDIA, FEATURE_PROGRAMFILES_DISPLAYNAME);    

    FeatureGetData (MEDIA, FEATURE_PROGRAMFILES_DISPLAYNAME,    

        FEATURE_FIELD_PASSWORD, nvData, svData);    

    if (nResult && nvData) then    

        bPwdValid = FALSE;    

        Disable (BACKBUTTON);  // Back button not needed or supported here.    

        while  (!bPwdValid)    

            AskText (PASSWORD_PROMPT, "", svResult);    

            nResult = FeatureValidate (MEDIA, FEATURE_PROGRAMFILES_DISPLAYNAME,    

                svResult);    

            if  (nResult = 0) then    

                bPwdValid = TRUE;    

            else    

                MessageBox (PASSWORD_ERRMSG, SEVERE);    

            endif;    

        endwhile;    

        Enable (BACKBUTTON);   // Restore Back button's default status.    

    endif;    

end;