// ----------------------------------------------------------------------
// Copyright © 1994, National Education Training Group, Inc.		-
// All rights reserved.							-
//									-
// Skill Builder 3.1 Course Installation                 by Jerry Malik -                                                                    
//                                                                      -
// $Log$                                                                -
//-----------------------------------------------------------------------

#define MAX_SIZE         145

declare // Must use declare keyword to start variable declaration

string  szText[255], szSpace[10], szDefPath[MAX_SIZE], szWinINI[MAX_SIZE],
	szResultPath[MAX_SIZE], szCourse[20], szCourseName[80], szTitle[200],
	szLMPath[MAX_SIZE], szIVIPath[MAX_SIZE], szIconTag[80], szTagFile[15],
	szIconFile[80], szBitmapPath[255], szSourcePath[MAX_SIZE], szPrevPath[80], 
	szExt[6], szPath[MAX_SIZE], szCoursePath[MAX_SIZE], szLang[6], szType[30],
	szWinDir[MAX_SIZE], szNetwork[10], szCourseString[20], szCourseID[50],
	szTotal[20], szDisk[50], szSrcPath[144], szErrMsg [255], szFileBase[25],
	szDecFile[15], szErrFile [100],	szCommand[MAX_SIZE], szPgrp[40], 
	szFile[80], szWork[80],	szKeyFile[15], szFileList[255], szTimeOut[4],
	szWSPath[MAX_SIZE], szVersion[10];

 
number  nSpace, nSpaceAvail, nTotalCourse, nBaseSpace, nIconwareSpace, 
	nResult, nWavSpace, nAudioSpace, n256space, nHan, nFile, nPresent, 
	n256Color, nDiskNeeded, nOffset, nStrLen, nStMgt, nDisk, bDone;

program //  Must use program keyword to start the statements  


//-------------------------------------------------------------------
//          This procedure initializes screen colors                -
//-------------------------------------------------------------------

Start:
	szBitmapPath = SRCDIR;
	szBitmapPath = szBitmapPath ^ "NETGLOG8.BMP";
	PlaceBitmap( szBitmapPath, 101, 20, 20, UPPER_RIGHT );

       	SetColor( BACKGROUND, BLUE );
       	SetColor( STATUSBAR, RED );
       	SetFont( FONT_TITLE, STYLE_NORMAL, "Helv" );

       	Enable( BACKGROUND );
       
       	szTitle = "Skill Builder ® Installation";
       	SetTitle( szTitle, 18, WHITE );

//--------------------------------------------------------------------
//          This code initializes the windows display                -
//--------------------------------------------------------------------
       	GetDisk( SRCDIR, szDisk );
	szSrcPath = SRCDIR;

	SetStatusWindow( 1, "Setting initial parameters." );
       
// In Info Window to display the file1.lis
       	SetInfoWindow( "Information ", "file1.lis" );

// Enable various objects.
       	Enable( BITMAPFADE );    // All bitmaps will fade into the screen.
       	Enable( INDVFILESTATUS ); // Shows all filenames when copied.
       	Disable( HELP );        //
       	Enable( EXIT );         // Exit Button
       	Disable( PAUSE );       // Pause Button
       	Enable( STATUS );       // Status , % Complete Bar Window
       	Enable( TEXT );         // Info Windows
       	Enable( FEEDBACK_FULL); // Feedback window enabled


	SetStatusWindow( 4, "Setting initial parameters." );

// Set placement of path dialog boxes during installation.

	PlaceWindow( ASKPATH,135,125,UPPER_LEFT );
	PlaceWindow( ASKTEXT,135,125,UPPER_LEFT );

// Gets specific course information from INSTALL.INI
call GetCourseInfo;             

//	Checks for existence of NETG.INI and if not found, copies generic
//	file for installation.

       	szWinDir = WINDIR;			// defines a variable to
	szWinDir = szWinDir ^ "NETG.INI";	// point to NETG.INI

	FindFile( WINDIR, "NETG.INI", szText );
       	if LAST_RESULT != 0
       	then
	  nPresent=0;
	  szPath = TARGETDIR;
	  TARGETDIR = WINDIR;
	  CopyFile( "NETG.INI", "NETG.INI" );
	  TARGETDIR = szPath;
	  goto GetTargetLoc;
       	endif;

// 	Checks to see if the course has been previously installed.
//	If the course path exists notify the user that the course has been
//	previously installed.


	GetProfString(szWinDir, szCourse, "path", szPath );
	if ( szPath = "")
	then
	  goto GetTargetLoc;
	endif;
	szText = szPath ^ "\\SKILLB";
       	szText = szText ^ szCourse;
       	ExistsDir( szText );
       	if LAST_RESULT = EXISTS
	then
	  nPresent=1;
	  call CoursePresent;
	  StrToUpper ( szPath, szPath );
	  szPath = szPath + "\\";
	else
	  nPresent=0;
	endif;

GetTargetLoc:		// Gets course destination path
call GetTarget;

//-----------------------------------------------------------------------
//		Verifies target is valid, if course has already been 	-
//		installed in the target directory and if the target 	-
//		directory has enough disk space to install the course.	-
//-----------------------------------------------------------------------

VerifyTarget:

  // Invalid disk entered, reprompt

       	GetDisk( szResultPath, szDisk );
       	ExistsDisk( szDisk );
       	if ( LAST_RESULT != EXISTS ) then
	  szText = szDisk;
	  szText = szText + " - is an invalid disk, Press OK to return to the path selection.";
	  MessageBox( szText, WARNING );
	  goto GetTargetLoc;
       	endif;
       
  // Verifies that the target and source drives are different.

	GetDisk( SRCDIR, szText );
	StrCompare( szDisk, szText );
       	if LAST_RESULT = 0
       	then
	  MessageBox( "The target drive must be different from the\n source drive.  Please specify a different location.",WARNING );
	  goto GetTargetLoc;
       	endif;

//	Checks to make sure that there is enough space on the hard drive to
//	install the course.

	call EnoughSpace;

//	Checks to make sure that the course directory can be created.

	szCoursePath = szResultPath ^ "SKILLB";
	szCoursePath = szCoursePath ^ szCourse;
	CreateDir ( szCoursePath );
	if ( LAST_RESULT != 0 ) 
	then
	  MessageBox( "Unable to create the course subdirectory at the specified path.", WARNING );
	  goto GetTargetLoc;
	endif;

//	Creates a directory to hold the Workstation install files.

	if szNetwork = "yes" then
	  szWSPath = szResultPath ^ "SKILLB\\WS";
	  CreateDir ( szWSPath );
	endif;

  //------------------------------------------------------------------------
  //  Looks for Student Management in NETG.INI file.  If file is found, 
  //  prompts user to use Learner Management system.   Else, asks to use 
  //  Learner Management without the system.  If multi-user course, the
  //  Student Management option is automatically turned off.
  //  Settings for nStMgt:	2 - Use Learner Management system
  //				1 - Use Skill Builder's own management
  //				0 - No Learner Management
  //------------------------------------------------------------------------

  //	Checks to see if this is a multi-user course and skips section, 
  //	sets nStMgt = 0 when the course is a network version.

	if( szNetwork = "yes" )
	then
	  nStMgt = 0;
	  goto SetTimeOut;
	endif;
	GetProfString( szWinDir, "StudentManagement", "", szText );
	if ( szText != "" )
	then // NETG's Trainer Management is installed.
	  SetInfoWindow( "Information", "file7.lis" );
	  SetDialogTitle( DLG_ASK_YESNO, "Trainer Management Option" );
	  AskYesNo ("Do you want to use NETG's Trainer Management system?", YES );
	  if ( LAST_RESULT = YES )
	  then
	    nStMgt = 2;
	  else 
	    nStMgt = 0;
	  endif;
	endif;
	
	if nStMgt = 0 
	then  // NETG Trainer Management not used
	  SetInfoWindow( "Information", "file2.lis" );
	  SetDialogTitle( DLG_ASK_YESNO, "Learner Management Option" );
	  AskYesNo ("Do you want to use Skill Builder's \n Learner Management functions?", YES );
	  if LAST_RESULT = YES 
	  then  // Use Skill Builder's Learner Management
	    nStMgt = 1;	
	  else  // Do not use Skill Builder's Learner Managment
	    nStMgt = 0;
	  endif;
	endif;
	
//	If using Student Management calls subroutine to get UserPath.

	if nStMgt != 0
	then
	  call GetLMgt;
	endif;       	

SetTimeOut:
//	Gives student option to set time out feature.

	GetProfString( szWinDir, "NETGctlintf", "TimeOut", szTimeOut );

	if ( szTimeOut = "" ) then
    	  SetInfoWindow( "Information", "file6.lis" );
	  SetDialogTitle( DLG_ASK_YESNO, "Time Out Option" );
	  AskYesNo ("Do you want to set the time out option?", NO );

	  if LAST_RESULT = YES 
	  then
	    szTimeOut = "50";	
	  else 
	    szTimeOut = "0";
	  endif;
	endif;

       	SetInfoWindow( "Information", "file1.lis" );


// ----------------------------------------------------------------------
//	Copies course "CDF" file to course sub directory and updates the
//	EXEC and WORKDIR lines with install specific data.
// ----------------------------------------------------------------------

	GetDisk( SRCDIR, szDisk );
	SRCDIR    =  szDisk ^ "\\";
	TARGETDIR = szCoursePath;

	szFile    = szCourse + ".CDF";

	CopyFile ( szFile, szFile );

	if ( LAST_RESULT != 0 ) then
	  MessageBox( "Missing CDF file in install directory.", WARNING );
	endif;
	

// ----------------------------------------------------------------------
//	Creates course directory and loads files.
// ----------------------------------------------------------------------

LoadCourse:
	
	SetStatusWindow( 11, "Setting initial parameters." );


   //  Decompressing/Copying files to target directory
   //  Show the % Complete Status Bar

	Enable ( STATUS );
	Enable ( FEEDBACK_FULL );
	SetStatusWindow(1, "Installing miscellaneous files.");
	StatusUpdate( 1, 8 );

	if szNetwork = "yes" then

	  TARGETDIR = szResultPath ^ "SKILLB\\WS";

	  if( CompressGet( "WS.Z", "", COMP_UPDATE_DATE_NEWER ) <0) then
	    call CopyError;
	  endif;
	endif;

	TARGETDIR = szResultPath ^ "SKILLB";

   //	Checks for type of install - floppy or CD and calls appropriate 
   //	subroutine.

	GetSystemInfo ( DRIVE, nResult, szDisk );
	if ( nResult = IS_REMOVABLE )
	then
	  call LoadDisk;
	else
	  call LoadCD;	
	endif;
	
	Disable ( FEEDBACK_FULL );
	Disable ( STATUS );

//	Updates course specific information in the  NETG.INI file

	if ( nPresent = 1 ) then
	  WriteProfString( szWinDir, szCourse, "", "" );
	endif;

	if ( szType = "CD" )
	then
	  WriteProfString( szWinDir, szCourse, "CDRom", "1" );
	  WriteProfString( szWinDir, szCourse, "EnableFlag", "6" );
	else
	  WriteProfString( szWinDir, szCourse, "CDRom", "0" );
	  WriteProfString( szWinDir, szCourse, "EnableFlag", "2" );
	endif;

	WriteProfString( szWinDir, "NETGctlintf", "TimeOut", szTimeOut );

	if nStMgt > 0
	then  // Some form of Learner Management is ON.
	  WriteProfString( szWinDir, szCourse, "UserPath", szLMPath );
	  if nStMgt = 2
	  then  // Set code for external Learner Management.
	    WriteProfString( szWinDir, szCourse, "StudentMgt", "2" );
	  else  // Set code for Skill Builder's Learner Management
	    WriteProfString( szWinDir, szCourse, "StudentMgt", "1" );
	  endif;
	else // Learner Management is OFF.
	  WriteProfString( szWinDir, szCourse, "StudentMgt", "0" );
	endif;

	//  Sets a language flag to Microsoft's 3 character code which is
	//  set in the INSTALL.INI file

	WriteProfString( szWinDir, szCourse, "Lang", szLang );

	if nPresent = 0
	then
	  GetProfString( szWinDir, "Course", "Total", szText );
	  StrToNum( nTotalCourse, szText );

       	  GetProfString( szWinDir, szCourse, "Path", szText );
       	  StrLength( szText );
       	  if LAST_RESULT = 0
       	  then
	    WriteProfString( szWinDir, "Course", "Total", "" );
	    Add( nTotalCourse, 1 );
	    NumToStr( szTotal, nTotalCourse );
	    WriteProfString( szWinDir, "Course", "Total", szTotal );
	    szText = "Name";
	    szText = szText + szTotal;
	    WriteProfString( szWinDir, "Course", szText, szCourse );
       	  endif;
	endif;
       	GetProfString( szWinDir, "NETGctlintf", "nedebug", szText );
       	StrLength( szText );
       	if LAST_RESULT != 0
       	then
	  WriteProfString( szWinDir, "NETGctlintf", "nedebug", "" );
       	endif;
	WriteProfString( szWinDir, szCourse, "Path", szResultPath );
	
	call Complete;

	call ExitInstall;


//---------------------------------------------------------------------
//               This code reads the install.ini file to get the      -
//               course number, name, and icon tag.      -
//---------------------------------------------------------------------

GetCourseInfo:
	
       	szSourcePath = SRCDIR;
       	szSourcePath = szSourcePath ^ "install.ini";
    
       	GetProfString( szSourcePath, "course", "number", szCourse );
       	if LAST_RESULT != 0
       	then
	  goto BadInstallINI;
       	endif;

       	GetProfString( szSourcePath, "course", "name", szCourseName );
       	if LAST_RESULT != 0
       	then
	  goto BadInstallINI;
       	endif;
       	GetProfString( szSourcePath, "course", "courseid", szCourseID );
       	if LAST_RESULT != 0
       	then
	  goto BadInstallINI;
       	endif;

       	GetProfString( szSourcePath, "course", "icon", szIconTag );
       	if LAST_RESULT != 0
       	then
	  goto BadInstallINI;
       	endif;

       	GetProfString( szSourcePath, "course", "iconfile", szIconFile );
       	if LAST_RESULT != 0
       	then
	  goto BadInstallINI;
       	endif;

       	GetProfString( szSourcePath, "install", "network", szNetwork );

       	if LAST_RESULT != 0
       	then
	  goto BadInstallINI;
       	endif;
  
     	GetProfString( szSourcePath, "install", "type", szType );

       	if LAST_RESULT != 0
       	then
	  goto BadInstallINI;
       	endif;

       	GetProfString( szSourcePath, "install", "lang", szLang );

       	if LAST_RESULT != 0
       	then
	  goto BadInstallINI;
       	endif;

       	GetProfString( szSourcePath, "install", "ver", szVersion );

       	if LAST_RESULT != 0
       	then
	  goto BadInstallINI;
       	endif;

//--------------------------------------------------------------------
//              This procedure reads the install.ini file            -
//                 to get the course space requirements.             -
//--------------------------------------------------------------------


       	GetProfString( szSourcePath, "space", "base", szSpace );
       	if LAST_RESULT != 0
       	then
	  goto BadInstallINI;	  
       	endif;
       	StrToNum( nBaseSpace, szSpace );

       	GetProfString( szSourcePath, "space", "256base", szSpace );
       	if LAST_RESULT != 0
       	then
	  goto BadInstallINI;
       	endif;
       	StrToNum( n256space, szSpace );

       	GetProfString( szSourcePath, "space", "iconware", szSpace );
        if LAST_RESULT != 0
        then
	  goto BadInstallINI;
        endif;
        StrToNum( nIconwareSpace, szSpace );

       	GetProfString( szSourcePath, "space", "wav", szSpace );
       	if LAST_RESULT != 0
       	then
	  goto BadInstallINI;
       	endif;
       	StrToNum( nWavSpace, szSpace );

        GetProfString( szSourcePath, "space", "audio", szSpace );
       	if LAST_RESULT != 0
       	then
	  goto BadInstallINI;
        endif;
        StrToNum(nAudioSpace, szSpace );

       	return;

//--------------------------------------------------------------------
//            This procedure asks the user for the
//         location ( Disk & path ) to install course.
//--------------------------------------------------------------------

GetTarget:

        // Increment % Complete Bar to 4 %, & display message
        SetStatusWindow( 4, "Setting initial parameters." );

	if ( nPresent = 0 )
	then
	  szPath = "C:\\";
	endif;

       	szText = "Please enter the drive letter and path for course, " ;
       	szText = szText + szCourse;
       	szText = szText + ".";

        SetDialogTitle( DLG_ASK_PATH,  "Enter installation path" );
        AskPath( szText, szPath, szResultPath );
        if LAST_RESULT = FALSE
        then
	  call ConfirmCancel;
	  goto GetTarget;
        endif;

	  StrSub(szWork, szResultPath,1,1);
	  if (szWork != ":")
	  then

// 	Invalid disk entered, reprompt

	    szText = "You have entered an invalid path, Press OK to return to the path selection.";
	    MessageBox( szText, WARNING );
	    goto GetTarget;
       	  endif;

	StrLength(szResultPath);
	nOffset = LAST_RESULT - 1;
	if (nOffset < 0)
	then 
	  return;
	endif;
	
	StrSub(szWork, szResultPath, nOffset, 1);
	
	StrCompare( szWork, "\\" );
	if LAST_RESULT = 0		// Trim the last backslash off
	then
	  StrSub(szResultPath, szResultPath, 0, nOffset);
	endif;
	
	return;

//--------------------------------------------------------------------
//	This procedure gets a path for Learner Management.
//--------------------------------------------------------------------

GetLMgt:


	if (nPresent = 1) then
	  GetProfString( szWinDir, szCourse, "StudentMgt", szText );

	  if ( szText != "0" )
	  then
	    GetProfString( szWinDir, szCourse, "UserPath", szLMPath );
	    SetInfoWindow( "Information", "file4.lis" );
	  else
	    szLMPath = szResultPath ^ "SKILLB";
	    SetInfoWindow( "Information", "file3.lis" );
	  endif;
	else
	  szLMPath = szResultPath ^ "SKILLB";
	  SetInfoWindow( "Information", "file3.lis" );
	endif;

	StrToUpper ( szLMPath, szLMPath );

	SetDialogTitle( DLG_ASK_PATH,  "Learner Management Path" );
	AskPath( "Enter a path for the Learner Management files:", szLMPath, szLMPath );
        if LAST_RESULT = FALSE
        then
	   call ConfirmCancel;
	   goto GetLMgt;
        endif;

	  StrSub(szWork, szLMPath,1,1);
	  if (szWork != ":")
	  then
// 	Invalid disk entered, reprompt.

	    szText = szLMPath;
	    szText = "You have entered an invalid path, Press OK to return to the path selection.";
	    MessageBox( szText, WARNING );
	    goto GetLMgt;
       	  endif;

	  StrLength(szLMPath);
	  nOffset = LAST_RESULT - 1;
	  if (nOffset > -1)
	  then
	    StrSub(szWork, szLMPath, nOffset, 1);
	    StrCompare( szWork, "\\" );
	    if LAST_RESULT = 0		// Trim the last backslash off
	    then
	      StrSub(szLMPath, szLMPath, 0, nOffset);
	    endif;
	  endif;	

//  Verifies that the user doesn't attempt to install on the source drive.

	GetDisk (szLMPath,szDisk);
	GetDisk (SRCDIR,szText);
       	StrCompare( szDisk, szText );
       	if LAST_RESULT = 0
       	then
	  MessageBox( "The Learner Management location must be different than the source.\nPlease specify a different location.",WARNING );
	  goto GetLMgt;
       	endif;

       	SetStatusWindow( 10, "Setting initial parameters." );
       
//	Checks if valid disk is entered.

       	ExistsDisk( szDisk );
       	if ( LAST_RESULT != EXISTS ) then

// 	Invalid disk entered, reprompt.

	  szText = szLMPath;
	  szText = szText + " - is an invalid path, Press OK to return to the path selection";
	  MessageBox( szText, WARNING );
	  goto GetLMgt;
       	endif;

	ExistsDir ( szLMPath );
	if ( LAST_RESULT != EXISTS )
	then
	  CreateDir ( szLMPath );

	  if ( LAST_RESULT != 0 )
	  then
	    szText = "Unable to create the directory for Learner Management at the specified path.  Press OK to re-enter another path.";
	    MessageBox( szText, WARNING );
	    goto GetLMgt;
	  endif;
	endif;
	return;
//--------------------------------------------------------------------
//        This procedure is called when the course to install
//        is already installed on the hard drive.
//--------------------------------------------------------------------

CoursePresent:


     	szText = "Course ";
       	szText = szText + szCourse;
       	szText = szText + " has already been installed.\n";
       	szText = szText + " Do you want to reinstall the course?";

	SetDialogTitle ( DLG_ASK_YESNO, "Reinstall Verification" );
       	AskYesNo( szText, YES );

       	if LAST_RESULT = YES
       	then
	  return;
       	endif;

       	goto ExitInstall;

//--------------------------------------------------------------------
//             This procedure calculates disk space for the course   -
//             and verifies that the destination drive has           -
//	       sufficient space to load the course.                  -  
//--------------------------------------------------------------------

EnoughSpace:
   // Calculate course disk space requirement

       	nSpace = nBaseSpace + nIconwareSpace + nWavSpace + nAudioSpace + n256space;

   //	If the course is already installed, checks to see if the current 
   //	installation path is the same as the previous path.  If the paths 
   //	are the same, the disk space check is not made.

	if ( nPresent = 1 )
	then
	  StrLength( szPath );
	  nOffset = LAST_RESULT - 1;
	  if (nOffset > -1)
	  then
	    StrSub(szWork, szLMPath, nOffset, 1);
	    StrCompare( szWork, "\\" );
	    if LAST_RESULT = 0		// Trim the last backslash off
	    then
	      StrSub( szPath, szPath, 0, nOffset );
	    endif;
	  endif;
	  if ( szPath = szResultPath )
	  then
	    return;
	  endif;
	endif;
 
   // Check to see if enough space is free on the destination.
   // GetDiskSpace returns free space in LAST_RESULT.

	GetDisk( szResultPath, szDisk );
	GetDiskSpace( szDisk );
       	nSpaceAvail = LAST_RESULT;
	nSpaceAvail = nSpaceAvail / 1000000;
	
       	if nSpace > nSpaceAvail
       	then
	    StrToUpper( szDisk, szDisk );
	    szText = "Not enough space on drive ";
	    szText = szText + szDisk;
	    szText = szText + " - Please press OK to try another target drive.";
	    SetDialogTitle ( DLG_MSG_WARNING, "Insufficient Disk Space" );
	    MessageBox (szText, WARNING);
	    SetDialogTitle ( DLG_MSG_WARNING, "Warning" );
	    goto GetTargetLoc;
       	endif;

	SetInfoWindow( "Information", "file5.lis" );
	NumToStr (szFile,nSpace);
	szText = "This course requires " + szFile;
	szText = szText + " Mb to install. \n The drive that you selected has ";
	NumToStr (szFile,nSpaceAvail);
	szText = szText + szFile;
	szText = szText + " Mb \n of available space.";
	SetDialogTitle ( DLG_MSG_INFORMATION, "Disk Space Requirements" );
	MessageBox (szText, INFORMATION);
	SetDialogTitle ( DLG_MSG_INFORMATION, "INFORMATION" );
	return;
//--------------------------------------------------------------------
//              This procedure sets the error message                -
//             Invalid INSTALL.INI file on hard drive                -
//--------------------------------------------------------------------
BadInstallINI:

       szText = "Error in INSTALL.INI file on disk.\n";
       goto ExitMessage;


//--------------------------------------------------------------------
//        This procedure will confirm with the users if they         -
//         want to terminate the installation of the course.         -
//--------------------------------------------------------------------
ConfirmCancel:

       AskYesNo( "Are you sure you want to CANCEL installation ?", YES );

       if LAST_RESULT = YES
       then
	  goto ExitInstall;           
       endif;

       return;

LoadDisk:

	if ( nStMgt = 1 ) then  
	  TARGETDIR = szLMPath;
	  if(FileCompare( "NE_USERS.FMT",
		          "NE_USERS.FMT", 
			  COMPARE_DATE ) != LESS_THAN) then
	    if(FileCompare( "NE_USERS.FMT",
		            "NE_USERS.FMT", 
			    COMPARE_DATE ) != EQUALS) then
	      CopyFile( "NE_USERS.FMT", "NE_USERS.FMT" );
	    endif;
	  endif;
	endif;

	FileSetBeginDefine ( "SBFileSet" );

	TARGETDIR = szResultPath ^ "SKILLB";
	if( CompressGet( "COURSE.Z", "", INCLUDE_SUBDIR ) <0) then
	  call CopyError;
	endif;

	
	FileSetEndDefine ( "SBFileSet" );

//  Decompressing/Copying files to target directory
//  Show the % Complete Status Bar

	Enable ( STATUS );
	Enable ( FEEDBACK_FULL );
	SetStatusWindow(9, "Installing course files.");
	StatusUpdate( 9, 96 );

// Initialize variables

	nDisk = 1;
	bDone = FALSE;
	szFileBase="COURSE.";

// Perform FileSet

	while ( !bDone )
	  nResult = FileSetPerform ( "SBFileSet", nDisk);
	  switch ( nResult )
	  case FS_TONEXTDISK:
	    szTagFile = szFileBase;
	    NumToStr(szExt, nDisk );
	    szTagFile = szTagFile + szExt;
	    szText = "Please insert diskette #" + szExt;
	    MessageBeep (0);
	    EnterDisk (szText, szTagFile );
	    if LAST_RESULT = CANCEL then
	      call ConfirmCancel;
	      EnterDisk (szText, szTagFile );
	      if LAST_RESULT = CANCEL then
	        call ExitInstall;
	      endif;
	    endif;
	  case FS_DONE:
	    // Files transferred successfully
	    bDone = TRUE;
	  case FS_GENERROR:
	    MessageBox( "An unknown error has occurred.", SEVERE );
	  case FS_OPERROR:
	    MessageBox( "An error has occurred in the file copying process.", SEVERE );
	    bDone = TRUE;
	  case FS_INCORRECTDISK:
	    MessageBox( "Please insert the disk requested.", SEVERE );
	    bDone = TRUE;
	  case FS_OUTOFSPACE:
	    MessageBox( "Please make sure that there is enough space on the target drive.", SEVERE );
	    bDone = TRUE;
	  default:
		SprintfBox(SEVERE, "", "Result:%ld", nResult);    
	  endswitch;
	endwhile;

	return;


//--------------------------------------------------------------------
//            This procedure installs decompresses and copies        -
//                   files from the source CD drive.                 -
//--------------------------------------------------------------------

LoadCD:
// ----------------------------------------------------------------------
//	If single-user version (network=no), checks WIN.INI file for NETG
//	sounds and adds sounds with default settings if they do not exist.
//	If sounds exist, does nothing.
// ----------------------------------------------------------------------

	if ( szNetwork = "no" ) then
	
	  szWinINI = WINDIR ^ "WIN.INI";
	  GetProfString( szWinINI, "Sounds", "NETGRewind", szText );

	  if ( szText = "" ) then

	    WriteProfString (szWinINI, "Sounds", "NETGRewind",   TARGETDIR^"NE_back.wav,NETG Rewind" );
	    WriteProfString (szWinINI, "Sounds", "NETGForward",  TARGETDIR^"NE_click.wav,NETG Page Forward" );
	    WriteProfString (szWinINI, "Sounds", "NETGFForward", TARGETDIR^"NE_next.wav,NETG Fast Forward" );
	    WriteProfString (szWinINI, "Sounds", "NETGMap",      TARGETDIR^"NE_map.wav,NETG Course Map" );
	    WriteProfString (szWinINI, "Sounds", "NETGExit",     TARGETDIR^"NE_exit.wav,NETG Exit" );
	  endif;
	  if( CompressGet( "MISC.Z", "", COMP_UPDATE_DATE_NEWER ) <0) then
	    call CopyError;
	  endif;
	endif;	

	
	SetStatusWindow(9, "Installing course files.");
	StatusUpdate( 9, 97 );

	if( CompressGet( "COURSE.Z", "", INCLUDE_SUBDIR ) <0) then
	  call CopyError;
	endif;


   //--------------------------------------------------------------------
   //  Loads Learner Management file only when Learner Management is ON and
   //  the file either doesn't exist in the designated directory or on older 
   //  copy of the file exists.
   //--------------------------------------------------------------------

	if ( nStMgt = 1 ) then  
	  TARGETDIR = szLMPath;
	  if(FileCompare( "NE_USERS.FMT",
		          "NE_USERS.FMT", 
			  COMPARE_DATE ) != LESS_THAN) then
	    if(FileCompare( "NE_USERS.FMT",
		            "NE_USERS.FMT", 
			    COMPARE_DATE ) != EQUALS) then
	      CopyFile( "NE_USERS.FMT", "NE_USERS.FMT" );
	    endif;
	  endif;
	endif;
	return;

//--------------------------------------------------------------------
//            This procedure creates the NETG Skill Builder          -
//                 program group and icon for windows.               -
//--------------------------------------------------------------------
Complete:

	SetStatusWindow( 97, "Initializing Program Group & Icon.");


//  Write out path and command line to run course from icon

	szCommand = szCoursePath;
	szCommand = szCommand ^ "PRESENT";
	szWork = szCommand;			// Define working directory.
	szCommand = szCommand ^ "PRESENT";
	szCommand = szCommand + " ";
	szPath = szCoursePath;
	szPath = szPath ^ "ICONWARE";
	szPath = szPath ^ szCourse;
	szPath = szPath + ".IW";
	szCommand = szCommand + szPath;  

// 	Write out path to course icon file.

	szPath = szCoursePath ^ "PRESENT"; 
	szPath = szPath ^ szIconFile;

//------------------------------------------------------------------------
//    Create batch file for VSI Menu install (Must be at least v1.45)    -
//------------------------------------------------------------------------

       SetStatusWindow(  97, "Creating VSI Install Files.");
       szIVIPath = "WIN ";
       szIVIPath = szIVIPath + szCommand; 
       szFile = szCourse;
       szFile = szFile + ".BAT";
       GetDisk( szWinDir, szText );
       szText = szText + "\\";
       CreateFile( nHan, szText, szFile );
       WriteLine( nHan, szIVIPath );

//------------------------------------------------------------------------
//    Create Program Group and Program Item.			 	 -
//------------------------------------------------------------------------

       SetStatusWindow(  99, "Creating Program Group & Icon.");

       szPgrp = "NETG SB Courseware";
       AddProgItemEx( szPgrp, szIconTag, szCommand, szWork, szPath, 0, "", REPLACE );
       if LAST_RESULT < 0
       then
	  szText = "Error creating course icon.\n";
	  MessageBox( szText, WARNING );
       endif;


   //	Updates CDF file with course specific information including a
   //	command line for executing the course, working directory for the
   //	the course, 

	szFile = szCoursePath ^ szCourse;
	szFile = szFile + ".CDF";


	WriteProfString( szFile, "RUNTIME INFO", "EXEC", szCommand );
	WriteProfString( szFile, "RUNTIME INFO", "WORKDIR", szWork );
	WriteProfString( szFile, "COURSE INFO", "NAME", szCourseName );
	WriteProfString( szFile, "COURSE INFO", "COURSEID", szCourseID );
	WriteProfString( szFile, "COURSE INFO", "AWARE", "1" );

	szText = "00000000;" + szCourseName;
	szText = szText + " OVERALL SCORE;3";
	WriteProfString( szFile, "SCORING ELEMENTS", "COMP", szText );




// ----------------------------------------------------------------------
//	Copies the course WS.INI file to course sub directory and updates 
//	the lines with install specific data for multiuser courses and 
//	modifies course VAR file so the movie doesn't play.
// ----------------------------------------------------------------------
//******
	if szNetwork = "yes" then

	  szFile = szResultPath ^ "SKILLB\\WS\\WS.INI";
	  WriteProfString( szFile, szCourse, "icon", szIconTag );
	  WriteProfString( szFile, szCourse, "iconfile", szIconFile );	  
	  WriteProfString( szFile, szCourse, "version", szVersion );

	endif; 
       MessageBox( "Installation complete.\nPress OK to exit.", INFORMATION );

       return;

//--------------------------------------------------------------------
//          This procedure will display an error when Install        -
//               is unable to decompress or copy a file.             -
//--------------------------------------------------------------------
CopyError:

       szErrMsg = "Unable to copy or decompress file: ";
       szErrMsg = szErrMsg + szErrFile;
       MessageBox( szErrMsg, SEVERE );

       return;

//--------------------------------------------------------------------
//              This procedure will Put an exit message              -
//              to the screen and exit install program               -
//--------------------------------------------------------------------

ExitMessage:

       StrConcat( szText , "Press OK to exit from install.");
       MessageBox( szText, SEVERE );

       goto ExitInstall;


//---------------------------------------------------------------------
//                      Exit Install Program                          -
//---------------------------------------------------------------------

ExitInstall:

       exit;

//-------------------- End of Install Program -------------------------

// ----------------------------------------------------------------------
//  Copyright © 1994, National Education Training Group, Inc.		-
//  All rights reserved.						-
//-----------------------------------------------------------------------
