//
//------------------------------------------------------------------------------------------------------
// Project Definitions
//------------------------------------------------------------------------------------------------------
//

@DefineProject
	@Name="NetQuestion"		// project name, do not change
	@Version="x"			// dummy version, do not change
	@OutDrive=@BootDrive		// default target drive
	@SubDir="\\IMNNQ"		// default target directory
	@Immediate=@True		// select immediate mode, do not change
@EndProject

//
//------------------------------------------------------------------------------------------------------
// Component Versions
//------------------------------------------------------------------------------------------------------
//

// defect 3790 : NetQ Web Server replaces ICS Lite, the variable names below will still use ICSL

@DefineVars
	@QString @NetQComponentAVersion="001.002.0003.0001"		// SBCS runtime
	@QString @NetQComponentBVersion="002.000.0000.0001"		// NetQ Web Server
	@QString @NetQComponentCVersion="001.002.0001.0001"		// DBCS runtime
	@QString @NetQComponentDVersion="@NetQComponentAVersion"	// SBCS build time
	@QString @NetQComponentEVersion="@NetQComponentCVersion"	// DBCS build time
	@QString @NetQComponentFVersion="000.000.0000.0000"		// unused
	@QString @NetQComponentGVersion="000.000.0000.0000"		// unused
	@QString @NetQComponentHVersion="000.000.0000.0000"		// unused
	@QString @NetQComponentIVersion="000.000.0000.0000"		// unused
	@QString @NetQComponentJVersion="000.000.0000.0000"		// unused
	@QString @NetQComponentKVersion="000.000.0000.0000"		// unused
	@QString @NetQComponentLVersion="000.000.0000.0000"		// unused
	@QString @NetQComponentMVersion="000.000.0000.0000"		// unused
	@QString @NetQComponentNVersion="000.000.0000.0000"		// unused
	@QString @NetQComponentOVersion="000.000.0000.0000"		// unused
	@QString @NetQComponentPVersion="000.000.0000.0000"		// unused
	@QString @NetQComponentQVersion="000.000.0000.0000"		// unused
	@QString @NetQComponentRVersion="000.000.0000.0000"		// unused
	@QString @NetQComponentSVersion="000.000.0000.0000"		// unused
	@QString @NetQComponentTVersion="000.000.0000.0000"		// unused
	@QString @NetQComponentUVersion="000.000.0000.0000"		// unused
	@QString @NetQComponentVVersion="000.000.0000.0000"		// unused
	@QString @NetQComponentWVersion="000.000.0000.0000"		// unused
	@QString @NetQComponentXVersion="000.000.0000.0000"		// unused
	@QString @NetQComponentYVersion="000.000.0000.0000"		// unused
	@QString @NetQComponentZVersion="000.000.0000.0000"		// unused
@EndVars

//
//------------------------------------------------------------------------------------------------------
// Function Prototypes
//------------------------------------------------------------------------------------------------------
//

@DefineProto
	@Void @NetQInsufficientSpaceDialog( @In @Drive @dev )
	@Void @NetQInvalidDeviceDialog( @In @Drive @dev )
	@Void @NetQDoneDialog( @Void )
	@Void @EventHandler @NetQCancelInit( @Void )
	@Void @NetQCancelDialog( @Void )
	@Void @NetQCustomHelp( @Void )
	@Void @EventHandler @NetQCustomCB( @In @Integer @id, @In @Integer @iold, @In @Integer @inew )
	@Void @EventHandler @NetQCustomInit( @Void )
	@Integer @NetQCustomMenu( @In @QString @ipath, @In @Integer @build, @In @Integer @installed, @In @Integer @update )
	@Void @EventHandler @NetQDirInit( @Void )
	@Integer @NetQDirMenu( @InOut @QString @ipath )
	@Void @NetQTypeHelp( @In @Integer @item )
	@Void @EventHandler @NetQTypeRB( @In @Integer @iold, @In @Integer @inew, @In @Integer @rstart, @In @Integer @rend )
	@Void @EventHandler @NetQTypeInit( @Void )
	@Integer @NetQTypeMenu( @In @QString @ipath, @In @Integer @build, @In @Integer @installed, @In @Integer @update )
	@Void @EventHandler @NetQWelcomeInit( @Void )
	@Void @NetQWelcomeMenu( @Void )
	@Void @NetQRebootHelp( @In @Integer @item )
	@Void @EventHandler @NetQRebootRB( @In @Integer @iold, @In @Integer @inew, @In @Integer @rstart, @In @Integer @rend )
	@Void @EventHandler @NetQRebootInit( @Void )
	@Integer @NetQRebootMenu( @Void )
	@Integer @NetQMenuProcessor( @InOut @QString @ipath, @In @Integer @mode, @In @Integer @build )
	@Void @NetQWriteErrFile( @In @QString @msg )
	@Void @NetQCallConfigBatch( @In @QString @ipath )
	@Integer @NetQProcessCustomElement( @In @QString @component, @InOut @Integer @bitmap )
	@Integer @NetQParseResponseFile( @In @QString @rspfile, @Out @QString @ipath, @Out @Integer @items, @Out @Integer @restart )
	@Void @NetQParseCmdLine( @Out @Integer @buildmode, @Out @QString @rspfile )
	@Integer @NetQCheckInstallPath( @InOut @QString @ipath, @Out @Drive @drv )
	@Void @NetQUninstall( @In @Integer @mode )
	@Void @NetQDeskTop( @In @Integer @mode, @In @QString @ipath )
	@Void @NetQPrepareServers( @In @QString @ipath, @In @Drive @idrive, @In @QString @idir )
	@Void @NetQPrepareSBCS( @In @QString @ipath, @In @Drive @idrive, @In @QString @idir )
	@Void @NetQPrepareDBCS( @In @QString @ipath )
	@Void @NetQPrepareICSL( @In @QString @ipath )
	@Void @NetQKillServers( @In @QString @ipath )
	@Void @NetQKillSBCS( @In @QString @ipath )
	@Void @NetQKillDBCS( @In @QString @ipath )
	@Void @NetQKillICSL( @In @QString @ipath )
	@Void @NetQSelectComponentForInstall( @In @QString @current, @In @QString @installed, @InOut @Integer @selection, @In @Integer @bitmap, @InOut @Integer @total, @In @Integer @csize )
	@Integer @NetQSelectComponentsForInstall( @In @Integer @selection, @In @Integer @mode )
	@Void @NetQSetInstalledComponent( @In @QString @version, @InOut @Integer @selection, @In @Integer @bitmask )
	@Void @NetQSetInstalledComponents( @InOut @Integer @selection )
	@Void @NetQSetPrereqs( @InOut @Integer @selection )
	@Integer @NetQGetDiskSpace( @In @QString @fpath )
	@Void @NetQReadLIBSize( @In @QString @fname, @Out @Integer @fsize )
	@Void @NetQReadLIBSizes( @Void )
	@Void @NetQSetCompatData( @In @QString @vers, @InOut @QString @line, @In @QString @data )
	@Void @NetQWriteCompatFile( @Void )
	@Void @NetQWriteINIFile( @In @Integer @mode )
	@Void @NetQSetINIFile( @In @QString @fpath )
	@Void @NetQReadINIFileVersion( @In @QString @versionname, @InOut @QString @versionval )
	@Void @NetQReadINIFile( @InOut @QString @fpath )
	@Void @NetQModPath( @In @QString @fname, @InOut @QString @fmode, @In @QString @Element, @In @Integer @mode, @In @QString @ipath )
	@Void @NetQModNLSPath( @In @QString @fname, @InOut @QString @fmode, @In @QString @Element, @In @Integer @mode, @In @QString @ipath )
	@Void @NetQEnv( @In @Integer @mode, @In @QString @ipath )
@EndProto

//
//------------------------------------------------------------------------------------------------------
// Constants
//------------------------------------------------------------------------------------------------------
//

@DefineVars
	@Integer @NetQComponentSBCS       = 0x01		// NetQuestion SBCS component
	@Integer @NetQComponentICSL       = 0x02		// NetQuestion ICSL component
	@Integer @NetQComponentDBCS       = 0x04		// NetQuestion DBCS component
	@Integer @NetQComponentSBCSB      = 0x08		// NetQuestion SBCS build time component
	@Integer @NetQComponentDBCSB      = 0x10		// NetQuestion DBCS build time component
	@Integer @NetQComponentsRunTime   = 0x07		// all runtime components
	@Integer @NetQComponentsBuildTime = 0x1f		// all run and build time components
@EndVars

// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// +                                     Dialogs (New Style)                                           +
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

//
//------------------------------------------------------------------------------------------------------
// menu NetQInsufficientSpaceDialog
//
//
// description: This dialog informs the user that there is insufficient disk space.
//------------------------------------------------------------------------------------------------------
//

@DefineFunc @Void @NetQInsufficientSpaceDialog( @In @Drive @dev )
	@BeginWinDialog( "Dialog1s1p", "Insufficient Disk Space", 10001 )
		@StaticText( 310, "There is not enough space on drive '@dev' to install NetQuestion. Click OK and select another drive for the installation or cancel the installation." )
		@Button( 100, "~@!OK" )
		@ExecuteDialog
	@EndWinDialog
	@Return()
@EndFunc

//
//------------------------------------------------------------------------------------------------------
// menu NetQInvalidDeviceDialog
//
//
// description: This dialog informs the user that the device given is invalid.
//------------------------------------------------------------------------------------------------------
//

@DefineFunc @Void @NetQInvalidDeviceDialog( @In @Drive @dev )
	@BeginWinDialog( "Dialog1s1p", "Invalid Drive", 10001 )
		@StaticText( 310, "Drive '@dev' is not a valid drive. Click OK and enter a valid drive." )
		@Button( 100, "~@!OK" )
		@ExecuteDialog
	@EndWinDialog
	@Return()
@EndFunc

//
//------------------------------------------------------------------------------------------------------
// menu NetQDoneDialog
//
//
// description: This dialog informs the user that NetQuestion is already installed. The
//		script execution is terminated.
//------------------------------------------------------------------------------------------------------
//

@DefineFunc @Void @NetQDoneDialog( @Void )
	@BeginWinDialog( "Dialog1s1p", "NetQuestion Installation Complete", 10001 )
		@StaticText( 310, "NetQuestion is already installed. To uninstall NetQuestion enter 'uninstnq' in an OS/2 command window. Click done to end the installation." )
		@Button( 100, "~@!Done" )
		@ExecuteDialog
	@EndWinDialog
	@Abort		// terminate script execution
	@Return()	// dummy, never reached
@EndFunc

//
//------------------------------------------------------------------------------------------------------
// menu NetQCancelDialog
//
//
// description: This dialog queries the user if the installation should really be aborted. If so
//		script execution is terminated.
//------------------------------------------------------------------------------------------------------
//

@DefineVars
	@Integer @NetQCancelDialogResult		// internal result memory
@EndVars
//
// Menu initialization event handler
//
@DefineFunc @Void @EventHandler @NetQCancelInit( @Void )
	@DlgCtrlShow(  100, 0 )
	@DlgCtrlShow(  110, 1 )
	@DlgCtrlShow(  120, 1 )
	@DlgCtrlShow(  130, 0 )
	@DlgCtrlShow(  140, 0 )
	@DlgCtrlShow(  500, 0 )
	@Return()
@EndFunc
//
// Menu handler
//
@DefineFunc @Void @NetQCancelDialog( @Void )

	// map and enable event handler

	@MapEventToFunc( @DlgInitEvent, @NetQCancelInit )
	@EnableEventMap( @DlgInitEvent )

	// process dialog

	@BeginWinDialog( "Dialog1s2p", "Exit Installation", 8000 )
		@Bitmap( 200, "vaibm10", 211 )
		@StaticText( 310, "The installation is not yet complete. If you quit the installation program now, NetQuestion will not be installed.\r\nYou may run the installation program at a later time to complete the installation.\r\nTo continue installing NetQuestion, click Resume. To quit the installation, click Exit." )
		@Button( 110, "~@!Resume" )
		@Button( 120, "E~@!xit" )
		@ExecuteDialog
		@NetQCancelDialogResult = @Button( 120 )
	@EndWinDialog

	// disable event handler

	@DisableEventMap( @DlgInitEvent )

	// abort installation if selected

	@If( @NetQCancelDialogResult )
		@Abort
	@EndIf

	// done

	@Return()
@EndFunc

// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// +                                      Menus (New Style)                                            +
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

//
//------------------------------------------------------------------------------------------------------
// menu NetQCustomMenu
//
//
// description: This menu selects the components to be installed in detail.
//------------------------------------------------------------------------------------------------------
//

@DefineVars
	@QString @NetQCustomMenuDir		// target directory
	@Integer @NetQCustomMenuSpace		// free space on device
	@Integer @NetQCustomMenuSize		// total component size
	@Integer @NetQCustomMenuMode		// build mode and button selection
	@Integer @NetQCustomMenuSBCS=1		// SBCS runtime selection flag
	@Integer @NetQCustomMenuDBCS=1		// DBCS runtime selection flag
	@Integer @NetQCustomMenuICSL=1		// ICS Lite selection flag
	@Integer @NetQCustomMenuSBCSB=1		// SBCS build time selection flag
	@Integer @NetQCustomMenuDBCSB=1		// DBCS build time selection flag
	@Integer @NetQCustomMenuInstalled	// components already installed
	@Integer @NetQCustomMenuUpdate		// components to be updated
	@Integer @NetQCustomMenuSelection	// components selected for install/update
@EndVars
//
// Menu help text output
//
@DefineFunc @Void @NetQCustomHelp( @Void )
	@NetQCustomMenuSize = 0
	@If( @NetQCustomMenuSBCS )
		@NetQCustomMenuSize = @Eval( @NetQCustomMenuSize + @NetQLIBFileASize )
		@NetQCustomMenuSize = @Eval( @NetQCustomMenuSize + @NetQLIBUFileSize )
	@EndIf
	@If( @NetQCustomMenuICSL )
		@NetQCustomMenuSize = @Eval( @NetQCustomMenuSize + @NetQLIBFileBSize )
	@EndIf
	@If( @NetQCustomMenuDBCS )
		@NetQCustomMenuSize = @Eval( @NetQCustomMenuSize + @NetQLIBFileCSize )
	@EndIf
	@If( @NetQCustomMenuSBCSB )
		@NetQCustomMenuSize = @Eval( @NetQCustomMenuSize + @NetQLIBFileDSize )
	@EndIf
	@If( @NetQCustomMenuDBCSB )
		@NetQCustomMenuSize = @Eval( @NetQCustomMenuSize + @NetQLIBFileESize )
	@EndIf
	@NetQCustomMenuSize = @Eval( ( @NetQCustomMenuSize + 1023 ) / 1024 )
	@StaticText( 510, "Destination Directory: @NetQCustomMenuDir\nSpace Required: @NetQCustomMenuSize K\nSpace Available: @NetQCustomMenuSpace K" )
	@Return()
@EndFunc
//
// Menu checkbox event handler
//
@DefineFunc @Void @EventHandler @NetQCustomCB( @In @Integer @id, @In @Integer @iold, @In @Integer @inew )
	@If( @id == 1000 )
		@NetQCustomMenuSBCS = @inew
	@ElseIf( @id == 1001 )
		@NetQCustomMenuICSL = @inew
	@ElseIf( @id == 1002 )
		@NetQCustomMenuDBCS = @inew
	@ElseIf( @id == 1008 )
		@NetQCustomMenuSBCSB = @inew
	@ElseIf( @id == 1009 )
		@NetQCustomMenuDBCSB = @inew
	@EndIf
	@NetQCustomHelp()
	@Return()
@EndFunc
//
// Menu initialization event handler
//
@DefineFunc @Void @EventHandler @NetQCustomInit( @Void )
	@DlgCtrlShow(  100, 1 )
	@DlgCtrlShow(  110, 1 )
	@DlgCtrlShow(  120, 1 )
	@DlgCtrlShow(  130, 0 )
	@DlgCtrlShow(  140, 0 )
	@DlgCtrlShow( 1003, 0 )
	@DlgCtrlShow( 1004, 0 )
	@DlgCtrlShow( 1005, 0 )
	@DlgCtrlShow( 1006, 0 )
	@DlgCtrlShow( 1007, 0 )
	@DlgCtrlShow( 1008, @NetQCustomMenuMode )
	@DlgCtrlShow( 1009, @NetQCustomMenuMode )
	@DlgCtrlShow( 1010, 0 )
	@DlgCtrlShow( 1011, 0 )
	@DlgCtrlShow( 1012, 0 )
	@DlgCtrlShow( 1013, 0 )
	@DlgCtrlShow( 1014, 0 )
	@DlgCtrlShow( 1015, 0 )
	@If( @NetQCustomMenuInstalled & @NetQComponentSBCS )
		@DlgCtrlEnable( 1000, 0 )
	@EndIf
	@If( @NetQCustomMenuInstalled & @NetQComponentICSL )
		@DlgCtrlEnable( 1001, 0 )
	@EndIf
	@If( @NetQCustomMenuInstalled & @NetQComponentDBCS )
		@DlgCtrlEnable( 1002, 0 )
	@EndIf
	@If( @NetQCustomMenuInstalled & @NetQComponentSBCSB )
		@DlgCtrlEnable( 1008, 0 )
	@EndIf
	@If( @NetQCustomMenuInstalled & @NetQComponentDBCSB )
		@DlgCtrlEnable( 1009, 0 )
	@EndIf
	@Return()
@EndFunc
//
// Menu handler
//
@DefineFunc @Integer @NetQCustomMenu( @In @QString @ipath, @In @Integer @build, @In @Integer @installed, @In @Integer @update )

	// make components already installed and components to be updated available to init handler

	@NetQCustomMenuInstalled = @installed
	@NetQCustomMenuUpdate    = @update

	// set initial selection values for components already installed

	@If( @NetQCustomMenuInstalled & @NetQComponentSBCS )
		@If( @NetQCustomMenuUpdate & @NetQComponentSBCS )
			@NetQCustomMenuSBCS = 1
		@Else
			@NetQCustomMenuSBCS = 0
		@EndIf
	@EndIf

	@If( @NetQCustomMenuInstalled & @NetQComponentICSL )
		@If( @NetQCustomMenuUpdate & @NetQComponentICSL )
			@NetQCustomMenuICSL = 1
		@Else
			@NetQCustomMenuICSL = 0
		@EndIf
	@EndIf

	@If( @NetQCustomMenuInstalled & @NetQComponentDBCS )
		@If( @NetQCustomMenuUpdate & @NetQComponentDBCS )
			@NetQCustomMenuDBCS = 1
		@Else
			@NetQCustomMenuDBCS = 0
		@EndIf
	@EndIf

	@If( @NetQCustomMenuInstalled & @NetQComponentSBCSB )
		@If( @NetQCustomMenuUpdate & @NetQComponentSBCSB )
			@NetQCustomMenuSBCSB = 1
		@Else
			@NetQCustomMenuSBCSB = 0
		@EndIf
	@EndIf

	@If( @NetQCustomMenuInstalled & @NetQComponentDBCSB )
		@If( @NetQCustomMenuUpdate & @NetQComponentDBCSB )
			@NetQCustomMenuDBCSB = 1
		@Else
			@NetQCustomMenuDBCSB = 0
		@EndIf
	@EndIf

	// make target directory available to help handler

	@NetQCustomMenuDir = @ipath

	// make free disk space available to help handler

	@NetQCustomMenuSpace = @NetQGetDiskSpace( @ipath )
	@NetQCustomMenuSpace = @Eval( ( @NetQCustomMenuSpace + 1023 ) / 1024 )

	// assert that build time components are only selected in build time mode

	@NetQCustomMenuSBCSB = @Eval( @NetQCustomMenuSBCSB * @build )
	@NetQCustomMenuDBCSB = @Eval( @NetQCustomMenuDBCSB * @build )

	// make build mode available to init handler

NetQCustomMenuLoop:

	@NetQCustomMenuMode = @build

	// map and enable event handlers

	@MapEventToFunc( @DlgCBEvent, @NetQCustomCB )
	@EnableEventMap( @DlgCBEvent )
	@MapEventToFunc( @DlgInitEvent, @NetQCustomInit )
	@EnableEventMap( @DlgInitEvent )

	// process menu

	@BeginWinDialog( "DialogCheck", "Select NetQuestion Components", 8200 )
		@StaticText( 310, "Select the desired NetQuestion components, then click Next." )
		@CB( 1000, "Basic Search Service", @NetQCustomMenuSBCS )
		@CB( 1001, "NetQ Web Server", @NetQCustomMenuICSL )
		@CB( 1002, "DBCS Search Service", @NetQCustomMenuDBCS )
		@CB( 1008, "SBCS Build Time", @NetQCustomMenuSBCSB )
		@CB( 1009, "DBCS Build Time", @NetQCustomMenuDBCSB )
		@Button( 100, "<< ~@!Back" )
		@Button( 110, "~@!Next >>" )
		@Button( 120, "~@!Cancel" )
		@Bitmap( 200, "vaibm10", 211 )
		@NetQCustomHelp()
		@ExecuteDialog
		@NetQCustomMenuSBCS = @CB( 1000 )
		@NetQCustomMenuICSL = @CB( 1001 )
		@NetQCustomMenuDBCS = @CB( 1002 )
		@NetQCustomMenuSBCSB = @CB( 1008 )
		@NetQCustomMenuDBCSB = @CB( 1009 )
		@If( @Button( 100 ) )
			@NetQCustomMenuMode = 0
		@ElseIf( @Button( 120 ) )
			@NetQCustomMenuMode = -1
		@Else
			@NetQCustomMenuMode = 1
		@Endif
	@EndWinDialog

	// disable event handlers

	@DisableEventMap( @DlgInitEvent )
	@DisableEventMap( @DlgCBEvent )

	// process cancel request

	@If( @NetQCustomMenuMode < 0 )
		@NetQCancelDialog()
		@Goto NetQCustomMenuLoop
	@EndIf

	// process back button

	@If( ! @NetQCustomMenuMode )
		@Return( -1 )
	@EndIf

	// space check

	@If( @NetQCustomMenuSpace < @NetQCustomMenuSize + 32 )
		@NetQInsufficientSpaceDialog( @StrIndex( @ipath, 0 ) )
		@Goto NetQCustomMenuLoop
	@EndIf

	// set selection

	@NetQCustomMenuSelection = 0
	@If( @NetQCustomMenuSBCS )
		@NetQCustomMenuSelection = @Eval( @NetQCustomMenuSelection | @NetQComponentSBCS )
	@EndIf
	@If( @NetQCustomMenuICSL )
		@NetQCustomMenuSelection = @Eval( @NetQCustomMenuSelection | @NetQComponentICSL )
	@EndIf
	@If( @NetQCustomMenuDBCS )
		@NetQCustomMenuSelection = @Eval( @NetQCustomMenuSelection | @NetQComponentDBCS )
	@EndIf
	@If( @NetQCustomMenuSBCSB )
		@NetQCustomMenuSelection = @Eval( @NetQCustomMenuSelection | @NetQComponentSBCSB )
	@EndIf
	@If( @NetQCustomMenuDBCSB )
		@NetQCustomMenuSelection = @Eval( @NetQCustomMenuSelection | @NetQComponentDBCSB )
	@EndIf

	// return selection to caller

	@Return( @NetQCustomMenuSelection )
@EndFunc

//
//------------------------------------------------------------------------------------------------------
// menu NetQDirMenu
//
//
// description: This menu selects the installation directory.
//------------------------------------------------------------------------------------------------------
//

@DefineVars
	@Integer @NetQDirMenuMode		// button selection
	@Drive   @NetQDirMenuDev		// target drive for error message
@EndVars
//
// Menu initialization event handler
//
@DefineFunc @Void @EventHandler @NetQDirInit( @Void )
	@DlgCtrlShow(  100, 1 )
	@DlgCtrlShow(  110, 1 )
	@DlgCtrlShow(  120, 1 )
	@DlgCtrlShow(  130, 0 )
	@DlgCtrlShow(  140, 0 )
	@Return()
@EndFunc
//
// Menu handler
//
@DefineFunc @Integer @NetQDirMenu( @InOut @QString @ipath )

	// map and enable event handlers

NetQDirMenuLoop:

	@MapEventToFunc( @DlgInitEvent, @NetQDirInit )
	@EnableEventMap( @DlgInitEvent )

	// process menu

	@BeginWinDialog( "DialogDir", "Choose NetQuestion Destination Location", 8700 )
		@Button( 100, "<< ~@!Back" )
		@Button( 110, "~@!Next >>" )
		@Button( 120, "~@!Cancel" )
		@StaticText( 310, "NetQuestion will be installed in the following directory.\r\n To install to this directory, click Next." )
		@EditBox( 1410, @ipath )
		@Bitmap( 200, "vaibm10", 211 )
		@ExecuteDialog
		@ipath = "@EditBox( 1410 )"
		@If( @Button( 100 ) )
			@NetQDirMenuMode = 0
		@ElseIf( @Button( 120 ) )
			@NetQDirMenuMode = -1
		@Else
			@NetQDirMenuMode = 1
		@Endif
	@EndWinDialog

	// disable event handlers

	@DisableEventMap( @DlgInitEvent )

	// process cancel request

	@If( @NetQDirMenuMode < 0 )
		@NetQCancelDialog()
		@Goto NetQDirMenuLoop
	@EndIf

	// process back button

	@If( ! @NetQDirMenuMode )
		@Return( -1 )
	@EndIf

	// assert that the given drive exists

	@If( ! @NetQCheckInstallPath( @ipath, @NetQDirMenuDev ) )
		@NetQInvalidDeviceDialog( @NetQDirMenuDev )
		@Goto NetQDirMenuLoop
	@EndIf

	// return result to caller

	@Return( 1 )
@EndFunc

//
//------------------------------------------------------------------------------------------------------
// menu NetQTypeMenu
//
//
// description: This menu selects the basic installation type (typical, compact or custom).
//------------------------------------------------------------------------------------------------------
//

@DefineVars
	@Integer @NetQTypeMenuResult=1		// menu result memory
	@Integer @NetQTypeMenuMode		// menu button pressed
	@QString @NetQTypeMenuDir		// target directory
	@Integer @NetQTypeMenuSizeA		// size of typical option
	@Integer @NetQTypeMenuSizeB		// size of compact option
	@Integer @NetQTypeMenuSpace		// free disk space
@EndVars
//
// Menu help text output
//
@DefineFunc @Void @NetQTypeHelp( @In @Integer @item )
	@If( @item == 1410 )
		@StaticText( 510, "Destination Directory: @NetQTypeMenuDir\nSpace Required: @NetQTypeMenuSizeA K\nSpace Available: @NetQTypeMenuSpace K\r\nNetQuestion will be installed with the most common options. Recommended for most users." )
	@ElseIf( @item == 1420 )
		@StaticText( 510, "Destination Directory: @NetQTypeMenuDir\nSpace Required: @NetQTypeMenuSizeB K\nSpace Available: @NetQTypeMenuSpace K\r\nNetQuestion will be installed with the minimum required options." )
	@Else
		@StaticText( 510, "Destination Directory: @NetQTypeMenuDir\r\nYou may choose the options you want to install. Recommended for advanced users." )
	@Endif
	@Return()
@EndFunc
//
// Menu radiobutton event handler
//
@DefineFunc @Void @EventHandler @NetQTypeRB(@In @Integer @iold, @In @Integer @inew, @In @Integer @rstart, @In @Integer @rend )
	@NetQTypeHelp( @inew )
	@Return()
@EndFunc
//
// Menu initialization event handler
//
@DefineFunc @Void @EventHandler @NetQTypeInit( @Void )
	@DlgCtrlShow(  100, 1 )
	@DlgCtrlShow(  110, 1 )
	@DlgCtrlShow(  120, 1 )
	@DlgCtrlShow(  130, 0 )
	@DlgCtrlShow(  140, 0 )
	@DlgCtrlShow( 1410, 1 )
	@DlgCtrlShow( 1420, 1 )
	@DlgCtrlShow( 1430, 1 )
	@DlgCtrlShow( 1440, 0 )
	@DlgCtrlShow( 1450, 0 )
	@DlgCtrlShow( 1460, 0 )
	@If( @NetQTypeMenuSizeB == 0 )
		@DlgCtrlEnable( 1420, 0 )
	@EndIf
	@Return()
@EndFunc
//
// Menu handler
//
@DefineFunc @Integer @NetQTypeMenu( @In @QString @ipath, @In @Integer @build, @In @Integer @installed, @In @Integer @update )

	// make target directory available to help handler

	@NetQTypeMenuDir = @ipath

	// calculate required disk space for typical and compact options

	@NetQTypeMenuSizeB = @Eval( @NetQLIBFileASize + @NETQLIBUFileSize )
	@If( @installed & @NetQComponentSBCS )
		@If( !( @update & @NetQComponentSBCS ) )
			@NetQTypeMenuSizeB = 0
		@EndIf
	@EndIf

	@If( @build )
		@NetQTypeMenuSizeB = @Eval( @NetQTypeMenuSizeB + @NETQLIBFileDSize )
		@If( @installed & @NetQComponentSBCSB )
			@If( !( @update & @NetQComponentSBCSB ) )
				@NetQTypeMenuSizeB = 0
			@EndIf
		@EndIf
	@EndIf

	@NetQTypeMenuSizeA = @Eval( @NetQTypeMenuSizeB + @NetQLIBFileBSize )
	@If( @installed & @NetQComponentICSL )
		@If( !( @update & @NetQComponentICSL ) )
			@NetQTypeMenuSizeA = @NetQTypeMenuSizeB
		@EndIf
	@EndIf

	@NetQTypeMenuSizeA = @Eval( ( @NetQTypeMenuSizeA + 1023 ) / 1024 )
	@NetQTypeMenuSizeB = @Eval( ( @NetQTypeMenuSizeB + 1023 ) / 1024 )

	// make free disk space available to help handler

	@NetQTypeMenuSpace = @NetQGetDiskSpace( @ipath )
	@NetQTypeMenuSpace = @Eval( ( @NetQTypeMenuSpace + 1023 ) / 1024 )

	// map and enable event handlers

NetQTypeMenuLoop:

	@MapEventToFunc( @DlgRBEvent, @NetQTypeRB )
	@EnableEventMap( @DlgRBEvent )
	@MapEventToFunc( @DlgInitEvent, @NetQTypeInit )
	@EnableEventMap( @DlgInitEvent )

	// process menu

	@BeginWinDialog( "DialogRadio", "NetQuestion Installation Type", 8100 )
		@StaticText( 310, "Select the installation type and click Next." )
		@RBRange( 1410, 1460 )
		@RB( 1410, "~@!Typical", @Eval( @NetQTypeMenuResult == 1 ) )
		@RB( 1420, "C~@!ompact", @Eval( @NetQTypeMenuResult == 2 ) )
		@RB( 1430, "C~@!ustom", @Eval( @NetQTypeMenuResult == 3 ) )
		@Button( 100, "<< ~@!Back" )
		@Button( 110, "~@!Next >>" )
		@Button( 120, "~@!Cancel" )
		@Bitmap( 200, "vaibm10", 211 )
		@NetQTypeHelp( @Eval( ( @NetQTypeMenuResult * 10 ) + 1400 ) )
		@ExecuteDialog
		@NetQTypeMenuResult = @Eval( ( @RBRange( 1410 ) - 1400 ) / 10 )
		@If( @Button( 100 ) )
			@NetQTypeMenuMode = 0
		@ElseIf( @Button( 120 ) )
			@NetQTypeMenuMode = -1
		@Else
			@NetQTypeMenuMode = 1
		@Endif
	@EndWinDialog

	// disable event handlers

	@DisableEventMap( @DlgInitEvent )
	@DisableEventMap( @DlgRBEvent )

	// process cancel request

	@If( @NetQTypeMenuMode < 0 )
		@NetQCancelDialog()
		@Goto NetQTypeMenuLoop
	@EndIf

	// process back button

	@If( ! @NetQTypeMenuMode )
		@Return( -1 )
	@EndIf

	// return value for custom

	@If( @NetQTypeMenuResult == 3 )
		@Return( 0 );
	@EndIf

	// return value for compact including space check

	@If( @NetQTypeMenuResult == 2 )
		@If( @NetQTypeMenuSpace < @NetQTypeMenuSizeB + 32 )
			@NetQInsufficientSpaceDialog( @StrIndex( @ipath, 0 ) )
			@Goto NetQTypeMenuLoop
		@EndIf
		@If( @build )
			@Return( @Eval( @NetQComponentSBCS | @NetQComponentSBCSB ) )
		@EndIf
		@Return( @NetQComponentSBCS )
	@Endif

	// space check for typical option

	@If( @NetQTypeMenuSpace < @NetQTypeMenuSizeA + 32 )
		@NetQInsufficientSpaceDialog( @StrIndex( @ipath, 0 ) )
		@Goto NetQTypeMenuLoop
	@EndIf

	// return value for typical

	@If( @build )
		@Return( @Eval( @NetQComponentSBCS | @NetQComponentSBCSB | @NetQComponentICSL ) )
	@EndIf
	@Return( @Eval( @NetQComponentSBCS | @NetQComponentICSL ) )
@EndFunc

//
//------------------------------------------------------------------------------------------------------
// menu NetQWelcomeMenu
//
//
// description: This is the first menu displayed.
//------------------------------------------------------------------------------------------------------
//

@DefineVars
	@Integer @NetQWelcomeMenuResult		// internal result memory
@EndVars
//
// Menu initialization event handler
//
@DefineFunc @Void @EventHandler @NetQWelcomeInit( @Void )
	@DlgCtrlShow(  100, 0 )
	@DlgCtrlShow(  110, 1 )
	@DlgCtrlShow(  120, 1 )
	@DlgCtrlShow(  130, 0 )
	@DlgCtrlShow(  140, 0 )
	@Return()
@EndFunc
//
// Menu handler
//
@DefineFunc @Void @NetQWelcomeMenu( @Void )

	// map and enable event handler

NetQWelcomeMenuLoop:

	@MapEventToFunc( @DlgInitEvent, @NetQWelcomeInit )
	@EnableEventMap( @DlgInitEvent )

	// process menu

	@BeginWinDialog( "DialogText", "Welcome to NetQuestion for OS/2 Installation", 8000 )
		@Bitmap( 200, "vaibm10", 211 )
		@StaticText( 310, "Welcome to the NetQuestion for OS/2 installation program. This program will install NetQuestion on your computer.\r\nIt is strongly recommended that you exit all other programs before running this installation program.\r\nClick Cancel to quit the installation and then close any programs you have running. Click Next to continue with the installation of NetQuestion." )
		@StaticText( 510, "WARNING: This program is protected by copyright law and international treaties.\r\nUnauthorized reproduction or distribution of this program, or any portion of it, may result in severe civil and criminal penalties, and violators will be prosecuted to the maximum extend possible under law." )
		@Button( 110, "~@!Next >>" )
		@Button( 120, "~@!Cancel" )
		@ExecuteDialog
		@NetQWelcomeMenuResult = @Button( 120 )
	@EndWinDialog

	// disable event handler

	@DisableEventMap( @DlgInitEvent )

	// abort installation if selected

	@If( @NetQWelcomeMenuResult )
		@NetQCancelDialog()
		@Goto NetQWelcomeMenuLoop
	@EndIf

	// done

	@Return()
@EndFunc

//
//------------------------------------------------------------------------------------------------------
// menu NetQRebootMenu
//
//
// description: This menu selects if the system should be rebooted. In this case it returns 1, else 0.
//------------------------------------------------------------------------------------------------------
//

@DefineVars
	@Integer @NetQRebootMenuResult		// menu result memory
@EndVars
//
// Menu help text output
//
@DefineFunc @Void @NetQRebootHelp( @In @Integer @item )
	@If( @item == 1410 )
		@StaticText( 510, "Your system will be rebooted for you when install is finished.\r\nClick Finish to complete the installation." )
	@Else
		@StaticText( 510, "You must manually reboot your system.\r\nClick Finish to complete the installation." )
	@Endif
	@Return()

@EndFunc
//
// Menu radiobutton event handler
//
@DefineFunc @Void @EventHandler @NetQRebootRB(@In @Integer @iold, @In @Integer @inew, @In @Integer @rstart, @In @Integer @rend )
	@NetQRebootHelp( @inew )
	@Return()
@EndFunc
//
// Menu initialization event handler
//
@DefineFunc @Void @EventHandler @NetQRebootInit( @Void )
	@DlgCtrlShow(  100, 0 )
	@DlgCtrlShow(  110, 1 )
	@DlgCtrlShow(  120, 0 )
	@DlgCtrlShow(  130, 0 )
	@DlgCtrlShow(  140, 0 )
	@DlgCtrlShow( 1410, 1 )
	@DlgCtrlShow( 1420, 1 )
	@DlgCtrlShow( 1430, 0 )
	@DlgCtrlShow( 1440, 0 )
	@DlgCtrlShow( 1450, 0 )
	@DlgCtrlShow( 1460, 0 )
	@Return()
@EndFunc
//
// Menu handler
//
@DefineFunc @Integer @NetQRebootMenu( @Void )

	// map and enable event handlers

	@MapEventToFunc( @DlgRBEvent, @NetQRebootRB )
	@EnableEventMap( @DlgRBEvent )
	@MapEventToFunc( @DlgInitEvent, @NetQRebootInit )
	@EnableEventMap( @DlgInitEvent )

	// process menu

	@BeginWinDialog( "DialogRadio", "NetQuestion Setup Complete", 8100 )
		@StaticText( 310, "Installation is complete. In order to start NetQuestion it is required to restart the system." )
		@RBRange( 1410, 1460 )
		@RB( 1410, "~@!Yes, I want to restart my computer now.", @True )
		@RB( 1420, "~@!No, I want to restart my computer later.", @False )
		@Button( 110, "~@!Finish" )
		@Bitmap( 200, "vaibm10", 211 )
		@NetQRebootHelp( 1410 )
		@ExecuteDialog
		@NetQRebootMenuResult = @Eval( @RBRange( 1410 ) == 1410 )
	@EndWinDialog

	// disable event handlers

	@DisableEventMap( @DlgInitEvent )
	@DisableEventMap( @DlgRBEvent )

	// if reboot was selected

	@If( @NetQRebootMenuResult )

		// signal reboot selected to caller

		@Return( 1 )
	@EndIf

	// return 0 to caller, if reboot is not selected

	@Return( 0 )
@EndFunc

// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// +                                     Functional Part                                               +
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

//
//------------------------------------------------------------------------------------------------------
// procedure NetQMenuProcessor
//
// input:  mode  - 1=enable/0=disable installation directory selection
//	   build - 1=enable/0=disable build time components selection
//
// inout:  ipath - the NetQuestion installation path
//
// description: This procedure handles all interactive selection menus (new version).
//------------------------------------------------------------------------------------------------------
//

@DefineVars
	@Integer @NetQMenuProcessorResult		// subroutine call result
	@Integer @NetQMenuProcessorInstalled	// components already installed
	@Integer @NetQMenuProcessorUpdate		// installed components to be updated
	@Integer @NetQMenuProcessorTypical		// typical components bitmap
	@Integer @NetQMenuProcessorCompact		// compact components bitmap
	@Integer @NetQMenuProcessorTypeMode		// type menu enable/disable flag
@EndVars

@DefineFunc @Integer @NetQMenuProcessor( @InOut @QString @ipath, @In @Integer @mode, @In @Integer @build )

	// get components already installed and components to be updated

	@NetQMenuProcessorInstalled = 0
	@NetQSetInstalledComponents( @NetQMenuProcessorInstalled )
	@NetQMenuProcessorUpdate = @NetQSelectComponentsForInstall( @NetQMenuProcessorInstalled, 0 )

	// create bitmap of typical and compact items

	@If( @build )
		@NetQMenuProcessorCompact = @Eval( @NetQComponentSBCS | @NetQComponentSBCSB )
	@Else
		@NetQMenuProcessorCompact = @NetQComponentSBCS
	@EndIf
	@NetQMenuProcessorTypical = @Eval( @NetQMenuProcessorCompact | @NetQComponentICSL )

	// enable or disable the type menu according to the typical components state

	@NetQMenuProcessorTypeMode = 1
	@NetQMenuProcessorResult = @Eval( @NetQMenuProcessorInstalled & @NetQMenuProcessorTypical )
	@If( @NetQMenuProcessorResult == @NetQMenuProcessorTypical )
		@NetQMenuProcessorResult = @Eval( @NetQMenuProcessorUpdate & @NetQMenuProcessorTypical )
		@If( @NetQMenuProcessorResult == 0 )
			@NetQMenuProcessorTypeMode = 0
		@EndIf
	@EndIf

	// done, if all components are already installed and up to date

	@If( @build )
		@If( @NetQMenuProcessorInstalled == @NetQComponentsBuildTime )
			@If( @NetQMenuProcessorUpdate == 0 )
				@NetQDoneDialog()
			@EndIf
		@EndIf
	@Else
		@If( @Eval( @NetQMenuProcessorInstalled & @NetQComponentsRunTime ) == @NetQComponentsRunTime )
			@If( @Eval( @NetQMenuProcessorUpdate & @NetQComponentsRunTime ) == 0 )
				@NetQDoneDialog()
			@EndIf
		@EndIf
	@EndIf

	// show welcome menu

NetQMenuProcessorWelcome:

	@NetQWelcomeMenu()
	@NetQMenuProcessorResult = 0

NetQMenuProcessorDir:

	// if directory selection is enabled show directory menu

	@If( @mode )
		@NetQMenuProcessorResult = @NetQDirMenu( @ipath )
	@EndIf

	// if the back button was pressed switch to the welcome menu

	@If( @NetQMenuProcessorResult == -1 )
		@Goto NetQMenuProcessorWelcome
	@EndIf

NetQMenuProcessorType:

	// if install type selection is enabled

	@If( @NetQMenuProcessorTypeMode )

		// show type menu

		@NetQMenuProcessorResult = @NetQTypeMenu( @ipath, @build, @NetQMenuProcessorInstalled, @NetQMenuProcessorUpdate )

		// react to back button

		@If( @NetQMenuProcessorResult == -1 )
			@Goto NetQMenuProcessorDir
		@EndIf

		// in case of custom menu selection

		@If( @NetQMenuProcessorResult == 0 )

			// show custom installation menu

			@NetQMenuProcessorResult = @NetQCustomMenu( @ipath, @build, @NetQMenuProcessorInstalled, @NetQMenuProcessorUpdate )

			// react to back button

			@If( @NetQMenuProcessorResult == -1 )
				@Goto NetQMenuProcessorType
			@EndIf
		@EndIf

	// if install type selection is disabled

	@Else
		// show custom installation menu

		@NetQMenuProcessorResult = @NetQCustomMenu( @ipath, @build, @NetQMenuProcessorInstalled, @NetQMenuProcessorUpdate )

		// react to back button

		@If( @NetQMenuProcessorResult == -1 )
			@Goto NetQMenuProcessorDir
		@EndIf
	@EndIf

	// done, if no components are selected for installation

	@If( @NetQMenuProcessorResult == 0 )
		@NetQDoneDialog()
	@EndIf

	// return selected components

	@Return( @NetQMenuProcessorResult )
@EndFunc

//
//------------------------------------------------------------------------------------------------------
// procedure NetQCallConfigBatch
//
// input:  ipath - the NetQuestion installation path
//
// description: This procedure calls a user supplied configuration file if it exists.
//------------------------------------------------------------------------------------------------------
//

@DefineVars
	@QString @NetQWriteErrFileTmp			// path of temporary directory
	@QString @NetQWriteErrFileDir="IMNNQ"		// NetQuestion directory within temporary one
	@QString @NetQWriteErrFileFile="IMNNQ.ERR"	// error file
@EndVars

@DefineFunc @Void @NetQWriteErrFile( @In @QString @msg )

	// get path to temporary directory

	@NetQWriteErrFileTmp = @Getenv( "TEMP" )
	@If( "@NetQWriteErrFileTmp" == "" )
		@NetQWriteErrFileTmp = @Getenv( "TMP" )
		@If( "@NetQWriteErrFileTmp" == "" )
			@NetQWriteErrFileTmp = "@BootDrive:\\OS2"
		@EndIf
	@EndIf

	// append NetQuestion directory

	@NetQWriteErrFileTmp = "@NetQWriteErrFileTmp\\@NetQWriteErrFileDir"

	// if the directory exists

	@If( @DirExists( @NetQWriteErrFileTmp ) )

		// write string to error file

		@Write( "@NetQWriteErrFileTmp\\@NetQWriteErrFileFile", "wt", "@msg\n" )
	@EndIf

	// done

	@Return()
@EndFunc

//
//------------------------------------------------------------------------------------------------------
// procedure NetQCallConfigBatch
//
// input:  ipath - the NetQuestion installation path
//
// description: This procedure calls a user supplied configuration file if it exists.
//------------------------------------------------------------------------------------------------------
//

@DefineVars
	@QString @NetQCallConfigBatchTmp		// path of temporary directory
	@QString @NetQCallConfigBatchDir="IMNNQ"	// NetQuestion directory within temporary one
	@QString @NetQCallConfigBatchFile="INITIMN.CMD"	// configuration command file
@EndVars

@DefineFunc @Void @NetQCallConfigBatch( @In @QString @ipath )

	// get path to temporary directory

	@NetQCallConfigBatchTmp = @Getenv( "TEMP" )
	@If( "@NetQCallConfigBatchTmp" == "" )
		@NetQCallConfigBatchTmp = @Getenv( "TMP" )
		@If( "@NetQCallConfigBatchTmp" == "" )
			@NetQCallConfigBatchTmp = "@BootDrive:\\OS2"
		@EndIf
	@EndIf

	// append NetQuestion directory and configuration command file name

	@NetQCallConfigBatchTmp = "@NetQCallConfigBatchTmp\\@NetQCallConfigBatchDir\\@NetQCallConfigBatchFile"

	// if the configuration file exists

	@If( @Exists( @NetQCallConfigBatchTmp ) )

		// execute configuration file with proper environment settings

		@OS2Exec( "@ipath\\install\\nqhide.exe", "cmd.exe /C \"@ipath\\setenv2.cmd @ipath @NetQCallConfigBatchTmp @ipath\"", "", 0, 0, "", "", 0, 0, 0, 0, -1, 0 )
	@EndIf

	// done

	@Return()
@EndFunc
//
//------------------------------------------------------------------------------------------------------
// procedure NetQProcessCustomElement
//
// input:  component - the component number as a string
//
// inout:  bitmap - the component bitmap
//
// description: This procedure translates and add the given component string to the component bitmap.
//		It returns 1 in case of success, else 0.
//------------------------------------------------------------------------------------------------------
//

@DefineVars
	@Integer @NetQProcessCustomElementId		// component numeric value
@EndVars

@DefineFunc @Integer @NetQProcessCustomElement( @In @QString @component, @InOut @Integer @bitmap )

	// convert component sting to number

	@NetQProcessCustomElementId = @StrToInt( @component )

	// signal error, if the component number is out of range

	@If( @NetQProcessCustomElementId < 1 || @NetQProcessCustomElementId > 26 )
		@Return( 0 )
	@EndIf

	// convert number to binary representation

	@If( @NetQProcessCustomElementId == 1 )
		@bitmap = @Eval( @bitmap | 0x00000001 )
	@ElseIf( @NetQProcessCustomElementId == 2 )
		@bitmap = @Eval( @bitmap | 0x00000002 )
	@ElseIf( @NetQProcessCustomElementId == 3 )
		@bitmap = @Eval( @bitmap | 0x00000004 )
	@ElseIf( @NetQProcessCustomElementId == 4 )
		@bitmap = @Eval( @bitmap | 0x00000008 )
	@ElseIf( @NetQProcessCustomElementId == 5 )
		@bitmap = @Eval( @bitmap | 0x00000010 )
	@ElseIf( @NetQProcessCustomElementId == 6 )
		@bitmap = @Eval( @bitmap | 0x00000020 )
	@ElseIf( @NetQProcessCustomElementId == 7 )
		@bitmap = @Eval( @bitmap | 0x00000040 )
	@ElseIf( @NetQProcessCustomElementId == 8 )
		@bitmap = @Eval( @bitmap | 0x00000080 )
	@ElseIf( @NetQProcessCustomElementId == 9 )
		@bitmap = @Eval( @bitmap | 0x00000100 )
	@ElseIf( @NetQProcessCustomElementId == 10 )
		@bitmap = @Eval( @bitmap | 0x00000200 )
	@ElseIf( @NetQProcessCustomElementId == 11 )
		@bitmap = @Eval( @bitmap | 0x00000400 )
	@ElseIf( @NetQProcessCustomElementId == 12 )
		@bitmap = @Eval( @bitmap | 0x00000800 )
	@ElseIf( @NetQProcessCustomElementId == 13 )
		@bitmap = @Eval( @bitmap | 0x00001000 )
	@ElseIf( @NetQProcessCustomElementId == 14 )
		@bitmap = @Eval( @bitmap | 0x00002000 )
	@ElseIf( @NetQProcessCustomElementId == 15 )
		@bitmap = @Eval( @bitmap | 0x00004000 )
	@ElseIf( @NetQProcessCustomElementId == 16 )
		@bitmap = @Eval( @bitmap | 0x00008000 )
	@ElseIf( @NetQProcessCustomElementId == 17 )
		@bitmap = @Eval( @bitmap | 0x00010000 )
	@ElseIf( @NetQProcessCustomElementId == 18 )
		@bitmap = @Eval( @bitmap | 0x00020000 )
	@ElseIf( @NetQProcessCustomElementId == 19 )
		@bitmap = @Eval( @bitmap | 0x00040000 )
	@ElseIf( @NetQProcessCustomElementId == 20 )
		@bitmap = @Eval( @bitmap | 0x00080000 )
	@ElseIf( @NetQProcessCustomElementId == 21 )
		@bitmap = @Eval( @bitmap | 0x00100000 )
	@ElseIf( @NetQProcessCustomElementId == 22 )
		@bitmap = @Eval( @bitmap | 0x00200000 )
	@ElseIf( @NetQProcessCustomElementId == 23 )
		@bitmap = @Eval( @bitmap | 0x00400000 )
	@ElseIf( @NetQProcessCustomElementId == 24 )
		@bitmap = @Eval( @bitmap | 0x00800000 )
	@ElseIf( @NetQProcessCustomElementId == 25 )
		@bitmap = @Eval( @bitmap | 0x01000000 )
	@ElseIf( @NetQProcessCustomElementId == 26 )
		@bitmap = @Eval( @bitmap | 0x02000000 )
	@EndIf

	// done, signal success

	@Return( 1 )
@EndFunc

//
//------------------------------------------------------------------------------------------------------
// procedure NetQParseResponseFile
//
// input:  rspfile - the response file pathname
//
// output: ipath   - the installation path
//	   items   - the components to be installed
//	   restart - reboot after installation flag
//
// return: 1 in case of success, 0 if an error occurred
//
// description: This procedure parses the response file.
//------------------------------------------------------------------------------------------------------
//

@DefineVars
	@Integer @NetQParseResponseFileSection			// flag for [ResponseFile] section
	@Integer @NetQParseResponseFilePathFound		// flag for Path1=... found
	@Integer @NetQParseResponseFileCustomFound		// flag for Custom=... found
	@Integer @NetQParseResponseFileResult			// function call result
	@QString @NetQParseResponseFileLine			// response file line
	@QString @NetQParseResponseFileItem			// response file item
	@QString @NetQParseResponseFilePathValue		// installation path
	@Integer @NetQParseResponseFileItemsValue		// components selected
	@Drive   @NetQParseResponseFileDriveDummy		// dummy value, unused
	@Integer @NetQParseResponseFileCounter			// counter value
	@QString @NetQParseResponseFileComponent		// current component
@EndVars

@DefineFunc @Integer @NetQParseResponseFile( @In @QString @rspfile, @Out @QString @ipath, @Out @Integer @items, @Out @Integer @restart )

	// reset flags

	@NetQParseResponseFileSection     = 0
	@NetQParseResponseFilePathFound   = 0
	@NetQParseResponseFileCustomFound = 0

	// reset return values

	@NetQParseResponseFilePathValue  = ""
	@NetQParseResponseFileItemsValue = 0
	@restart                         = 0

	// signal error, if the response file doesn't exist

	@If( ! @Exists( @rspfile ) )
		@Return( 0 )
	@EndIf

	// read first line of response file

	@NetQParseResponseFileResult = @ReadLine( @rspfile, @NetQParseResponseFileLine, 2048, 0 )

NetQParseResponseFileLineLoop:

	// if not End Of File

	@If( @NetQParseResponseFileResult != -1 )

		// get first token of current line and convert it to uppercase

		@NetQParseResponseFileItem = @StrToken( @NetQParseResponseFileLine, 0, "\t " )
		@NetQParseResponseFileItem = @StrUpr( @NetQParseResponseFileItem )

		// in case of a section command

		@If( @StrIndex( @NetQParseResponseFileItem, 0 ) == @StrIndex( "[", 0 ) )

			// set the flag if it is the response file section, else reset it

			@If( "@NetQParseResponseFileItem" == "[RESPONSEFILE]" )
				@NetQParseResponseFileSection = 1
			@Else
				@NetQParseResponsefileSection = 0
			@EndIf

		// if we are in the right section

		@ElseIf( @NetQParseResponseFileSection )

			// figure out if the line is a var=data line

			@NetQParseResponseFileResult = @StrFind( @NetQParseResponseFileLine, "=" )

			// if so

			@If( @NetQParseResponseFileResult != -1 )

				// get var part of the var=data line and convert it to uppercase

				@NetQParseResponseFileItem = @StrToken( @NetQParseResponseFileLine, 0, "=\t " )
				@NetQParseResponseFileItem = @StrUpr( @NetQParseResponseFileItem )

				// process PATH1

				@If( "@NetQParseResponseFileItem" == "PATH1" )

					// get path element and strip it of blanks/tabs

					@NetQParseResponseFilePathValue = @StrToken( @NetQParseResponseFileLine, 1, "=" )
					@NetQParseResponseFilePathValue = @StrToken( @NetQParseResponseFilePathValue, 0, "\t " )

					// make the path absolute, signal error, if the drive doesn't exist

					@If( ! @NetQCheckInstallPath( @NetQParseResponseFilePathValue, @NetQParseResponseFileDriveDummy ) )
						@Return( 0 )
					@EndIf

					// set path found flag

					@NetQParseResponseFilePathFound = 1

				// process CUSTOM

				@ElseIf( "@NetQParseResponseFileItem" == "CUSTOM" )

					// get component numbers

					@NetQParseResponseFileItem = @StrToken( @NetQParseResponseFileLine, 1, "=" )

					// reset counter

					@NetQParseResponseFileCounter = 0

					// get current element

NetQParseResponseFileCustomLoop:
					@NetQParseResponseFileComponent = @StrToken( @NetQParseResponseFileItem, @NetQParseResponseFileCounter, "\t " )

					// if the element exists

					@If( "@NetQParseResponseFileComponent" != "" )

						// process element, react to errors

						@If( ! @NetQProcessCustomElement( @NetQParseResponseFileComponent, @NetQParseResponseFileItemsValue ) )
							@Return( 0 )
						@EndIf

						// next element

						@NetQParseResponseFileCounter = @Eval( @NetQParseResponseFileCounter + 1 )
						@Goto NetQParseResponseFileCustomLoop
					@EndIf

					// set custom found flag

					@NetQParseResponseFileCustomFound = 1

				// process REBOOT

				@ElseIf( "@NetQParseResponseFileItem" == "REBOOT" )

					// get component value

					@NetQParseResponseFileItem = @StrToken( @NetQParseResponseFileLine, 1, "=" )
					@NetQParseResponseFileItem = @StrToken( @NetQParseResponseFileItem, 1, "\t " )

					// set reboot flag if requested by user

					@If( ! @StrCmpNos( @NetQParseResponseFileItem, "Y" ) )
						@restart = 1
					@EndIf
				@EndIf
			@Endif
		@EndIf

		// read next line of response file

		@NetQParseResponseFileResult = @ReadLine( , @NetQParseResponseFileLine, 2048, )

		// process line

		@Goto NetQParseResponseFileLineLoop
	@EndIf

	// signal error, if path or custom section not found

	@If( @NetQParseResponseFilePathFound == 0 || @NetQParseResponseFileCustomFound == 0 )
		@Return( 0 )
	@EndIf

	// make return values available to caller

	@ipath = "@NetQParseResponseFilePathValue"
	@items = @NetQParseResponseFileItemsValue

	// signal success

	@Return( 1 )
@EndFunc

//
//------------------------------------------------------------------------------------------------------
// procedure NetQParseCmdLine
//
// output: buildmode - 1=buildtime install enabled, 0=buildtime install disabled
//	   rspfile   = response file name or empty string
//
// description: This procedure parses the command line parameters.
//------------------------------------------------------------------------------------------------------
//

@DefineVars
	@QString @NetQParseCmdLineItem			// current element
	@Integer @NetQParseCmdLineSelection		// element counter
	@Integer @NetQParseCmdLineSilent		// silent mode flag
@EndVars

@DefineFunc @Void @NetQParseCmdLine( @Out @Integer @buildmode, @Out @QString @rspfile )

	// reset build mode and response file

	@buildmode = 0
	@rspfile   = ""

	// reset silent mode flag

	@NetQParseCmdLineSilent = 0

	// start with item one

	@NetQParseCmdLineSelection = 0

	// get item

NetQParseCmdLineLoop:

	@NetQParseCmdLineItem = @StrToken( @CommandLine, @NetQParseCmdLineSelection, "\t " )

	// if there is still an item

	@If( "@NetQParseCmdLineItem" != "" )

		// if uninstall is selected

		@If( ! @StrCmpNos( @NetQParseCmdLineItem, "-uninstall" ) )

			// call uninstall routine (never returns)

			@NetQUninstall( @NetQParseCmdLineSilent )

		// if build mode is selected

		@ElseIf( ! @StrCmpNos( @NetQParseCmdLineItem, "-build" ) )

			// set build mode flag

			@buildmode = 1

		// if a response file is given

		@ElseIf( @StrIndex( @NetQParseCmdLineItem, 0 ) == @StrIndex( "@@", 0 ) )

			// set silent mode

			@NetQParseCmdLineSilent = 1

			// get response file name from item

			@NetQParseCmdLineItem = @StrTail( @NetQParseCmdLineItem, @Eval( @StrLen( @NetQParseCmdLineItem ) - 1 ) )

			// in case of no file name use default

			@If( "@NetQParseCmdLineItem" == "" )
				@NetQParseCmdLineItem="@StartUpDrive:\\@StartupDir\\INSTALL.INI"
			@EndIf

			// make response file name available to caller

			@rspfile = @NetQParseCmdLineItem
		@EndIf

		// next item

		@NetQParseCmdLineSelection = @Eval( @NetQParseCmdLineSelection + 1 )
		@Goto NetQParseCmdLineLoop
	@EndIf

	// done

	@Return()
@EndFunc

//
//------------------------------------------------------------------------------------------------------
// procedure NetQCheckInstallPath
//
// inout:  ipath - the NetQuestion installation path
//
// output: drv - the installation drive
//
// description: This procedure returns 0, if the given device does not exists. If it exists, the 
//		procedure returns 1 and creates an absolute pathname from the pathname given.
//------------------------------------------------------------------------------------------------------
//

@DefineVars
	@Drive   @NetQCheckInstallPathDev		// installation device
	@QString @NetQCheckInstallPathDir		// installation directory
@EndVars

@DefineFunc @Integer @NetQCheckInstallPath( @InOut @QString @ipath, @Out @Drive @drv )

	// split installation path in drive and directory

	@If( @StrLen( @ipath ) > 1 )
		@If( @StrIndex( @ipath, 1 ) == @StrIndex( ":", 0 ) )
			@NetQCheckInstallPathDev = @StrIndex( @StrUpr( @ipath ), 0 )
			@NetQCheckInstallPathDir = @StrTail( @ipath, @Eval( @StrLen( @ipath ) - 2 ) )
		@Else
			@NetQCheckInstallPathDev = @OutDrive
			@NetQCheckInstallPathDir = @ipath
		@EndIf
	@Else
		@NetQCheckInstallPathDev = @OutDrive
		@NetQCheckInstallPathDir = @ipath
	@EndIf

	// make installation drive available to caller

	@drv = @NetQCheckInstallPathDev

	// assert that the given drive exists, signal error otherwise

	@If( ! @DriveExists( @NetQCheckInstallPathDev ) )
		@Return( 0 )
	@EndIf

	// assert that the given directory is absolute, else make it absolute

	@If( @StrLen( @NetQCheckInstallPathDir ) > 0 )
		@If( @StrIndex( @NetQCheckInstallPathDir, 0 ) != @StrIndex( "\\", 0 ) )
			@If( "@NetCheckInstallPathQDir" == "" )
				@NetQCheckInstallPathDir = "@GetCwd( @NetQCheckInstallPathDev )"
			@Else
				@If( "@StrTail( @GetCwd( @NetQCheckInstallPathDev ), 1 )" == "\\" )
					@NetQCheckInstallPathDir = "@GetCwd( @NetQCheckInstallPathDev )@NetQCheckInstallPathDir"
				@Else
					@NetQCheckInstallPathDir = "@GetCwd( @NetQCheckInstallPathDev )\\@NetQCheckInstallPathDir"
				@EndIf
			@EndIf
			@NetQCheckInstallPathDir = @StrTail( @NetQCheckInstallPathDir, @Eval( @StrLen( @NetQCheckInstallPathDir ) - 2 ) )
		@Endif
	@Else
		@If( "@NetQCheckInstallPathDir" == "" )
			@NetQCheckInstallPathDir = "@GetCwd( @NetQCheckInstallPathDev )"
		@Else
			@If( "@StrTail( @GetCwd( @NetQCheckInstallPathDev ), 1 )" == "\\" )
				@NetQCheckInstallPathDir = "@GetCwd( @NetQCheckInstallPathDev )@NetQCheckInstallPathDir"
			@Else
				@NetQCheckInstallPathDir = "@GetCwd( @NetQCheckInstallPathDev )\\@NetQCheckInstallPathDir"
			@EndIf
		@EndIf
		@NetQCheckInstallPathDir = @StrTail( @NetQCheckInstallPathDir, @Eval( @StrLen( @NetQCheckInstallPathDir ) - 2 ) )
	@EndIf

	// now create a complete pathname

	@ipath = "@NetQCheckInstallPathDev:@NetQCheckInstallPathDir"

	// return success to caller

	@Return( 1 )
@EndFunc

//
//------------------------------------------------------------------------------------------------------
// procedure NetQUninstall
//
// input:  mode - 1 if silent uninstall, else 0
//
// description: This procedure removes NetQuestion, if there are no more indexes.
//------------------------------------------------------------------------------------------------------
//

@DefineVars
	@QString @NetQUninstallPath		// NetQuestion installation directory
@EndVars

@DefineFunc @Void @NetQUninstall( @In @Integer @mode )

	// load background bitmap if not in silent mode

	@If( ! @mode )
		@ShowBMP( 0, 0, 0, "@InDrive:VABACK1._B_", 2, @WinScreenCaps( 8 ), @Eval( @WinScreenCaps( 10 ) - 15 ) )
	@EndIf

	// reset uninstall path

	@NetQUninstallPath = ""

	// read INI file data

	@NetQReadINIFile( @NetQUninstallPath )

	// done, if the path is empty, i.e. NetQuestion is not installed

	@If( "@NetQUninstallPath" == "" )
		@Abort
	@EndIf

	// done, if the installation directory doesn't exist

	@If( ! @DirExists( @NetQUninstallPath ) )
		@Abort
	@EndIf

	// if build time components are not installed

	@If( ( "@NetQINIFileVerDVal" == "000.000.0000.0000" ) && ( "@NetQINIFileVerEVal" == "000.000.0000.0000" ) )

		// done, if there are SBCS indexes

		@If( @Spawn( "@NetQUninstallPath\\install\\nqhide.exe @NetQUninstallPath\\nqcounti.exe @NetQUninstallPath") != 0 )
			@Abort
		@EndIf

		// done, if there are DBCS indexes

		@If( "@NetQINIFileVerCVal" != "000.000.0000.0000" )
			@If( @Spawn("@NetQUninstallPath\\install\\nqhide.exe @NetQUninstallPath\\tmcounti.exe -m @NetQUninstallPath\\instance\\dbcshelp") != 0 )
				@Abort
			@EndIf
		@EndIf
	@EndIf

	// show environment removal bitmap if not in silent mode

	@If( ! @mode )
		@ShowBMP( 1, @Eval( @WinScreenCaps( 8 ) / 10 ), @Eval( @WinScreenCaps( 10 ) - ( @WinScreenCaps( 10 ) / 10 ) ) - 156, "@InDrive:VABYEENV._B_", 2 )
	@EndIf

	// kill all processes

	@NetQKillICSL( @NetQUninstallPath )
	@NetQKillSBCS( @NetQUninstallPath )
	@NetQKillDBCS( @NetQUninstallPath )

	// uninstall from desktop

	@NetQDesktop( 0, @NetQUninstallPath )

	// uninstall from OS2.INI

	@NetQWriteINIFile( 0 )

	// uninstall environment

	@NetQEnv( 0, @NetQUninstallPath )

	// show file removal bitmap if not in silent mode

	@If( ! @mode )
		@EraseBMP( 1 )
		@ShowBMP( 1, @Eval( @WinScreenCaps( 8 ) / 10 ), @Eval( @WinScreenCaps( 10 ) - ( @WinScreenCaps( 10 ) / 10 ) ) - 156, "@InDrive:VABYEFIL._B_", 2 )
	@EndIf

	// uninstall files

	@DeleteTree( @NetQUninstallPath, 99999, "--DANGER--" )
	@RmDir( @NetQUninstallPath )

	// remove file removal bitmap if not in silent mode

	@If( ! @mode )
		@EraseBMP( 1 )
	@EndIf

	// done, exit

	@Abort

	// dummy, never reached
	@Return()
@EndFunc

//
//------------------------------------------------------------------------------------------------------
// procedure NetQDesktop
//
// input:  mode  - 0=delete, 1=create/update
//	   ipath - NetQuestion installation path
//
// description: This procedure creates/deletes the NetQuestion Desktop folder and icons.
//------------------------------------------------------------------------------------------------------
//

@DefineVars
	@QString @NetQDeskTopFile = "IMNNQWPS.CMD"	// command file used for icon creation/deletion
@EndVars

@DefineFunc @Void @NetQDeskTop( @In @Integer @mode, @In @QString @ipath )

	// create command file header

	@Write( "@ipath\\@NetQDesktopFile", "wt", "/* REXX CMD Script */\n\n" )
	@Write( , , "CALL RxFuncAdd 'SysLoadFuncs', 'REXXUtil', 'SysLoadFuncs'\n" )
	@Write( , , "CALL SysLoadFuncs\n\n" )

	// write icon and folder deletion commands

	@Write( , , "name = '<NetQuestion SBCS Start>'\n")
	@Write( , , "return = SysDestroyObject(name)\n\n")
	@Write( , , "name = '<NetQuestion SBCS Stop>'\n")
	@Write( , , "return = SysDestroyObject(name)\n\n")
	@Write( , , "name = '<NetQuestion MWS Start>'\n")
	@Write( , , "return = SysDestroyObject(name)\n\n")
	@Write( , , "name = '<NetQuestion DBCS Start>'\n")
	@Write( , , "return = SysDestroyObject(name)\n\n")
	@Write( , , "name = '<NetQuestion DBCS Stop>'\n")
	@Write( , , "return = SysDestroyObject(name)\n\n")
	@Write( , , "name = '<NetQuestion Uninstall>'\n")
	@Write( , , "return = SysDestroyObject(name)\n\n")
	@Write( , , "name = '<NetQuestion>'\n")
	@Write( , , "return = SysDestroyObject(name)\n\n")

	// in case of installation mode

	@If( @mode )

		// write folder creation command

		@Write( , , "classname = 'WPFolder'\n" )
		@Write( , , "title = 'NetQuestion Help Search Service'\n" )
		@Write( , , "location = '<WP_DESKTOP>'\n" )
		@Write( , , "setup = 'OBJECTID=<NetQuestion>'\n" )
		@Write( , , "return = SysCreateObject(classname, title, location, setup)\n\n" )

		// write uninstall icon creation command

		@Write( , , "classname = 'WPProgram'\n" )
		@Write( , , "title = 'Uninstall NetQuestion'\n" )
		@Write( , , "location = '<NetQuestion>'\n" )
		@Write( , , "setup = 'OBJECTID=<NetQuestion Uninstall>;EXENAME=cmd.exe;STARTUPDIR=@ipath\\..;PARAMETERS=/C \"start /C /MIN @ipath\\uninstnq.cmd\"'\n" )
		@Write( , , "return = SysCreateObject(classname, title, location, setup)\n\n" )

		// write sbcs stop server creation command, if sbcs is installed

		@If( "@NetQINIFileVerAVal" != "000.000.0000.0000" )
			@Write( , , "classname = 'WPProgram'\n" )
			@Write( , , "title = 'Stop SBCS Server'\n" )
			@Write( , , "location = '<NetQuestion>'\n" )
			@Write( , , "setup = 'OBJECTID=<NetQuestion SBCS Stop>;EXENAME=@ipath\\netq.exe;STARTUPDIR=@ipath;PARAMETERS=stop server'\n" )
			@Write( , , "return = SysCreateObject(classname, title, location, setup)\n\n" )
		@EndIf

		// write dbcs stop server creation command, if dbcs is installed

		@If( "@NetQINIFileVerCVal" != "000.000.0000.0000" )
			@Write( , , "classname = 'WPProgram'\n" )
			@Write( , , "title = 'Stop DBCS Server'\n" )
			@Write( , , "location = '<NetQuestion>'\n" )
			@Write( , , "setup = 'OBJECTID=<NetQuestion DBCS Stop>;EXENAME=@ipath\\imqss.exe;STARTUPDIR=@ipath;PARAMETERS=-stop dbcshelp'\n" )
			@Write( , , "return = SysCreateObject(classname, title, location, setup)\n\n" )
		@EndIf

		// write sbcs start server creation command, if sbcs is installed

		@If( "@NetQINIFileVerAVal" != "000.000.0000.0000" )
			@Write( , , "classname = 'WPProgram'\n" )
			@Write( , , "title = 'Start SBCS Server'\n" )
			@Write( , , "location = '<NetQuestion>'\n" )
			@Write( , , "setup = 'OBJECTID=<NetQuestion SBCS Start>;EXENAME=@ipath\\netq.exe;STARTUPDIR=@ipath;PARAMETERS=start server'\n" )
			@Write( , , "return = SysCreateObject(classname, title, location, setup)\n\n" )
		@EndIf

		// write ics lite start server creation command, if ics lite is installed

		@If( "@NetQINIFileVerBVal" != "000.000.0000.0000" )
			@Write( , , "classname = 'WPProgram'\n" )
			@Write( , , "title = 'Start NetQ Web Server'\n" )
			@Write( , , "location = '<NetQuestion>'\n" )
			@Write( , , "setup = 'OBJECTID=<NetQuestion MWS Start>;EXENAME=cmd.exe;STARTUPDIR=@ipath;PARAMETERS=/C \"detach @ipath\\httpdl.exe -r @ipath\\httpd.cnf\"'\n" )
			@Write( , , "return = SysCreateObject(classname, title, location, setup)\n\n" )
		@EndIf

		// write dbcs start server creation command, if dbcs is installed

		@If( "@NetQINIFileVerCVal" != "000.000.0000.0000" )
			@Write( , , "classname = 'WPProgram'\n" )
			@Write( , , "title = 'Start DBCS Server'\n" )
			@Write( , , "location = '<NetQuestion>'\n" )
			@Write( , , "setup = 'OBJECTID=<NetQuestion DBCS Start>;EXENAME=@ipath\\imqss.exe;STARTUPDIR=@ipath;PARAMETERS=-start dbcshelp'\n" )
			@Write( , , "return = SysCreateObject(classname, title, location, setup)\n\n" )
		@EndIf
	@Endif

	// execute commnd file, i.e. delete/create folder and icons

	@OS2Exec( "@ipath\\install\\nqhide.exe", "cmd.exe /C \"@ipath\\@NetQDesktopFile\"", "", 0, 0, "", "", 0, 0, 0, 0, -1, 0 )

	// delete temporary command file

	@Delete( "@ipath\\@NetQDesktopFile" )

	// done

	@Return()
@EndFunc

//
//------------------------------------------------------------------------------------------------------
// procedure NetQPrepareServers
//
// input:  ipath  - the NetQuestion installation path
//	   idrive - the NetQuestion installation drive
//	   idir   - the NetQuestion installation directory
//
// description: This procedure configures the NetQuestion components actually installed.
//------------------------------------------------------------------------------------------------------
//

@DefineFunc @Void @NetQPrepareServers( @In @QString @ipath, @In @Drive @idrive, @In @QString @idir )
	@If( @GroupIsSet( A ) )
		@NetQPrepareSBCS( @ipath, @idrive, @idir )
	@EndIf
	@If( @GroupIsSet( B ) )
		@NetQPrepareICSL( @ipath )
	@EndIf
	@If( @GroupIsSet( C ) )
		@NetQPrepareDBCS( @ipath )
	@EndIf
	@Return()
@EndFunc

//
//------------------------------------------------------------------------------------------------------
// procedure NetQPrepareSBCS
//
// input:  ipath  - the NetQuestion installation path
//	   idrive - the NetQuestion installation drive
//	   idir   - the NetQuestion installation directory
//
// description: This procedure executes the SBCS configuration process and creates the UNINSTNQ.CMD
//		file, furthermore a line is appended for old install compatability.
//------------------------------------------------------------------------------------------------------
//

@DefineFunc @Void @NetQPrepareSBCS( @In @QString @ipath, @In @Drive @idrive, @In @QString @idir )
// ALi: do not configure TCP/IP as default, instead use the shipped netq.cfg
//	@OS2Exec( "@ipath\\install\\nqhide.exe", "@ipath\\netqinit.exe @ipath\\data" "", 0, 0, "", "", 0, 0, 0, 0, -1, 0 )
	@Write( "@ipath\\uninstnq.cmd", "wt", "@@ECHO OFF\n" )
	@Write( , , "SET NETQBASEDIRECTORY=@ipath\n" )
	@Write( , , "@idrive:\n" )
	@Write( , , "CD @idir\\INSTALL\n" )
	@Write( , , "UNINSTAL.CMD ___UNINSTNQ___ %1\n" )
	@Write( , , "EXIT 1\n" )
	@Write( "@ipath\\SETENV.CMD", "at", "SET NETQ11MAIN=@ipath\n" )
	@Return()
@EndFunc

//
//------------------------------------------------------------------------------------------------------
// procedure NetQPrepareDBCS
//
// input:  ipath - the NetQuestion installation path
//
// description: This procedure executes the DBCS configuration processes.
//------------------------------------------------------------------------------------------------------
//

@DefineFunc @Void @NetQPrepareDBCS( @In @QString @ipath )
	@OS2Exec( "@ipath\\install\\nqhide.exe", "cmd.exe /C \"@ipath\\setenv2.cmd @ipath @ipath\\imqcrins -i dbcshelp -r c:\\ -c local\"", "", 0, 0, "", "", 0, 0, 0, 0, -1, 0 )
	@OS2Exec( "@ipath\\install\\nqhide.exe", "cmd.exe /C \"@ipath\\setenv2.cmd @ipath @ipath\\imqcrcl -s SERVER -r c:\\ -c local -i dbcshelp\"", "", 0 , 0, "", "", 0, 0, 0, 0, -1, 0 )
	@Return()
@EndFunc

//
//------------------------------------------------------------------------------------------------------
// procedure NetQPrepareICSL
//
// input:  ipath - the NetQuestion installation path
//
// description: This procedure corrects the ICS Lite configuration file.
//------------------------------------------------------------------------------------------------------
//

@DefineVars
	@QString @NetQPrepareICSLLine		// configuration file line buffer
@EndVars

@DefineFunc @Void @NetQPrepareICSL( @In @QString @ipath )
	@ReadLine( "@ipath\\httpd.cnf", @NetQPrepareICSLLine, 2048, 0 )
	@Write( "@ipath\\httptemp.cnf", "wt", "@NetQPrepareICSLLine\n" )
NetQPrepareICSLLoop:
	@If( @ReadLine( "@ipath\\httpd.cnf", @NetQPrepareICSLLine, 2048 ) != -1 )
		@If( @StrFind( "@NetQPrepareICSLLine", "ServerRoot" ) >= 0 )
			@Write( , , "ServerRoot    @ipath\n" )
		@ElseIf( @StrFind( "@NetQPrepareICSLLine", "/cgi-bin/" ) >= 0 )
			@Write( , , "Exec    /cgi-bin/*  @ipath\\*\n" )
		@ElseIf( @StrFind( "@NetQPrepareICSLLine", "/icons" ) >= 0 )
			@Write( , , "Pass    /icons/*    @ipath\\*\n" )
		@ElseIf( @StrFind( "@NetQPrepareICSLLine" , "Pass" ) >= 0 )
			@Write( , , "Pass    /*          @ipath\\*\n" )
		@Else
			@Write( , , "@NetQPrepareICSLLine\n" )
		@EndIf
		@Goto NetQPrepareICSLLoop
	@EndIf
	@Copy( "@ipath\\httptemp.cnf", "@ipath\\httpd.cnf" )
	@Delete( "@ipath\\httptemp.cnf" )
	@Return()
@EndFunc

//
//------------------------------------------------------------------------------------------------------
// procedure NetQKillServers
//
// input:  ipath - the NetQuestion installation path
//
// description: This procedure kills all servers necessary prior to install/upgrade.
//------------------------------------------------------------------------------------------------------
//

@DefineFunc @Void @NetQKillServers( @In @QString @ipath )

	// ICS Lite must be killed in any case

	@If( @GroupIsSet( A ) || @GroupIsSet( B ) || @GroupIsSet( C ) || @GroupIsSet( D ) || @GroupIsSet( E ) )
		@NetQKillICSL( @ipath )
	@EndIf

	// SBCS must be killed for SBCS runtime and build time install

	@If( @GroupIsSet( A ) || @GroupIsSet( D ) )
		@NetQKillSBCS( @ipath )
	@EndIf

	// DBCS must be killed for DBCS runtime and build time install

	@If( @GroupIsSet( B ) || @GroupIsSet( E ) )
		@NetQKillDBCS( @ipath )
	@EndIf

	// done

	@Return()
@EndFunc

//
//------------------------------------------------------------------------------------------------------
// procedure NetQKillSBCS
//
// input:  ipath - the NetQuestion installation path
//
// description: This procedure kills all SBCS server processes.
//------------------------------------------------------------------------------------------------------
//

@DefineFunc @Void @NetQKillSBCS( @In @QString @ipath )
	@OS2Exec( "@ipath\\install\\killproc.exe", "@ipath\\imncsclt.exe", "", 0, 0, "", "", 0, 0, 0, 0, -1, 0 )
	@OS2Exec( "@ipath\\install\\killproc.exe", "@ipath\\imncssrv.exe", "", 0, 0, "", "", 0, 0, 0, 0, -1, 0 )
	@OS2Exec( "@ipath\\install\\killproc.exe", "@ipath\\imnsvdem.exe", "", 0, 0, "", "", 0, 0, 0, 0, -1, 0 )
	@Return()
@EndFunc

//
//------------------------------------------------------------------------------------------------------
// procedure NetQKillDBCS
//
// input:  ipath - the NetQuestion installation path
//
// description: This procedure kills the DBCS server process.
//------------------------------------------------------------------------------------------------------
//

@DefineFunc @Void @NetQKillDBCS( @In @QString @ipath )
	@OS2Exec( "@ipath\\install\\killproc.exe", "@ipath\\imqsmdem.exe", "", 0, 0, "", "", 0, 0, 0, 0, -1, 0 )
	@Return()
@EndFunc

//
//------------------------------------------------------------------------------------------------------
// procedure NetQKillICSL
//
// input:  ipath - the NetQuestion installation path
//
// description: This procedure kills the ICS Lite server process.
//------------------------------------------------------------------------------------------------------
//

@DefineFunc @Void @NetQKillICSL( @In @QString @ipath )
	@OS2Exec( "@ipath\\install\\killproc.exe", "@ipath\\httpdl.exe", "", 0, 0, "", "", 0, 0, 0, 0, -1, 0 )
	@Return()
@EndFunc


//
//------------------------------------------------------------------------------------------------------
// procedure NetQSelectComponentForInstall
//
// input:  current   - the current component version number
//	   installed - the installed component version number
//	   bitmap    - the bit representing the component
//	   total     - the total size of all components not yet installed
//	   csize     - the size of the current component
//
// inout:  selection - the components selected
//
// description: This procedure selects if the given component must be installed.
//------------------------------------------------------------------------------------------------------
//

@DefineFunc @Void @NetQSelectComponentForInstall( @In @QString @current, @In @QString @installed, @InOut @Integer @selection, @In @Integer @bitmap, @InOut @Integer @total, @In @Integer @csize )

	// if the current component is selected for installation

	@If( @selection & @bitmap )

		// if the same or a higher version is already installed

		@If( @StrCmp( @installed, @current ) >= 0 )

			// deselect the component

			@selection = @Eval( @selection ^ @bitmap )
		@EndIf
	@EndIf

	// if the current component is still selected for installation

	@If( @selection & @bitmap )

		// if  the component is not yet installed

		@If( "@installed" == "000.000.0000.0000" )

			// add the component size to the total size

			@total = @Eval( @total + @csize )

			// if the current component is SBCS runtime

			@If( @bitmap & @NetQComponentSBCS )

				// add the uninstall component size to the total size

				@total = @Eval( @total + @NetQLIBUFileSize )
			@EndIf
		@EndIf
	@EndIf

	// done

	@Return()
@EndFunc

//
//------------------------------------------------------------------------------------------------------
// procedure NetQSelectComponentsForInstall
//
// input:  selection - the components selected
//
// return: the components that must be installed
//
// description: This procedure selects the components that must be installed from the given
//		selection.
//------------------------------------------------------------------------------------------------------
//

@DefineVars
	@Integer @NetQSelectComponentsForInstallOutput	// components that must be installed
	@Integer @NetQSelectComponentsForInstallSize	// total size of components not yet installed
@EndVars

@DefineFunc @Integer @NetQSelectComponentsForInstall( @In @Integer @selection, @In @Integer @mode )

	// preset the components to be installed according to the current selection

	@NetQSelectComponentsForInstallOutput = @selection

	// reset the components not yet installed total size

	@NetQSelectComponentsForInstallSize = 0

	// select the components that must be installed from the current selection

	@NetQSelectComponentForInstall( @NetQComponentAVersion, @NetQINIFileVerAVal, @NetQSelectComponentsForInstallOutput, 0x00000001, @NetQSelectComponentsForInstallSize, @NetQLIBFileASize )
	@NetQSelectComponentForInstall( @NetQComponentBVersion, @NetQINIFileVerBVal, @NetQSelectComponentsForInstallOutput, 0x00000002, @NetQSelectComponentsForInstallSize, @NetQLIBFileBSize )
	@NetQSelectComponentForInstall( @NetQComponentCVersion, @NetQINIFileVerCVal, @NetQSelectComponentsForInstallOutput, 0x00000004, @NetQSelectComponentsForInstallSize, @NetQLIBFileCSize )
	@NetQSelectComponentForInstall( @NetQComponentDVersion, @NetQINIFileVerDVal, @NetQSelectComponentsForInstallOutput, 0x00000008, @NetQSelectComponentsForInstallSize, @NetQLIBFileDSize )
	@NetQSelectComponentForInstall( @NetQComponentEVersion, @NetQINIFileVerEVal, @NetQSelectComponentsForInstallOutput, 0x00000010, @NetQSelectComponentsForInstallSize, @NetQLIBFileESize )
	@NetQSelectComponentForInstall( @NetQComponentFVersion, @NetQINIFileVerFVal, @NetQSelectComponentsForInstallOutput, 0x00000020, @NetQSelectComponentsForInstallSize, @NetQLIBFileFSize )
	@NetQSelectComponentForInstall( @NetQComponentGVersion, @NetQINIFileVerGVal, @NetQSelectComponentsForInstallOutput, 0x00000040, @NetQSelectComponentsForInstallSize, @NetQLIBFileGSize )
	@NetQSelectComponentForInstall( @NetQComponentHVersion, @NetQINIFileVerHVal, @NetQSelectComponentsForInstallOutput, 0x00000080, @NetQSelectComponentsForInstallSize, @NetQLIBFileHSize )
	@NetQSelectComponentForInstall( @NetQComponentIVersion, @NetQINIFileVerIVal, @NetQSelectComponentsForInstallOutput, 0x00000100, @NetQSelectComponentsForInstallSize, @NetQLIBFileISize )
	@NetQSelectComponentForInstall( @NetQComponentJVersion, @NetQINIFileVerJVal, @NetQSelectComponentsForInstallOutput, 0x00000200, @NetQSelectComponentsForInstallSize, @NetQLIBFileJSize )
	@NetQSelectComponentForInstall( @NetQComponentKVersion, @NetQINIFileVerKVal, @NetQSelectComponentsForInstallOutput, 0x00000400, @NetQSelectComponentsForInstallSize, @NetQLIBFileKSize )
	@NetQSelectComponentForInstall( @NetQComponentLVersion, @NetQINIFileVerLVal, @NetQSelectComponentsForInstallOutput, 0x00000800, @NetQSelectComponentsForInstallSize, @NetQLIBFileLSize )
	@NetQSelectComponentForInstall( @NetQComponentMVersion, @NetQINIFileVerMVal, @NetQSelectComponentsForInstallOutput, 0x00001000, @NetQSelectComponentsForInstallSize, @NetQLIBFileMSize )
	@NetQSelectComponentForInstall( @NetQComponentNVersion, @NetQINIFileVerNVal, @NetQSelectComponentsForInstallOutput, 0x00002000, @NetQSelectComponentsForInstallSize, @NetQLIBFileNSize )
	@NetQSelectComponentForInstall( @NetQComponentOVersion, @NetQINIFileVerOVal, @NetQSelectComponentsForInstallOutput, 0x00004000, @NetQSelectComponentsForInstallSize, @NetQLIBFileOSize )
	@NetQSelectComponentForInstall( @NetQComponentPVersion, @NetQINIFileVerPVal, @NetQSelectComponentsForInstallOutput, 0x00008000, @NetQSelectComponentsForInstallSize, @NetQLIBFilePSize )
	@NetQSelectComponentForInstall( @NetQComponentQVersion, @NetQINIFileVerQVal, @NetQSelectComponentsForInstallOutput, 0x00010000, @NetQSelectComponentsForInstallSize, @NetQLIBFileQSize )
	@NetQSelectComponentForInstall( @NetQComponentRVersion, @NetQINIFileVerRVal, @NetQSelectComponentsForInstallOutput, 0x00020000, @NetQSelectComponentsForInstallSize, @NetQLIBFileRSize )
	@NetQSelectComponentForInstall( @NetQComponentSVersion, @NetQINIFileVerSVal, @NetQSelectComponentsForInstallOutput, 0x00040000, @NetQSelectComponentsForInstallSize, @NetQLIBFileSSize )
	@NetQSelectComponentForInstall( @NetQComponentTVersion, @NetQINIFileVerTVal, @NetQSelectComponentsForInstallOutput, 0x00080000, @NetQSelectComponentsForInstallSize, @NetQLIBFileTSize )
	@NetQSelectComponentForInstall( @NetQComponentUVersion, @NetQINIFileVerUVal, @NetQSelectComponentsForInstallOutput, 0x00100000, @NetQSelectComponentsForInstallSize, @NetQLIBFileUSize )
	@NetQSelectComponentForInstall( @NetQComponentVVersion, @NetQINIFileVerVVal, @NetQSelectComponentsForInstallOutput, 0x00200000, @NetQSelectComponentsForInstallSize, @NetQLIBFileVSize )
	@NetQSelectComponentForInstall( @NetQComponentWVersion, @NetQINIFileVerWVal, @NetQSelectComponentsForInstallOutput, 0x00400000, @NetQSelectComponentsForInstallSize, @NetQLIBFileWSize )
	@NetQSelectComponentForInstall( @NetQComponentXVersion, @NetQINIFileVerXVal, @NetQSelectComponentsForInstallOutput, 0x00800000, @NetQSelectComponentsForInstallSize, @NetQLIBFileXSize )
	@NetQSelectComponentForInstall( @NetQComponentYVersion, @NetQINIFileVerYVal, @NetQSelectComponentsForInstallOutput, 0x01000000, @NetQSelectComponentsForInstallSize, @NetQLIBFileYSize )
	@NetQSelectComponentForInstall( @NetQComponentZVersion, @NetQINIFileVerZVal, @NetQSelectComponentsForInstallOutput, 0x02000000, @NetQSelectComponentsForInstallSize, @NetQLIBFileZSize )

	// if in size mode

	@If( @mode )
		// return the total size of the components not yet installed

		@Return( @NetQSelectComponentsForInstallSize )
	@EndIf

	// return the components that must be installed

	@Return( @NetQSelectComponentsForInstallOutput )
@EndFunc

//
//------------------------------------------------------------------------------------------------------
// procedure NetQSetInstalledComponent
//
// input:  version - the component version
//	   bitmap  - the bit representiog the component
//
// inout:  selection - the components selected
//
// description: This procedure selects a component if it is already installed.
//------------------------------------------------------------------------------------------------------
//

@DefineFunc @Void @NetQSetInstalledComponent( @In @QString @version, @InOut @Integer @selection, @In @Integer @bitmask )

	// if  the component is already installed

	@If( "@version" != "000.000.0000.0000" )

		// add it to the selection

		@selection = @Eval( @selection | @bitmask )
	@EndIf

	// done

	@Return()
@EndFunc

//
//------------------------------------------------------------------------------------------------------
// procedure NetQSetInstalledComponents
//
// inout:  selection - the components selected
//
// description: This procedure selects additional components according to the components
//		already installed.
//------------------------------------------------------------------------------------------------------
//

@DefineFunc @Void @NetQSetInstalledComponents( @InOut @Integer @selection )

	// process all possible components

	@NetQSetInstalledComponent( @NetQINIFileVerAVal, @selection, 0x00000001 )
	@NetQSetInstalledComponent( @NetQINIFileVerBVal, @selection, 0x00000002 )
	@NetQSetInstalledComponent( @NetQINIFileVerCVal, @selection, 0x00000004 )
	@NetQSetInstalledComponent( @NetQINIFileVerDVal, @selection, 0x00000008 )
	@NetQSetInstalledComponent( @NetQINIFileVerEVal, @selection, 0x00000010 )
	@NetQSetInstalledComponent( @NetQINIFileVerFVal, @selection, 0x00000020 )
	@NetQSetInstalledComponent( @NetQINIFileVerGVal, @selection, 0x00000040 )
	@NetQSetInstalledComponent( @NetQINIFileVerHVal, @selection, 0x00000080 )
	@NetQSetInstalledComponent( @NetQINIFileVerIVal, @selection, 0x00000100 )
	@NetQSetInstalledComponent( @NetQINIFileVerJVal, @selection, 0x00000200 )
	@NetQSetInstalledComponent( @NetQINIFileVerKVal, @selection, 0x00000400 )
	@NetQSetInstalledComponent( @NetQINIFileVerLVal, @selection, 0x00000800 )
	@NetQSetInstalledComponent( @NetQINIFileVerMVal, @selection, 0x00001000 )
	@NetQSetInstalledComponent( @NetQINIFileVerNVal, @selection, 0x00002000 )
	@NetQSetInstalledComponent( @NetQINIFileVerOVal, @selection, 0x00004000 )
	@NetQSetInstalledComponent( @NetQINIFileVerPVal, @selection, 0x00008000 )
	@NetQSetInstalledComponent( @NetQINIFileVerQVal, @selection, 0x00010000 )
	@NetQSetInstalledComponent( @NetQINIFileVerRVal, @selection, 0x00020000 )
	@NetQSetInstalledComponent( @NetQINIFileVerSVal, @selection, 0x00040000 )
	@NetQSetInstalledComponent( @NetQINIFileVerTVal, @selection, 0x00080000 )
	@NetQSetInstalledComponent( @NetQINIFileVerUVal, @selection, 0x00100000 )
	@NetQSetInstalledComponent( @NetQINIFileVerVVal, @selection, 0x00200000 )
	@NetQSetInstalledComponent( @NetQINIFileVerWVal, @selection, 0x00400000 )
	@NetQSetInstalledComponent( @NetQINIFileVerXVal, @selection, 0x00800000 )
	@NetQSetInstalledComponent( @NetQINIFileVerYVal, @selection, 0x01000000 )
	@NetQSetInstalledComponent( @NetQINIFileVerZVal, @selection, 0x02000000 )

	// done

	@Return()
@EndFunc

//
//------------------------------------------------------------------------------------------------------
// procedure NetQSetPrereqs
//
// inout:  selection - the components selected
//
// description: This procedure selects the prerequisite components according to the selected
//		components.
//------------------------------------------------------------------------------------------------------
//

@DefineFunc @Void @NetQSetPrereqs( @InOut @Integer @selection )

	// DBCS build time prereqs DBCS runtime

	@If( @selection & @NetQComponentDBCSB )
		@selection = @Eval( @selection | @NetQComponentDBCS )
	@EndIf

	// SBCS build time prereqs SBCS runtime

	@If( @selection & @NetQComponentSBCSB )
		@selection = @Eval( @selection | @NetQComponentSBCS )
	@EndIf

	// DBCS runtime prereqs SBCS runtime

	@If( @selection & @NetQComponentDBCS )
		@selection = @Eval( @selection | @NetQComponentSBCS )
	@EndIf

	// ICS Lite prereqs SBCS runtime

	@If( @selection & @NetQComponentICSL )
		@selection = @Eval( @selection | @NetQComponentSBCS )
	@EndIf

	// done

	@Return()
@EndFunc

//
//------------------------------------------------------------------------------------------------------
// procedure NetQGetDiskSpaceDrive
//
// input:  fpath - full installation pathname
//
// description: This procedure retrieves the available free disk space on the target drive.
//------------------------------------------------------------------------------------------------------
//

@DefineVars
	@Drive @NetQGetDiskSpaceDrive		// drive letter of the drive to be processed
@EndVars

@DefineFunc @Integer @NetQGetDiskSpace( @In @QString @fpath )

	// extract the drive letter from the installation directory

	@NetQGetDiskSpaceDrive = @StrIndex( @fpath, 0 )

	// if the drive exists

	@If( @DriveExists( @NetQGetDiskSpaceDrive ) )

		// return no free disk space for CDROMs

		@If( @DriveCDRom( @NetQGetDiskSpaceDrive ) )
			@Return( 0 )
		@EndIf

		// return no free disk space for removable media

		@If( @Removable( @NetQGetDiskSpaceDrive ) )
			@Return( 0 )
		@EndIf

		// return the disk space available on the drive

		@Return( @DiskFree( @NetQGetDiskSpaceDrive ) )
	@EndIf

	// return no free space if the drive doesn't exist

	@Return( 0 )
@EndFunc

//
//------------------------------------------------------------------------------------------------------
// Library file related variables used by NetQReadLLIBSizes()
// *Size variables may be used READ-ONLY after NetQReadLIBSizes() was called
//------------------------------------------------------------------------------------------------------
//

@DefineVars
	@QString @NetQLIBFileAName="AGROUP.OS2"		// component A library file name
	@QString @NetQLIBFileBName="BGROUP.OS2"		// component B library file name
	@QString @NetQLIBFileCName="CGROUP.OS2"		// component C library file name
	@QString @NetQLIBFileDName="DGROUP.OS2"		// component D library file name
	@QString @NetQLIBFileEName="EGROUP.OS2"		// component E library file name
	@QString @NetQLIBFileFName="FGROUP.OS2"		// component F library file name
	@QString @NetQLIBFileGName="GGROUP.OS2"		// component G library file name
	@QString @NetQLIBFileHName="HGROUP.OS2"		// component H library file name
	@QString @NetQLIBFileIName="IGROUP.OS2"		// component I library file name
	@QString @NetQLIBFileJName="JGROUP.OS2"		// component J library file name
	@QString @NetQLIBFileKName="KGROUP.OS2"		// component K library file name
	@QString @NetQLIBFileLName="LGROUP.OS2"		// component L library file name
	@QString @NetQLIBFileMName="MGROUP.OS2"		// component M library file name
	@QString @NetQLIBFileNName="NGROUP.OS2"		// component N library file name
	@QString @NetQLIBFileOName="OGROUP.OS2"		// component O library file name
	@QString @NetQLIBFilePName="PGROUP.OS2"		// component P library file name
	@QString @NetQLIBFileQName="QGROUP.OS2"		// component Q library file name
	@QString @NetQLIBFileRName="RGROUP.OS2"		// component R library file name
	@QString @NetQLIBFileSName="SGROUP.OS2"		// component S library file name
	@QString @NetQLIBFileTName="TGROUP.OS2"		// component T library file name
	@QString @NetQLIBFileUName="UGROUP.OS2"		// component U library file name
	@QString @NetQLIBFileVName="VGROUP.OS2"		// component V library file name
	@QString @NetQLIBFileWName="WGROUP.OS2"		// component W library file name
	@QString @NetQLIBFileXName="XGROUP.OS2"		// component X library file name
	@QString @NetQLIBFileYName="YGROUP.OS2"		// component Y library file name
	@QString @NetQLIBFileZName="ZGROUP.OS2"		// component Z library file name
	@Integer @NetQLIBFileASize			// component A library file contents size
	@Integer @NetQLIBFileBSize			// component A library file contents size
	@Integer @NetQLIBFileCSize			// component A library file contents size
	@Integer @NetQLIBFileDSize			// component A library file contents size
	@Integer @NetQLIBFileESize			// component A library file contents size
	@Integer @NetQLIBFileFSize			// component A library file contents size
	@Integer @NetQLIBFileGSize			// component A library file contents size
	@Integer @NetQLIBFileHSize			// component A library file contents size
	@Integer @NetQLIBFileISize			// component A library file contents size
	@Integer @NetQLIBFileJSize			// component A library file contents size
	@Integer @NetQLIBFileKSize			// component A library file contents size
	@Integer @NetQLIBFileLSize			// component A library file contents size
	@Integer @NetQLIBFileMSize			// component A library file contents size
	@Integer @NetQLIBFileNSize			// component A library file contents size
	@Integer @NetQLIBFileOSize			// component A library file contents size
	@Integer @NetQLIBFilePSize			// component A library file contents size
	@Integer @NetQLIBFileQSize			// component A library file contents size
	@Integer @NetQLIBFileRSize			// component A library file contents size
	@Integer @NetQLIBFileSSize			// component A library file contents size
	@Integer @NetQLIBFileTSize			// component A library file contents size
	@Integer @NetQLIBFileUSize			// component A library file contents size
	@Integer @NetQLIBFileVSize			// component A library file contents size
	@Integer @NetQLIBFileWSize			// component A library file contents size
	@Integer @NetQLIBFileXSize			// component A library file contents size
	@Integer @NetQLIBFileYSize			// component A library file contents size
	@Integer @NetQLIBFileZSize			// component A library file contents size
	@QString @NetQLIBUFileName="UNINSTAL.OS2"	// uninstall library file name
	@Integer @NetQLIBUFileSize			// uninstall library file contents size
@EndVars

//
//------------------------------------------------------------------------------------------------------
// procedure NetQReadLIBSize
//
// input:  fname - library file name
//
// output: fsize - library file contents size in bytes
//
// description: This procedure retrieves the contents size of the specified library file.
//------------------------------------------------------------------------------------------------------
//

@DefineFunc @Void @NetQReadLIBSize( @In @QString @fname, @Out @Integer @fsize )

	// if the given library file exists

	@If( @Exists( @fname ) )

		// retrieve contents size

		@fsize = @LibInfo( @InDrive, @fname )

	// if the given library file does not exist

	@Else

		// set contents size to zero

		@fsize = 0
	@EndIf

	// done

	@Return()
@EndFunc

//
//------------------------------------------------------------------------------------------------------
// procedure NetQReadLIBSizes
//
// description: This procedure retrieves the contents size of all library files.
//------------------------------------------------------------------------------------------------------
//

@DefineFunc @Void @NetQReadLIBSizes( @Void )

	// read library file contents sizes

	@NetQReadLIBSize( @NetQLIBUFileName, @NetQLIBUFileSize )

	@NetQReadLIBSize( @NetQLIBFileAName, @NetQLIBFileASize )
	@NetQReadLIBSize( @NetQLIBFileBName, @NetQLIBFileBSize )
	@NetQReadLIBSize( @NetQLIBFileCName, @NetQLIBFileCSize )
	@NetQReadLIBSize( @NetQLIBFileDName, @NetQLIBFileDSize )
	@NetQReadLIBSize( @NetQLIBFileEName, @NetQLIBFileESize )
	@NetQReadLIBSize( @NetQLIBFileFName, @NetQLIBFileFSize )
	@NetQReadLIBSize( @NetQLIBFileGName, @NetQLIBFileGSize )
	@NetQReadLIBSize( @NetQLIBFileHName, @NetQLIBFileHSize )
	@NetQReadLIBSize( @NetQLIBFileIName, @NetQLIBFileISize )
	@NetQReadLIBSize( @NetQLIBFileJName, @NetQLIBFileJSize )
	@NetQReadLIBSize( @NetQLIBFileKName, @NetQLIBFileKSize )
	@NetQReadLIBSize( @NetQLIBFileLName, @NetQLIBFileLSize )
	@NetQReadLIBSize( @NetQLIBFileMName, @NetQLIBFileMSize )
	@NetQReadLIBSize( @NetQLIBFileNName, @NetQLIBFileNSize )
	@NetQReadLIBSize( @NetQLIBFileOName, @NetQLIBFileOSize )
	@NetQReadLIBSize( @NetQLIBFilePName, @NetQLIBFilePSize )
	@NetQReadLIBSize( @NetQLIBFileQName, @NetQLIBFileQSize )
	@NetQReadLIBSize( @NetQLIBFileRName, @NetQLIBFileRSize )
	@NetQReadLIBSize( @NetQLIBFileSName, @NetQLIBFileSSize )
	@NetQReadLIBSize( @NetQLIBFileTName, @NetQLIBFileTSize )
	@NetQReadLIBSize( @NetQLIBFileUName, @NetQLIBFileUSize )
	@NetQReadLIBSize( @NetQLIBFileVName, @NetQLIBFileVSize )
	@NetQReadLIBSize( @NetQLIBFileWName, @NetQLIBFileWSize )
	@NetQReadLIBSize( @NetQLIBFileXName, @NetQLIBFileXSize )
	@NetQReadLIBSize( @NetQLIBFileYName, @NetQLIBFileYSize )
	@NetQReadLIBSize( @NetQLIBFileZName, @NetQLIBFileZSize )

	// done

	@Return()
@EndFunc

//
//------------------------------------------------------------------------------------------------------
// INI file related variables used by NetQReadINIFile() and NetQWriteINIFile()
// *Val variables may be used READ-ONLY after NetQReadINIFile() was called
//------------------------------------------------------------------------------------------------------
//

@DefineVars
	@QString @NetQINIFileName			// full pathname of NETQ11.INI
	@QString @NetQINIFileApp="NETQ"			// application in OS2.INI
	@QString @NetQINIFileKey1="NETQ11"		// key in OS2.INI
	@QString @NetQINIFileKey2="Install"		// key in NETQ11.INI
	@QString @NetQINIFileDirName="Directory"	// NetQuestion installation directory key
	@QString @NetQINIFileFolderName="Folder"	// obsolete, for old version compatability only
	@QString @NetQINIFileLangName="Language"	// obsolete, for old version compatability only
	@QString @NetQINIFileFixPackName="FixPak"	// obsolete, for old version compatability only
	@QString @NetQINIFileDirVal			// NetQuestion installation directory
	@QString @NetQINIFileFolderVal			// obsolete, for old version compatability only
	@QString @NetQINIFileLangVal			// obsolete, for old version compatability only
	@QString @NetQINIFileFixPackVal			// obsolete, for old version compatability only
	@QString @NetQINIFileVerAName="GroupAVersion"	// component A version key
	@QString @NetQINIFileVerBName="GroupBVersion"	// component B version key
	@QString @NetQINIFileVerCName="GroupCVersion"	// component C version key
	@QString @NetQINIFileVerDName="GroupDVersion"	// component D version key
	@QString @NetQINIFileVerEName="GroupEVersion"	// component E version key
	@QString @NetQINIFileVerFName="GroupFVersion"	// component F version key
	@QString @NetQINIFileVerGName="GroupGVersion"	// component G version key
	@QString @NetQINIFileVerHName="GroupHVersion"	// component H version key
	@QString @NetQINIFileVerIName="GroupIVersion"	// component I version key
	@QString @NetQINIFileVerJName="GroupJVersion"	// component J version key
	@QString @NetQINIFileVerKName="GroupKVersion"	// component K version key
	@QString @NetQINIFileVerLName="GroupLVersion"	// component L version key
	@QString @NetQINIFileVerMName="GroupMVersion"	// component M version key
	@QString @NetQINIFileVerNName="GroupNVersion"	// component N version key
	@QString @NetQINIFileVerOName="GroupOVersion"	// component O version key
	@QString @NetQINIFileVerPName="GroupPVersion"	// component P version key
	@QString @NetQINIFileVerQName="GroupQVersion"	// component Q version key
	@QString @NetQINIFileVerRName="GroupRVersion"	// component R version key
	@QString @NetQINIFileVerSName="GroupSVersion"	// component S version key
	@QString @NetQINIFileVerTName="GroupTVersion"	// component T version key
	@QString @NetQINIFileVerUName="GroupUVersion"	// component U version key
	@QString @NetQINIFileVerVName="GroupVVersion"	// component V version key
	@QString @NetQINIFileVerWName="GroupWVersion"	// component W version key
	@QString @NetQINIFileVerXName="GroupXVersion"	// component X version key
	@QString @NetQINIFileVerYName="GroupYVersion"	// component Y version key
	@QString @NetQINIFileVerZName="GroupZVersion"	// component Z version key
	@QString @NetQINIFileVerAVal			// component A version value
	@QString @NetQINIFileVerBVal			// component B version value
	@QString @NetQINIFileVerCVal			// component C version value
	@QString @NetQINIFileVerDVal			// component D version value
	@QString @NetQINIFileVerEVal			// component E version value
	@QString @NetQINIFileVerFVal			// component F version value
	@QString @NetQINIFileVerGVal			// component G version value
	@QString @NetQINIFileVerHVal			// component H version value
	@QString @NetQINIFileVerIVal			// component I version value
	@QString @NetQINIFileVerJVal			// component J version value
	@QString @NetQINIFileVerKVal			// component K version value
	@QString @NetQINIFileVerLVal			// component L version value
	@QString @NetQINIFileVerMVal			// component M version value
	@QString @NetQINIFileVerNVal			// component N version value
	@QString @NetQINIFileVerOVal			// component O version value
	@QString @NetQINIFileVerPVal			// component P version value
	@QString @NetQINIFileVerQVal			// component Q version value
	@QString @NetQINIFileVerRVal			// component R version value
	@QString @NetQINIFileVerSVal			// component S version value
	@QString @NetQINIFileVerTVal			// component T version value
	@QString @NetQINIFileVerUVal			// component U version value
	@QString @NetQINIFileVerVVal			// component V version value
	@QString @NetQINIFileVerWVal			// component W version value
	@QString @NetQINIFileVerXVal			// component X version value
	@QString @NetQINIFileVerYVal			// component Y version value
	@QString @NetQINIFileVerZVal			// component Z version value
@EndVars

//
//------------------------------------------------------------------------------------------------------
// procedure NetQSetCompatData
//
// description: This procedure appends a component number to the old style component number string.
//------------------------------------------------------------------------------------------------------
//

@DefineFunc @Void @NetQSetCompatData( @In @QString @vers, @InOut @QString @line, @In @QString @data )

	// if the component is installed

	@If( "@vers" != "000.000.0000.0000" )

		// append component number to output line

		@If( "@line" == "" )
			@line = "@data"
		@Else
			@line = "@line @data"
		@EndIf
	@EndIf

	// done

	@Return()
@EndFunc

//
//------------------------------------------------------------------------------------------------------
// procedure NetQWriteCompatFile
//
// description: This procedure writes the old style install compatability file (INSTALL.SYS).
//		Note that only the minimum required elements are written.
//------------------------------------------------------------------------------------------------------
//

@DefineVars
	@QString @NetQWriteCompatFileName		// INSTALL.SYS pathname
	@QSTring @NetQWriteCompatFileData		// data for Custom=... line
@EndVars

@DefineFunc @Void @NetQWriteCompatFile( @Void )

	// preset file name and reset component data

	@NetQWriteCompatFileName = "@NetQINIFileDirVal\\INSTALL.SYS"
	@NetQWriteCompatFileData = ""

	// create compatability component data

	@NetQSetCompatData( @NetQINIFileVerAVal, @NetQWriteCompatFileData, "01" )
	@NetQSetCompatData( @NetQINIFileVerBVal, @NetQWriteCompatFileData, "02" )
	@NetQSetCompatData( @NetQINIFileVerCVal, @NetQWriteCompatFileData, "03" )
	@NetQSetCompatData( @NetQINIFileVerDVal, @NetQWriteCompatFileData, "04" )
	@NetQSetCompatData( @NetQINIFileVerEVal, @NetQWriteCompatFileData, "05" )
	@NetQSetCompatData( @NetQINIFileVerFVal, @NetQWriteCompatFileData, "06" )
	@NetQSetCompatData( @NetQINIFileVerGVal, @NetQWriteCompatFileData, "07" )
	@NetQSetCompatData( @NetQINIFileVerHVal, @NetQWriteCompatFileData, "08" )
	@NetQSetCompatData( @NetQINIFileVerIVal, @NetQWriteCompatFileData, "09" )
	@NetQSetCompatData( @NetQINIFileVerJVal, @NetQWriteCompatFileData, "10" )
	@NetQSetCompatData( @NetQINIFileVerKVal, @NetQWriteCompatFileData, "11" )
	@NetQSetCompatData( @NetQINIFileVerLVal, @NetQWriteCompatFileData, "12" )
	@NetQSetCompatData( @NetQINIFileVerMVal, @NetQWriteCompatFileData, "13" )
	@NetQSetCompatData( @NetQINIFileVerNVal, @NetQWriteCompatFileData, "14" )
	@NetQSetCompatData( @NetQINIFileVerOVal, @NetQWriteCompatFileData, "15" )
	@NetQSetCompatData( @NetQINIFileVerPVal, @NetQWriteCompatFileData, "16" )
	@NetQSetCompatData( @NetQINIFileVerQVal, @NetQWriteCompatFileData, "17" )
	@NetQSetCompatData( @NetQINIFileVerRVal, @NetQWriteCompatFileData, "18" )
	@NetQSetCompatData( @NetQINIFileVerSVal, @NetQWriteCompatFileData, "19" )
	@NetQSetCompatData( @NetQINIFileVerTVal, @NetQWriteCompatFileData, "20" )
	@NetQSetCompatData( @NetQINIFileVerUVal, @NetQWriteCompatFileData, "21" )
	@NetQSetCompatData( @NetQINIFileVerVVal, @NetQWriteCompatFileData, "22" )
	@NetQSetCompatData( @NetQINIFileVerWVal, @NetQWriteCompatFileData, "23" )
	@NetQSetCompatData( @NetQINIFileVerXVal, @NetQWriteCompatFileData, "24" )
	@NetQSetCompatData( @NetQINIFileVerYVal, @NetQWriteCompatFileData, "25" )
	@NetQSetCompatData( @NetQINIFileVerZVal, @NetQWriteCompatFileData, "26" )

	// write data to old style file

	@Write( @NetQWriteCompatFileName, "wt", "[InstallOptions]\nInstallPath1=@NetQINIFileDirVal\nCustom=@NetQWriteCompatFileData\n" )

	// done

	@Return()
@EndFunc

//
//------------------------------------------------------------------------------------------------------
// procedure NetQWriteINIFile
//
// input:  mode - the operation mode (0=remove, >0=install)
//
// description: This procedure removes/writes the NetQuestion INI file data to OS2.INI and NETQ11.INI.
//------------------------------------------------------------------------------------------------------
//

@DefineFunc @Void @NetQWriteINIFile( @In @Integer @mode )

	// if removal is requested

	@If( @mode == 0 )

		// remove entry from OS2.INI

		@OS2SetINI( @NetQINIFileApp, @NetQINIFileKey1, "", "HINI_USERPROFILE" )

		// done

		@Return()
	@EndIf

	// write entry (link to NETQ11.INI) to OS2.INI

	@OS2SetINI( @NetQINIFileApp, @NetQINIFileKey1, @NetQINIFileName, "HINI_USERPROFILE" )

	// write INI file data to NETQ11.INI

	@OS2SetINI( @NetQINIFileKey2, @NetQINIFileDirName,     @NetQINIFileDirVal,     @NetQINIFileName )
	@OS2SetINI( @NetQINIFileKey2, @NetQINIFileFolderName,  @NetQINIFileFolderVal,  @NetQINIFileName )
	@OS2SetINI( @NetQINIFileKey2, @NetQINIFileLangName,    @NetQINIFileLangVal,    @NetQINIFileName )
	@OS2SetINI( @NetQINIFileKey2, @NetQINIFileFixPackName, @NetQINIFileFixPackVal, @NetQINIFileName )

	@OS2SetINI( @NetQINIFileKey2, @NetQINIFileVerAName, @NetQINIFileVerAVal, @NetQINIFileName )
	@OS2SetINI( @NetQINIFileKey2, @NetQINIFileVerBName, @NetQINIFileVerBVal, @NetQINIFileName )
	@OS2SetINI( @NetQINIFileKey2, @NetQINIFileVerCName, @NetQINIFileVerCVal, @NetQINIFileName )
	@OS2SetINI( @NetQINIFileKey2, @NetQINIFileVerDName, @NetQINIFileVerDVal, @NetQINIFileName )
	@OS2SetINI( @NetQINIFileKey2, @NetQINIFileVerEName, @NetQINIFileVerEVal, @NetQINIFileName )
	@OS2SetINI( @NetQINIFileKey2, @NetQINIFileVerFName, @NetQINIFileVerFVal, @NetQINIFileName )
	@OS2SetINI( @NetQINIFileKey2, @NetQINIFileVerGName, @NetQINIFileVerGVal, @NetQINIFileName )
	@OS2SetINI( @NetQINIFileKey2, @NetQINIFileVerHName, @NetQINIFileVerHVal, @NetQINIFileName )
	@OS2SetINI( @NetQINIFileKey2, @NetQINIFileVerIName, @NetQINIFileVerIVal, @NetQINIFileName )
	@OS2SetINI( @NetQINIFileKey2, @NetQINIFileVerJName, @NetQINIFileVerJVal, @NetQINIFileName )
	@OS2SetINI( @NetQINIFileKey2, @NetQINIFileVerKName, @NetQINIFileVerKVal, @NetQINIFileName )
	@OS2SetINI( @NetQINIFileKey2, @NetQINIFileVerLName, @NetQINIFileVerLVal, @NetQINIFileName )
	@OS2SetINI( @NetQINIFileKey2, @NetQINIFileVerMName, @NetQINIFileVerMVal, @NetQINIFileName )
	@OS2SetINI( @NetQINIFileKey2, @NetQINIFileVerNName, @NetQINIFileVerNVal, @NetQINIFileName )
	@OS2SetINI( @NetQINIFileKey2, @NetQINIFileVerOName, @NetQINIFileVerOVal, @NetQINIFileName )
	@OS2SetINI( @NetQINIFileKey2, @NetQINIFileVerPName, @NetQINIFileVerPVal, @NetQINIFileName )
	@OS2SetINI( @NetQINIFileKey2, @NetQINIFileVerQName, @NetQINIFileVerQVal, @NetQINIFileName )
	@OS2SetINI( @NetQINIFileKey2, @NetQINIFileVerRName, @NetQINIFileVerRVal, @NetQINIFileName )
	@OS2SetINI( @NetQINIFileKey2, @NetQINIFileVerSName, @NetQINIFileVerSVal, @NetQINIFileName )
	@OS2SetINI( @NetQINIFileKey2, @NetQINIFileVerTName, @NetQINIFileVerTVal, @NetQINIFileName )
	@OS2SetINI( @NetQINIFileKey2, @NetQINIFileVerUName, @NetQINIFileVerUVal, @NetQINIFileName )
	@OS2SetINI( @NetQINIFileKey2, @NetQINIFileVerVName, @NetQINIFileVerVVal, @NetQINIFileName )
	@OS2SetINI( @NetQINIFileKey2, @NetQINIFileVerWName, @NetQINIFileVerWVal, @NetQINIFileName )
	@OS2SetINI( @NetQINIFileKey2, @NetQINIFileVerXName, @NetQINIFileVerXVal, @NetQINIFileName )
	@OS2SetINI( @NetQINIFileKey2, @NetQINIFileVerYName, @NetQINIFileVerYVal, @NetQINIFileName )
	@OS2SetINI( @NetQINIFileKey2, @NetQINIFileVerZName, @NetQINIFileVerZVal, @NetQINIFileName )

	// write old style compatability file

	@NetQWriteCompatFile()

	// done

	@Return()
@EndFunc

//
//------------------------------------------------------------------------------------------------------
// procedure NetQSetINIFile
//
// input:  fpath - the NetQuestion installation path
//
// description: This procedure presets the NetQuestion INI file pathname.
//------------------------------------------------------------------------------------------------------
//

@DefineFunc @Void @NetQSetINIFile( @In @QString @fpath )

	// use the given installation path to create the NETQ11.INI pathname

	@NetQINIFileName   = "@fpath\\@NetQINIFileKey1.INI"
	@NetQINIFileDirVal = "@fpath"

	// done

	@Return()
@EndFunc

//
//------------------------------------------------------------------------------------------------------
// procedure NetQReadINIFileVersion
//
// input:  versionname - the version identifier
//
// output: versionval - the version value
//
// description: This procedure presets/reads a NetQuestion INI file version from NETQ11.INI.
//------------------------------------------------------------------------------------------------------
//

@DefineFunc @Void @NetQReadINIFileVersion( @In @QString @versionname, @InOut @QString @versionval )

	// read version value from NETQ11.INI

	@versionval = @OS2GetINI( @NetQINIFileKey2, @versionname, @NetQINIFileName )

	// in the value does not exist in NETQ11.INI

	@If( "@versionval" == "" )

		// preset to the default value

		@versionval = "000.000.0000.0000"
	@EndIf

		// done

	@Return()
@EndFunc

//
//------------------------------------------------------------------------------------------------------
// procedure NetQReadINIFile
//
// inout:  fpath - the NetQuestion installation path
//
// description: This procedure presets/reads the NetQuestion INI file data from OS2.INI and NETQ11.INI.
//------------------------------------------------------------------------------------------------------
//

@DefineFunc @Void @NetQReadINIFile( @InOut @QString @fpath )

	// preset INI file data to default values

	@NetQINIFileDirVal     = "@fpath"
	@NetQINIFileFolderVal  = ""
	@NetQINIFileLangVal    = "ENG"
	@NetQINIFileFixPackVal = "0"
	@NetQINIFileVerAVal    = "000.000.0000.0000"
	@NetQINIFileVerBVal    = "000.000.0000.0000"
	@NetQINIFileVerCVal    = "000.000.0000.0000"
	@NetQINIFileVerDVal    = "000.000.0000.0000"
	@NetQINIFileVerEVal    = "000.000.0000.0000"
	@NetQINIFileVerFVal    = "000.000.0000.0000"
	@NetQINIFileVerGVal    = "000.000.0000.0000"
	@NetQINIFileVerHVal    = "000.000.0000.0000"
	@NetQINIFileVerIVal    = "000.000.0000.0000"
	@NetQINIFileVerJVal    = "000.000.0000.0000"
	@NetQINIFileVerKVal    = "000.000.0000.0000"
	@NetQINIFileVerLVal    = "000.000.0000.0000"
	@NetQINIFileVerMVal    = "000.000.0000.0000"
	@NetQINIFileVerNVal    = "000.000.0000.0000"
	@NetQINIFileVerOVal    = "000.000.0000.0000"
	@NetQINIFileVerPVal    = "000.000.0000.0000"
	@NetQINIFileVerQVal    = "000.000.0000.0000"
	@NetQINIFileVerRVal    = "000.000.0000.0000"
	@NetQINIFileVerSVal    = "000.000.0000.0000"
	@NetQINIFileVerTVal    = "000.000.0000.0000"
	@NetQINIFileVerUVal    = "000.000.0000.0000"
	@NetQINIFileVerVVal    = "000.000.0000.0000"
	@NetQINIFileVerWVal    = "000.000.0000.0000"
	@NetQINIFileVerXVal    = "000.000.0000.0000"
	@NetQINIFileVerYVal    = "000.000.0000.0000"
	@NetQINIFileVerZVal    = "000.000.0000.0000"

	// try to read NETQ11.INI pathname from OS2.INI

	@NetQINIFileName = @OS2GetINI( @NetQINIFileApp, @NetQINIFileKey1, "HINI_USERPROFILE" )

	// if the pathname of NETQ11.INI does not exist in OS2.INI

	@If( "@NetQINIFileName" == "" )

		// use the given installation path to create the NETQ11.INI pathname

		@NetQINIFileName = "@fpath\\@NetQINIFileKey1.INI"

	// if the pathname of NETQ11.INI exists in OS2.INI

	@Else
		// if the NETQ11.INI file exists

		@If( @Exists( @NetQINIFileName ) )

			// read INI file values from NETQ11.INI

			@NetQINIFileDirVal     = @OS2GetINI( @NetQINIFileKey2, @NetQINIFileDirName,     @NetQINIFileName )
			@NetQINIFileFolderVal  = @OS2GetINI( @NetQINIFileKey2, @NetQINIFileFolderName,  @NetQINIFileName )
			@NetQINIFileLangVal    = @OS2GetINI( @NetQINIFileKey2, @NetQINIFileLangName,    @NetQINIFileName )
			@NetQINIFileFixPackVal = @OS2GetINI( @NetQINIFileKey2, @NetQINIFileFixPackName, @NetQINIFileName )

			@NetQReadINIFileVersion( @NetQINIFileVerAName, @NetQINIFileVerAVal ) 
			@NetQReadINIFileVersion( @NetQINIFileVerBName, @NetQINIFileVerBVal ) 
			@NetQReadINIFileVersion( @NetQINIFileVerCName, @NetQINIFileVerCVal ) 
			@NetQReadINIFileVersion( @NetQINIFileVerDName, @NetQINIFileVerDVal ) 
			@NetQReadINIFileVersion( @NetQINIFileVerEName, @NetQINIFileVerEVal ) 
			@NetQReadINIFileVersion( @NetQINIFileVerFName, @NetQINIFileVerFVal ) 
			@NetQReadINIFileVersion( @NetQINIFileVerGName, @NetQINIFileVerGVal ) 
			@NetQReadINIFileVersion( @NetQINIFileVerHName, @NetQINIFileVerHVal ) 
			@NetQReadINIFileVersion( @NetQINIFileVerIName, @NetQINIFileVerIVal ) 
			@NetQReadINIFileVersion( @NetQINIFileVerJName, @NetQINIFileVerJVal ) 
			@NetQReadINIFileVersion( @NetQINIFileVerKName, @NetQINIFileVerKVal ) 
			@NetQReadINIFileVersion( @NetQINIFileVerLName, @NetQINIFileVerLVal ) 
			@NetQReadINIFileVersion( @NetQINIFileVerMName, @NetQINIFileVerMVal ) 
			@NetQReadINIFileVersion( @NetQINIFileVerNName, @NetQINIFileVerNVal ) 
			@NetQReadINIFileVersion( @NetQINIFileVerOName, @NetQINIFileVerOVal ) 
			@NetQReadINIFileVersion( @NetQINIFileVerPName, @NetQINIFileVerPVal ) 
			@NetQReadINIFileVersion( @NetQINIFileVerQName, @NetQINIFileVerQVal ) 
			@NetQReadINIFileVersion( @NetQINIFileVerRName, @NetQINIFileVerRVal ) 
			@NetQReadINIFileVersion( @NetQINIFileVerSName, @NetQINIFileVerSVal ) 
			@NetQReadINIFileVersion( @NetQINIFileVerTName, @NetQINIFileVerTVal ) 
			@NetQReadINIFileVersion( @NetQINIFileVerUName, @NetQINIFileVerUVal ) 
			@NetQReadINIFileVersion( @NetQINIFileVerVName, @NetQINIFileVerVVal ) 
			@NetQReadINIFileVersion( @NetQINIFileVerWName, @NetQINIFileVerWVal ) 
			@NetQReadINIFileVersion( @NetQINIFileVerXName, @NetQINIFileVerXVal ) 
			@NetQReadINIFileVersion( @NetQINIFileVerYName, @NetQINIFileVerYVal ) 
			@NetQReadINIFileVersion( @NetQINIFileVerZName, @NetQINIFileVerZVal ) 

			// if the installation path is valid

			@If( "@NetQINIFileDirVal" != "" )

				// return the current installation path

				@fpath = "@NetQINIFileDirVal"

			// if the installation path is not valid

			@Else
				@NetQINIFileDirVal = "@fpath"
			@EndIf

		// if the NETQ11.INI file does not exist

		@Else
			// use the given installation path to create the NETQ11.INI pathname

			@NetQINIFileName   = "@fpath\\@NetQINIFileKey1.INI"
		@EndIf
	@EndIf

	// done

	@Return()
@EndFunc

//
//------------------------------------------------------------------------------------------------------
// procedure NetQModPath
//
// input:  fname   - full pathname of CONFIG.NEW
//	   element - the CONFIG.SYS line to be processed
//         mode    - the operation mode (0=remove, >0=install)
//	   ipath   - the NetQuestion installation path
//
// inout:  fmode - file access mode for CONFIG.NEW
//
// description: This procedure removes/appends the NetQuestion installation directory from/to the given
//		path variable.
//------------------------------------------------------------------------------------------------------
//

@DefineVars
	@QString @NetQModPathVar		// variable name
	@QString @NetQModPathData		// variable data
	@Integer @NetQModPathIndex		// element index counter
	@QString @NetQModPathElement		// current data element
@EndVars

@DefineFunc @Void @NetQModPath(  @In @QString @fname, @InOut @QString @fmode, @In @QString @element, @In @Integer @mode, @In @QString @ipath )

	// get variable name and data from line, reset element index
	@NetQModPathVar   = @StrToken( @element, 0, "=" )
	@NetQModPathData  = @StrToken( @element, 1, "=" )
	@NetQModPathIndex = 0

	// write out variable name and equality character, set file access mode to overwrite

	@Write( @fname, @fmode, "@NetQModPathVar=" )
	@fmode = "at"

NetQModPathLoop:

	// get next element from data

	@NetQModPathElement = @StrToken( @NetQModPathData, @NetQModPathIndex, ";" )

	// if there is still an element

	@If( "@NetQModPathElement" != "" )

		// if this is not the NetQuestion installation path

		@If( @StrCmpNos( @NetQModPathElement, @ipath ) != 0 )

			// write out the current element to CONFIG.NEW

			@Write( @fname, @fmode, "@NetQModPathElement;" )
		@EndIf

		// calulate next element index

		@NetQModPathIndex = @Eval( @NetQModPathIndex + 1 )

		// process next element

		@Goto NetQModPathLoop
	@Endif

	// if in install mode

	@If( @mode != 0 )

		// append NetQuestion installation path to CONFIG.NEW

		@Write( @fname, @fmode, "@ipath;" )
	@EndIf

	// append newline character to complete the line written

	@Write( @fname, @fmode, "\n" )

	// done

	@Return()
@EndFunc

//
//------------------------------------------------------------------------------------------------------
// procedure NetQModNLSPath
//
// input:  fname   - full pathname of CONFIG.NEW
//	   element - the CONFIG.SYS line to be processed
//         mode    - the operation mode (0=remove, >0=install)
//	   ipath   - the NetQuestion installation path
//
// inout:  fmode - file access mode for CONFIG.NEW
//
// description: This procedure removes/appends the NetQuestion installation directory from/to the given
//		path variable.
//------------------------------------------------------------------------------------------------------
//

@DefineVars
	@QString @NetQModNLSPathVar		// variable name
	@QString @NetQModNLSPathData		// variable data
	@Integer @NetQModNLSPathIndex		// element index counter
	@QString @NetQModNLSPathElement		// current data element
	@QString @NetQModNLSPathIpath		// NetQuestion Path
@EndVars

@DefineFunc @Void @NetQModNLSPath(  @In @QString @fname, @InOut @QString @fmode, @In @QString @element, @In @Integer @mode, @In @QString @ipath )

	// get variable name and data from line, reset element index
	@NetQModNLSPathVar   = @StrToken( @element, 0, "=" )
	@NetQModNLSPathData  = @StrToken( @element, 1, "=" )
	@NetQModNLSPathIndex = 0
	@NetQModNLSPathIpath = "@ipath\\%N"

	// write out variable name and equality character, set file access mode to overwrite

	@Write( @fname, @fmode, "@NetQModNLSPathVar=" )
	@fmode = "at"

NetQModNLSPathLoop:

	// get next element from data

	@NetQModNLSPathElement = @StrToken( @NetQModNLSPathData, @NetQModNLSPathIndex, ";" )

	// if there is still an element

	@If( "@NetQModNLSPathElement" != "" )

		// if this is not the NetQuestion installation path

		@If( @StrCmpNos( @NetQModNLSPathElement, @NetQModNLSPathIpath ) != 0 )

			// write out the current element to CONFIG.NEW

			@Write( @fname, @fmode, "@NetQModNLSPathElement;" )
		@EndIf

		// calulate next element index

		@NetQModNLSPathIndex = @Eval( @NetQModNLSPathIndex + 1 )

		// process next element

		@Goto NetQModNLSPathLoop
	@Endif

	// if in install mode

	@If( @mode  & @NetQComponentICSL )

		// append NetQuestion installation path to CONFIG.NEW

		@Write( @fname, @fmode, "@NetQModNLSPathIpath;" )
	@EndIf

	// append newline character to complete the line written

	@Write( @fname, @fmode, "\n" )

	// done

	@Return()
@EndFunc

//
//------------------------------------------------------------------------------------------------------
// procedure NetQEnv
//
// input:  mode  - the operation mode: 0=remove, >0=install (bitmap):
//	   ipath - the NetQuestion installation path
//
// description: This procedure adds/removes all NetQuestion related data to/from CONFIG.SYS.
//------------------------------------------------------------------------------------------------------
//

@DefineVars
	@Integer @NetQEnvResult					// procedure call result memory
	@QString @NetQEnvFile = "@BootDrive:\\CONFIG.SYS"	// full pathname of CONFIG.SYS
	@QString @NetQEnvFileNew = "@BootDrive:\\CONFIG.NEW"	// full pathname of CONFIG.NEW
	@QString @NetQEnvFileSav = "@BootDrive:\\CONFIG.NQ"	// full pathname of CONFIG.NQ
	@QString @NetQEnvLine					// current line of CONFIG.SYS
	@QString @NetQEnvMode					// file access mode for CONFIG.NEW
	@Integer @NetQEnvWrite					// write line to CONFIG.NEW flag
	@QString @NetQEnvItem					// current CONFIG.SYS variable name
	@Byte    @NetQEnvEOF = @Eval( 0x1a )			// ^Z character
	@Integer @NetQEnvNLS					// NLSPATH processing flag
@EndVars

@DefineFunc @Void @NetQEnv( @In @Integer @mode, @In @QString @ipath )

	// reset NLSPATH processing flag

	@NetQEnvNLS = 0

	// preset writing mode to overwrite

	@NetQEnvMode = "wt"

	// read first line of CONFIG.SYS

	@NetQEnvLine = ""
	@NetQEnvResult = @ReadLine( @NetQEnvFile, @NetQEnvLine, 2048, 0 )

	// remove possible trailing ^Z

	@If( @StrIndex( @StrTail( @NetQEnvLine, 1 ), 0 ) == @NetQEnvEOF )
		@NetQEnvLine = @StrHead( @NetQEnvLine, @Eval( @Strlen( @NetQEnvLine ) - 1 ) )
	@EndIf

NetQEnvLoop:

	// in case of End Of File

	@If( @NetQEnvResult == -1 )

		// if the line is not empty

		@If( "@NetQEnvLine" != "" )

			// set the result to 'process last line'

			@NetQEnvResult = -2
		@Endif
	@EndIf

	// if not End Of File

	@If( @NetQEnvResult != -1 )

		// preset to write out line read

		@NetQEnvWrite = 1

		// figure out if the line is a var=data line

		@NetQEnvResult = @StrFind( @NetQEnvLine, "=" )

		// if so

		@If( @NetQEnvResult != -1 )

			// preset not to write out line

			@NetQEnvWrite = 0

			// get var part of the var=data line and convert it to uppercase

			@NetQEnvItem = @StrToken( @NetQEnvLine, 0, "=\t " )
			@NetQEnvItem = @StrUpr( @NetQEnvItem )
			@If( "@NetQEnvItem" == "SET" )
				@NetQEnvItem = @StrToken( @NetQEnvLine, 1, "=\t " )
				@NetQEnvItem = @StrUpr( @NetQEnvItem )
			@EndIf

			// process PATH, DPATH, LIBPATH and NLSPATH (if NLSPATH exists)

			@If( "@NetQEnvItem" == "PATH" )
				@NetQModPath( @NetQEnvFileNew, @NetQEnvMode, @NetQEnvLine, @mode, @ipath )
			@ElseIf( "@NetQEnvItem" == "DPATH" )
				@NetQModPath( @NetQEnvFileNew, @NetQEnvMode, @NetQEnvLine, @mode, @ipath )
			@ElseIf( "@NetQEnvItem" == "LIBPATH" )
				@NetQModPath( @NetQEnvFileNew, @NetQEnvMode, @NetQEnvLine, @mode, @ipath )
			@ElseIf( "@NetQEnvItem" == "NLSPATH" )
				@NetQModNLSPath( @NetQEnvFileNew, @NetQEnvMode, @NetQEnvLine, @mode, @ipath )
				@NetQEnvNLS = 1

			// remove all NetQuestion owned environment variables

			@ElseIf( "@NetQEnvItem" == "IMNDATASRV" )
			@ElseIf( "@NetQEnvItem" == "IMNDATACL" )
			@ElseIf( "@NetQEnvItem" == "IMNWORKSRV" )
			@ElseIf( "@NetQEnvItem" == "IMNWORKCL" )
			@ElseIf( "@NetQEnvItem" == "IMNNLPSSRV" )
			@ElseIf( "@NetQEnvItem" == "IMNNLPSCL" )
			@ElseIf( "@NetQEnvItem" == "IMNCCCFGFILE" )
			@ElseIf( "@NetQEnvItem" == "IMNCSCFGFILE" )
			@ElseIf( "@NetQEnvItem" == "IMQCONFIGSRV" )
			@ElseIf( "@NetQEnvItem" == "IMQCONFIGCL" )
			@ElseIf( "@NetQEnvItem" == "LITE_LOCALES" )  // still required for MWS, deinstall previous ICSL

			// write out all other lines

			@Else
				@NetQEnvWrite = 1
			@EndIf
		@Endif

		// if writing is selected

		@If( @NetQEnvWrite == 1 )

			// write line to CONFIG.NEW and set access mode to append

			@Write( @NetQEnvFileNew, @NetQEnvMode, "@NetQEnvLine\n" )
			@NetQEnvMode = "at"
		@EndIf

		// if not in 'process last line' mode

		@If( @NetQEnvResult != -2 )

			// read next line of CONFIG.SYS

			@NetQEnvLine = ""
			@NetQEnvResult = @ReadLine( , @NetQEnvLine, 2048, )

			// remove possible trailing ^Z

			@If( @StrIndex( @StrTail( @NetQEnvLine, 1 ), 0 ) == @NetQEnvEOF )
				@NetQEnvLine = @StrHead( @NetQEnvLine, @Eval( @Strlen( @NetQEnvLine ) - 1 ) )
			@EndIf

			// process line

			@Goto NetQEnvLoop
		@EndIf
	@EndIf

	// write SBCS environment variables to CONFIG.NEW if selected

	@NetQEnvResult = @Eval( @mode & @NetQComponentSBCS )

	@If( @NetQEnvResult )
		@Write( @NetQEnvFileNew, @NetQEnvMode, "SET IMNDATASRV=@ipath\\DATA\n" )
		@NetQEnvMode = "at"
		@Write( @NetQEnvFileNew, @NetQEnvMode, "SET IMNDATACL=@ipath\\DATA\n" )
		@NetQEnvMode = "at"
		@Write( @NetQEnvFileNew, @NetQEnvMode, "SET IMNWORKSRV=@ipath\\WORK\n" )
		@NetQEnvMode = "at"
		@Write( @NetQEnvFileNew, @NetQEnvMode, "SET IMNWORKCL=@ipath\\WORK\n" )
		@NetQEnvMode = "at"
		@Write( @NetQEnvFileNew, @NetQEnvMode, "SET IMNNLPSSRV=@ipath\n" )
		@NetQEnvMode = "at"
		@Write( @NetQEnvFileNew, @NetQEnvMode, "SET IMNNLPSCL=@ipath\n" )
		@NetQEnvMode = "at"
		@Write( @NetQEnvFileNew, @NetQEnvMode, "SET IMNCCCFGFILE=NETQ.CFG\n" )
		@NetQEnvMode = "at"
		@Write( @NetQEnvFileNew, @NetQEnvMode, "SET IMNCSCFGFILE=NETQ.CFG\n" )
		@NetQEnvMode = "at"
	@EndIf

	// write DBCS environment variables to CONFIG.NEW if selected

	@NetQEnvResult = @Eval( @mode & @NetQComponentDBCS )

	@If( @NetQEnvResult )
		@Write( @NetQEnvFileNew, @NetQEnvMode, "SET IMQCONFIGSRV=@ipath\\INSTANCE\n" )
		@NetQEnvMode = "at"
		@Write( @NetQEnvFileNew, @NetQEnvMode, "SET IMQCONFIGCL=@ipath\\INSTANCE\\DBCSHELP\n" )
		@NetQEnvMode = "at"
	@EndIf

	// write ICS Lite environment variables to CONFIG.NEW if selected

        // disabled
        //         since NetQ Web Server does not need the environment variables
	// @NetQEnvResult = @Eval( @mode & @NetQComponentICSL )

        // @If( @NetQEnvResult )
        //   @Write( @NetQEnvFileNew, @NetQEnvMode, "SET LITE_LOCALES=@ipath\n" )
        //   @NetQEnvMode = "at"
        //   @If( @NetQEnvNLS == 0 )
        //     @Write( @NetQEnvFileNew, @NetQEnvMode, "SET NLSPATH=@ipath\\%N\n" )
        //     @NetQEnvMode = "at"
        //   @EndIf
        // @EndIf
        // end disabled

	// backup CONFIG.SYS to CONFIG.NQ

	@Copy( @NetQEnvFile, @NetQEnvFileSav )

	// copy CONFIG.NEW to CONFIG.SYS

	@Copy( @NetQEnvFileNew, @NetQEnvFile )

	// delete CONFIG.NEW

	@Delete( @NetQEnvFileNew )

	// done

	@Return()
@EndFunc

// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// +                                             Main                                                  +
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

//
//------------------------------------------------------------------------------------------------------
// Actual Processing
//------------------------------------------------------------------------------------------------------
//

@DefineVars
	@Integer @NetQInstallSelection		// components selected for installation
	@QString @NetQInstallPath		// NetQuestion full installation path
	@Integer @NetQInstallItems		// components that must be installed
	@Integer @NetQInstallSize		// total size of components not yet installed
	@Integer @NetQInstallSpace		// total space left on device
	@Integer @NetQInstallNMem		// IfNewerMode memory
	@Drive   @NetQInstallDMem		// output device memory
	@QString @NetQInstallSMem		// output directory memory
	@Integer @NetQInstallDirMode		// flag for directory selection enable
	@Integer @NetQInstallBuildMode		// build time component select enable
	@QString @NetQInstallResponseFile	// response file name or empty string
	@Integer @NetQInstallRebootMode		// reboot after install flag
@EndVars

// reset basic variables

@NetQInstallPath         = ""
@NetQInstallResponseFile = ""
@NetQInstallBuildMode    = 0
@NetQInstallSelection    = 0
@NetQInstallRebootMode   = 0

// parse command line

@NetQParseCmdLine( @NetQInstallBuildMode, @NetQInstallResponseFile )

// if a response file is given

@If( "@NetQInstallResponseFile" != "" )

	// parse response file, terminate execution in case of error (write optional error file)

	@If( ! @NetQParseResponseFile( @NetQInstallResponseFile, @NetQInstallPath, @NetQInstallSelection, @NetQInstallRebootMode ) )
		@NetQWriteErrFile( "2" )
		@Abort
	@EndIf

// if no response file is given

@Else
	// load background bitmap

	@ShowBMP( 0, 0, 0, "@InDrive:VABACK1._B_", 2, @WinScreenCaps( 8 ), @Eval( @WinScreenCaps( 10 ) - 15 ) )
@EndIf

// read INI file data

@NetQReadINIFile( @NetQInstallPath )

// get component sizes

@NetQReadLIBSizes()

// if no response file was given

@If( "@NetQInstallResponseFile" == "" )

	// set up directory selection mode as well as default directory

	@If( "@NetQInstallPath" == "" )
		@NetQInstallPath = "@OutDrive:@SubDir"
		@NetQInstallDirMode = 1
	@Else
		@NetQInstallDirMode = 0
	@EndIf

	// process menus

	@NetQInstallSelection = @NetQMenuProcessor( @NetQInstallPath, @NetQInstallDirMode, @NetQInstallBuildMode )

	// set actual path to inifile if directory editing was enabled

	@If( @NetQInstallDirMode )
		@NetQSetINIFile( @NetQInstallPath )
	@EndIf
@EndIf

// assert that components already installed are selected

@NetQSetInstalledComponents( @NetQInstallSelection )

// assert that prerequisite components are selected

@NetQSetPrereqs( @NetQInstallSelection )

// get the components that have actually to be installed

@NetQInstallItems = @NetQSelectComponentsForInstall( @NetQInstallSelection, 0 )

// done, if no components have to be installed (but call optional user supplied configuration file)

@If( @NetQInstallItems == 0 )
	@NetQCallConfigBatch( @NetQInstallPath )
	@Abort
@EndIf

// get the total size of all components not yet installed

@NetQInstallSize = @NetQSelectComponentsForInstall( @NetQInstallSelection, 1 )

// get the total space left on device

@NetQInstallSpace = @NetQGetDiskSpace( @NetQInstallPath )

// evaluate the remaining space left on device after installation (headroom 32K)

@NetQInstallSpace = @Eval( @NetQInstallSpace - @NetQInstallSize - 32768 )

// abort, if there is insufficient space left

@If( @NetQInstallSpace < 0 )
	@NetQWriteErrFile( "3" )
	@Abort
@EndIf

// set the component groups for installation (courtesy of KDC installation is not possible within a function)
// furthermore set output drive and directory, update version data

// reset all group settings

@FlushGroups()

// assert that all files are installed and set output device and directory as well as disk amount

@IfNewerMode   = @False
@OutDrive      = @StrIndex( @StrUpr( @NetQInstallPath ), ( @StrFind( @NetQInstallPath, ":\\" ) - 1 ) )
@SubDir        = @StrDel( "@NetQInstallPath", 0, ( @StrFind( @NetQInstallPath, ":\\" ) + 1 ) )
@NumberOfDisks = 0

// set the groups for the selected components and set the new INI file values

@If( @NetQInstallItems & @NetQComponentSBCS )
	@SetGroup( A )
	@NetQINIFileVerAVal = "@NetQComponentAVersion"
	@NumberOfDisks = @Eval( @NumberOfDisks + 2 )
@Endif
@If( @NetQInstallItems & @NetQComponentICSL )
	@SetGroup( B )
	@NetQINIFileVerBVal = "@NetQComponentBVersion"
	@NumberOfDisks = @Eval( @NumberOfDisks + 1 )
@Endif
@If( @NetQInstallItems & @NetQComponentDBCS )
	@SetGroup( C )
	@NetQINIFileVerCVal = "@NetQComponentCVersion"
	@NumberOfDisks = @Eval( @NumberOfDisks + 1 )
@Endif
@If( @NetQInstallItems & @NetQComponentSBCSB )
	@SetGroup( D )
	@NetQINIFileVerDVal = "@NetQComponentDVersion"
	@NumberOfDisks = @Eval( @NumberOfDisks + 1 )
@Endif
@If( @NetQInstallItems & @NetQComponentDBCSB )
	@SetGroup( E )
	@NetQINIFileVerEVal = "@NetQComponentEVersion"
	@NumberOfDisks = @Eval( @NumberOfDisks + 1 )
@EndIf

// if a response file is given

@If( "@NetQInstallResponseFile" != "" )

	// hide progress bar

	@DefineProject
		@Terse
	@EndProject
@EndIf

// now actually install files (DefineDisk works SOOOO nicely outside a function...)
// note: the call to NetQKillServers asserts that the required servers are terminated
// by the way: make sure that the goup files exist, else KDC will just do nothing...

@DefineDisk
	@Label = "x"
	@BeginLib @NetQLIBUFileName
		@File *.* @Group A
	@EndLib
@EndDisk

@NetQKillServers( @NetQInstallPath )

@DefineDisk
	@Label = "x"
	@BeginLib @NetQLIBFileAName
		@File *.* @Group A
	@EndLib
@EndDisk

@DefineDisk
	@Label = "x"
	@BeginLib @NetQLIBFileBName
		@File *.* @Group B
	@EndLib
@EndDisk

@If( @NetQInstallItems & @NetQComponentDBCS )
@DefineDisk
	@Label = "x"
	@BeginLib @NetQLIBFileCName
		@File *.* @Group C
	@EndLib
@EndDisk
@EndIf

@If( @NetQInstallItems & @NetQComponentSBCSB )
@DefineDisk
	@Label = "x"
	@BeginLib @NetQLIBFileDName
		@File *.* @Group D
	@EndLib
@EndDisk
@EndIf

@If( @NetQInstallItems & @NetQComponentDBCSB )
@DefineDisk
	@Label = "x"
	@BeginLib @NetQLIBFileEName
		@File *.* @Group E
	@EndLib
@EndDisk
@EndIf

// if no response file was given, show environment setup bitmap

@If( "@NetQInstallResponseFile" == "" )
	@ShowBMP( 1, @Eval( @WinScreenCaps( 8 ) / 10 ), @Eval( @WinScreenCaps( 10 ) - ( @WinScreenCaps( 10 ) / 10 ) ) - 156, "@InDrive:MSGENV._B_", 2 )
@EndIf

// configure the servers as required

@NetQPrepareServers( @NetQInstallPath, @OutDrive, @SubDir )

// adjust CONFIG.SYS according to the components now installed

@NetQEnv( @NetQInstallSelection, @NetQInstallPath )

// in build time mode install desktop folder and icons

@If( @NetQInstallBuildMode )
	@NetQDesktop( 1, @NetQInstallPath )
@EndIf

// write version data back to the INI file

@NetQWriteINIFile( 1 )

// call optional user supplied configuration file

@NetQCallConfigBatch( @NetQInstallPath )

// if no response file was given, erase environment setup bitmap

@If( "@NetQInstallResponseFile" == "" )
	@EraseBMP( 1 )
@EndIf

// if no response file was given

@If( "@NetQInstallResponseFile" == "" )

	// perform reboot dialog

	@NetQInstallRebootMode = @NetQRebootMenu()
@EndIf

// if reboot is selected

@If( @NetQInstallRebootMode )

	// try to reboot using the SETBOOT /IBD feature

	@NetQRebootMenuResult = @Spawn( "@NetQInstallPath\\install\\nqhide.exe setboot.exe /IBD:@BootDrive" )
	@If( @NetQRebootMenuResult != -1 && @NetQRebootMenuResult != 65535 )
		@Abort
	@EndIf

	// if SETBOOT.EXE is not available try to shutdown the system

	@Reboot( "", 2 )
@EndIf

// done

@Abort

