home *** CD-ROM | disk | FTP | other *** search
Wrap
'$DEFINE DEBUG ''Define for script development/debugging '$INCLUDE 'setupapi.inc' '$INCLUDE 'msdetect.inc' ''Dialog ID's CONST WELCOME = 100 CONST ASKQUIT = 200 CONST DESTPATH = 300 CONST EXITFAILURE = 400 CONST EXITQUIT = 600 CONST EXITSUCCESS = 700 CONST APPHELP = 900 CONST OVERWRITE = 1800 CONST CUSTINST = 6200 CONST TOOBIG = 6300 CONST BADPATH = 6400 ''Bitmap ID CONST LOGO = 1 ''File Types CONST PROGFILE = 1 CONST CONFIGS = 2 CONST TEMPLATE = 3 CONST SAMPLES = 4 CONST FITFUNC = 5 CONST INIFILE = 6 CONST HLPFILE = 7 CONST DIMENS3 = 8 CONST NUMTYPES = 8 GLOBAL DEST$ GLOBAL SDEST$ GLOBAL FDEST$ GLOBAL BDEST$ GLOBAL WINDRIVE$ ''Windows drive letter. GLOBAL OPT1OPT$ ''Option selection from OptFiles1 option dialog. GLOBAL OPT2OPT$ ''Option selection from OptFiles2 option dialog. ''CustInst list symbol names GLOBAL PROGNEEDS$ GLOBAL CONFNEEDS$ GLOBAL TEMPNEEDS$ GLOBAL SAMPNEEDS$ GLOBAL HLPNEEDS$ GLOBAL ININEEDS$ GLOBAL FITNEEDS$ GLOBAL DIM3NEEDS$ GLOBAL EXTRACOSTS$ ''List of extra costs to add per drive GLOBAL BIGLIST$ ''List of option files cost calc results (boolean) ''Dialog list symbol names GLOBAL CHECKSTATES$ GLOBAL STATUSTEXT$ GLOBAL DRIVETEXT$ DECLARE SUB AddOptFilesToCopyList (ftype%) DECLARE SUB RecalcOptFiles (ftype%) DECLARE SUB RecalcPath DECLARE SUB SetDriveStatus DECLARE FUNCTION MakePath (szDir$, szFile$) AS STRING INIT: CUIDLL$ = "orgsetup.dll" ''custom user interface dll HELPPROC$ = "FHelpDlgProc" ''Help dialog procedure SetTitle "MicroCal Origin Installation" szInf$ = GetSymbolValue("STF_SRCINFPATH") IF szInf$ = "" THEN szInf$ = GetSymbolValue("STF_CWDDIR") + "ORIGIN.INF" END IF ReadInfFile szInf$ WINDRIVE$ = MID$(GetWindowsDir, 1, 1) SYSDEST$ = GetWindowsSysDir() DEST$ = WINDRIVE$ + ":\ORIGIN\" SDEST$ = DEST$ + "SAMPLES\" FDEST$ = DEST$ + "FITFUNC\" BDEST$ = DEST$ + "BUTTONS\" ''CustInst list symbols CHECKSTATES$ = "CheckItemsState" STATUSTEXT$ = "StatusItemsText" DRIVETEXT$ = "DriveStatusText" FOR i% = 1 TO NUMTYPES STEP 1 AddListItem CHECKSTATES$, "ON" NEXT i% FOR i% = 1 TO NUMTYPES STEP 1 AddListItem STATUSTEXT$, "" NEXT i% FOR i% = 1 TO NUMTYPES STEP 1 AddListItem DRIVETEXT$, "" NEXT i% ReplaceListItem DRIVETEXT$, 7, DEST$ ''Disk cost list symbols PROGNEEDS$ = "ProgNeeds" CONFNEEDS$ = "ConfNeeds" TEMPNEEDS$ = "TempNeeds" SAMPNEEDS$ = "SampNeeds" HLPNEEDS$ = "HlpNeeds" ININEEDS$ = "IniNeeds" FITNEEDS$ = "FitNeeds" DIM3NEEDS$ = "Dim3Needs" EXTRACOSTS$ = "ExtraCosts" BIGLIST$ = "BigList" FOR i% = 1 TO NUMTYPES STEP 1 AddListItem BIGLIST$, "" NEXT i% FOR i% = 1 TO 26 STEP 1 AddListItem EXTRACOSTS$, "0" NEXT i% ''File Option Variables for 3D OPT1OPT$ = "1" RecalcPath SetDriveStatus '$IFDEF DEBUG i% = SetSizeCheckMode(scmOnIgnore) '' could use scmOff; def = scmOnFatal '$ENDIF ''DEBUG WELCOME: sz$ = UIStartDlg(CUIDLL$, WELCOME, "FInfoDlgProc", APPHELP, HELPPROC$) IF sz$ = "CONTINUE" THEN UIPop 1 ELSE GOSUB ASKQUIT GOTO WELCOME END IF GETPATH: SetSymbolValue "EditTextIn", DEST$ SetSymbolValue "EditFocus", "END" GETPATHL1: sz$ = UIStartDlg(CUIDLL$, DESTPATH, "FEditDlgProc", APPHELP, HELPPROC$) IF sz$ = "BACK" THEN '**Custom install. olddest$ = DEST$ DEST$ = GetSymbolValue("EditTextOut") ''Validate new path. IF IsDirWritable(DEST$) = 0 THEN GOSUB BADPATH GOTO GETPATHL1 END IF UIPop 1 ''Truncate display if too long. IF LEN(DEST$) > 23 THEN ReplaceListItem DRIVETEXT$, 7, MID$(DEST$, 1, 23)+"..." ELSE ReplaceListItem DRIVETEXT$, 7, DEST$ END IF IF IsDirWritable(DEST$+"\") = 0 THEN ELSE DEST$ = DEST$ + "\" END IF SDEST$ = DEST$ + "SAMPLES\" FDEST$ = DEST$ + "FITFUNC\" BDEST$ = DEST$ + "BUTTONS\" ''Recalc if path changed. IF (olddest$ <> DEST$) AND (olddest$ <> DEST$+"\") AND (olddest$+"\" <> DEST$) THEN RecalcPath SetDriveStatus END IF olddest$ = "" GOSUB OVERWR GOTO CUSTINST ELSEIF sz$ = "CONTINUE" THEN '** Default installation olddest$ = DEST$ DEST$ = GetSymbolValue("EditTextOut") ''Validate new path. IF IsDirWritable(DEST$) = 0 THEN GOSUB BADPATH GOTO GETPATHL1 END IF UIPop 1 ''Truncate display if too long. IF LEN(DEST$) > 23 THEN ReplaceListItem DRIVETEXT$, 7, MID$(DEST$, 1, 23)+"..." ELSE ReplaceListItem DRIVETEXT$, 7, DEST$ END IF IF IsDirWritable(DEST$+"\") = 0 THEN ELSE DEST$ = DEST$ + "\" END IF SDEST$ = DEST$ + "SAMPLES\" FDEST$ = DEST$ + "FITFUNC\" BDEST$ = DEST$ + "BUTTONS\" ''Recalc if path changed. IF (olddest$ <> DEST$) AND (olddest$ <> DEST$+"\") AND (olddest$+"\" <> DEST$) THEN RecalcPath SetDriveStatus END IF olddest$ = "" GOSUB OVERWR FOR i% = 1 TO NUMTYPES STEP 1 IF GetListItem(BIGLIST$, i%) <> "" THEN GOSUB TOOBIG GOTO GETPATH END IF NEXT i% GOTO INSTALL ELSEIF sz$ = "REACTIVATE" THEN RecalcPath SetDriveStatus GOTO GETPATHL1 ELSEIF sz$ = "EXIT" THEN GOSUB ASKQUIT GOTO GETPATHL1 END IF CUSTINST: sz$ = UIStartDlg(CUIDLL$, CUSTINST, "FCustInstDlgProc", APPHELP, HELPPROC$) IF sz$ = "CONTINUE" THEN ''Install only if it will fit. FOR i% = 1 TO NUMTYPES STEP 1 IF GetListItem(BIGLIST$, i%) <> "" THEN GOSUB TOOBIG GOTO CUSTINST END IF NEXT i% UIPop 1 GOTO INSTALL ELSEIF sz$ = "CHK1" THEN RecalcOptFiles PROGFILE SetDriveStatus GOTO CUSTINST ELSEIF sz$ = "CHK2" THEN RecalcOptFiles CONFIGS SetDriveStatus GOTO CUSTINST ELSEIF sz$ = "CHK3" THEN RecalcOptFiles TEMPLATE SetDriveStatus GOTO CUSTINST ELSEIF sz$ = "CHK4" THEN RecalcOptFiles SAMPLES SetDriveStatus GOTO CUSTINST ELSEIF sz$ = "CHK5" THEN RecalcOptFiles FITFUNC SetDriveStatus GOTO CUSTINST ELSEIF sz$ = "CHK6" THEN RecalcOptFiles INIFILE SetDriveStatus GOTO CUSTINST ELSEIF sz$ = "CHK7" THEN RecalcOptFiles HLPFILE SetDriveStatus GOTO CUSTINST ELSEIF sz$ = "CHK8" THEN RecalcOptFiles DIMENS3 SetDriveStatus GOTO CUSTINST ELSEIF sz$ = "BTN1" THEN GOTO CUSTINST '**HELP ELSEIF sz$ = "BTN2" THEN GOTO CUSTINST '**HELP ELSEIF sz$ = "BTN3" THEN GOTO CUSTINST '**HELP ELSEIF sz$ = "BTN4" THEN GOTO CUSTINST '**HELP ELSEIF sz$ = "BTN5" THEN GOTO CUSTINST '**HELP ELSEIF sz$ = "BTN6" THEN GOTO CUSTINST '**HELP ELSEIF sz$ = "BTN7" THEN GOTO CUSTINST '**HELP ELSEIF sz$ = "BTN8" THEN GOTO CUSTINST '**HELP ELSEIF sz$ = "BTN9" THEN GOTO CUSTINST '**HELP ELSEIF sz$ = "REACTIVATE" THEN RecalcPath SetDriveStatus GOTO CUSTINST ELSEIF sz$ = "BACK" THEN UIPop 1 GOTO GETPATH ELSE GOSUB ASKQUIT GOTO CUSTINST END IF INSTALL: ClearCopyList SrcDir$ = GetSymbolValue("STF_SRCDIR") IF GetListItem(CHECKSTATES$, PROGFILE) = "ON" THEN AddSectionFilesToCopyList "PROGFILE", SrcDir$, DEST$ END IF IF GetListItem(CHECKSTATES$, CONFIGS) = "ON" THEN AddSectionFilesToCopyList "CONFIGS", SrcDir$, DEST$ END IF IF GetListItem(CHECKSTATES$, TEMPLATE) = "ON" THEN AddSectionFilesToCopyList "TEMPLATE1", SrcDir$, DEST$ AddSectionFilesToCopyList "TEMPLATE2", SrcDir$, BDEST$ END IF IF GetListItem(CHECKSTATES$, SAMPLES) = "ON" THEN AddSectionFilesToCopyList "SAMPLES", SrcDir$, SDEST$ END IF IF GetListItem(CHECKSTATES$, FITFUNC) = "ON" THEN AddSectionFilesToCopyList "FITFUNC", SrcDir$, FDEST$ END IF IF GetListItem(CHECKSTATES$, INIFILE) = "ON" THEN AddSectionFilesToCopyList "INIFILE", SrcDir$, DEST$ END IF IF GetListItem(CHECKSTATES$, HLPFILE) = "ON" THEN AddSectionFilesToCopyList "HLPFILE", SrcDir$, DEST$ END IF IF GetWindowsMinorVersion() = 0 THEN AddSectionFilesToCopyList "WIN30", SrcDir$, SYSDEST$ ENDIF CreateDir DEST$, cmoNone CreateDir SDEST$, cmoNone CreateDir FDEST$, cmoNone CreateDir BDEST$, cmoNone CopyFilesInCopyList D3: IF GetListItem(CHECKSTATES$, DIMENS3) = "ON" THEN szText$="If your package includes the optional 3D/Contour module,please insert the disk into drive: "+GetSymbolValue("STF_SRCDIR")+". Otherwise press cancel to skip this optional installation." i%=DoMsgBox(szText$,"Origin",1) IF i%=1 THEN IF GetSizeOfFile(SrcDir$+"3D.ID") = 0 THEN GOTO D3 ELSE CursorSave% = ShowWaitCursor() szFulPath$=SrcDir$ CopyFile szFulPath$+"lab3d.dll", DEST$+"lab3d.dll",cmoNone,0 CopyFile szFulPath$+"labcolor.dll",DEST$+"labcolor.dll",cmoNone,0 CopyFile szFulPath$+"mesh.otp",DEST$+"mesh.otp",cmoNone,0 CopyFile szFulPath$+"xconst.otp",DEST$+"xconst.otp",cmoNone,0 CopyFile szFulPath$+"yconst.otp",DEST$+"yconst.otp",cmoNone,0 CopyFile szFulPath$+"wirefrm.otp",DEST$+"wirefrm.otp",cmoNone,0 CopyFile szFulPath$+"wireface.otp",DEST$+"wireface.otp",cmoNone,0 CopyFile szFulPath$+"cmap.otp",DEST$+"cmap.otp",cmoNone,0 CopyFile szFulPath$+"3d.otp",DEST$+"3d.otp",cmoNone,0 CopyFile szFulPath$+"Traject.otp",DEST$+"Traject.otp",cmoNone,0 CopyFile szFulPath$+"bar3d.otp",DEST$+"bar3d.otp",cmoNone,0 CopyFile szFulPath$+"ribbon.otp",DEST$+"RIBBON.OTP",cmoNone,0 CopyFile szFulPath$+"walls.otp",DEST$+"walls.otp",cmoNone,0 CopyFile szFulPath$+"water3d.otp",DEST$+"water3d.otp",cmoNone,0 CopyFile szFulPath$+"3d.cnf",DEST$+"3D.CNF",cmoNone,0 CopyFile szFulPath$+"lab3d.hlp",DEST$+"lab3d.hlp",cmoNone,0 CopyFile szFulPath$+"labmatrx.dll",DEST$+"labmatrx.dll",cmoNone,0 CopyFile szFulPath$+"mathgrid.dll",DEST$+"mathgrid.dll",cmoNone,0 CopyFile szFulPath$+"matrix.cnf",DEST$+"matrix.cnf",cmoNone,0 CopyFile szFulPath$+"contour.dll",DEST$+"contour.dll",cmoNone,0 CopyFile szFulPath$+"contour.otp",DEST$+"contour.otp",cmoNone,0 CopyFile szFulPath$+"contgray.otp",DEST$+"contgray.otp",cmoNone,0 CopyFile szFulPath$+"contline.otp",DEST$+"contline.otp",cmoNone,0 CopyFile szFulPath$+"contour.cnf",DEST$+"contour.cnf",cmoNone,0 RestoreCursor CursorSave% ENDIF ELSE OPT1OPT$="0" '' szStr$="Call MicroCal today to get the 3D application." '' j%=DoMsgBox(szStr$,"ORIGIN",0) ENDIF END IF CreateProgmanGroup "MicroCal Origin", "", cmoOverwrite ShowProgmanGroup "MicroCal Origin", 1, cmoNone CreateProgmanItem "MicroCal Origin ", "Origin 3.0", MakePath(DEST$,"origin.exe"), "", cmoOverwrite IF (OPT1OPT$ = "1") THEN CreateProgmanItem "MicroCal Origin", "3D+CONTOUR 3.0", MakePath(DEST$,"origin.exe -a 3D -a contour"), "", cmoOverwrite ENDIF AddDos5Help "YOURAPP", "A brief help text for your Windows application."+chr$(10)+"It can be continued on another line with chr$(10).", cmoNone QUIT: ON ERROR GOTO ERRQUIT IF ERR = 0 THEN dlg% = EXITSUCCESS ELSEIF ERR = STFQUIT THEN dlg% = EXITQUIT ELSE dlg% = EXITFAILURE END IF QUITL1: sz$ = UIStartDlg(CUIDLL$, dlg%, "FInfo0DlgProc", 0, "") IF sz$ = "REACTIVATE" THEN GOTO QUITL1 END IF UIPop 1 END ERRQUIT: i% = DoMsgBox("Setup sources were corrupted!", "Installation Message", MB_OK+MB_TASKMODAL+MB_ICONHAND) END TOOBIG: sz$ = UIStartDlg(CUIDLL$, TOOBIG, "FInfo0DlgProc", 0, "") IF sz$ = "REACTIVATE" THEN RecalcPath SetDriveStatus GOTO TOOBIG END IF UIPop 1 RETURN BADPATH: sz$ = UIStartDlg(CUIDLL$, BADPATH, "FInfo0DlgProc", 0, "") IF sz$ = "REACTIVATE" THEN RecalcPath SetDriveStatus GOTO BADPATH END IF UIPop 1 RETURN OVERWR: IF GetSizeOfFile(DEST$+"ORIGIN.EXE") = 0 THEN ELSE sz$ = UIStartDlg(CUIDLL$, OVERWRITE, "FInfoDlgProc", APPHELP, HELPPROC$) IF sz$ = "EXIT" THEN UIPopAll ERROR STFQUIT ELSEIF sz$ = "CONTINUE" THEN UIPop 1 ELSEIF sz$ = "BACK" THEN UIPop 1 GOTO GETPATH ELSE GOSUB ASKQUIT GOTO OVERWR END IF ENDIF RETURN ASKQUIT: sz$ = UIStartDlg(CUIDLL$, ASKQUIT, "FQuitDlgProc", 0, "") IF sz$ = "EXIT" THEN UIPopAll ERROR STFQUIT ELSEIF sz$ = "REACTIVATE" THEN GOTO ASKQUIT ELSE UIPop 1 END IF RETURN SUB AddOptFilesToCopyList (ftype%) STATIC IF GetListItem(CHECKSTATES$, ftype%) = "ON" THEN SrcDir$ = GetSymbolValue("STF_SRCDIR") IF ftype% = PROGFILE THEN AddSectionFilesToCopyList "PROGFILE", SrcDir$, DEST$ '** AddSectionFilesToCopyList "COMMDLG", SrcDir$, DEST$ ELSEIF ftype% = CONFIGS THEN AddSectionFilesToCopyList "CONFIGS", SrcDir$, DEST$ ELSEIF ftype% = TEMPLATE THEN AddSectionFilesToCopyList "TEMPLATE1", SrcDir$, DEST$ AddSectionFilesToCopyList "TEMPLATE2", SrcDir$, BDEST$ ELSEIF ftype% = SAMPLES THEN AddSectionFilesToCopyList "SAMPLES", SrcDir$, SDEST$ ELSEIF ftype% = FITFUNC THEN AddSectionFilesToCopyList "FITFUNC", SrcDir$, FDEST$ ELSEIF ftype% = INIFILE THEN AddSectionFilesToCopyList "INIFILE", SrcDir$, DEST$ ELSEIF ftype% = HLPFILE THEN AddSectionFilesToCopyList "HLPFILE", SrcDir$, DEST$ ELSEIF ftype% = DIMENS3 THEN AddSectionFilesToCopyList "3DIMENS", SrcDir$, DEST$ AddSectionFilesToCopyList "CONTOUR", SrcDir$, DEST$ END IF SrcDir$ = "" END IF END SUB SUB RecalcOptFiles (ftype%) STATIC CursorSave% = ShowWaitCursor() ClearCopyList AddOptFilesToCopyList ftype% fExtra% = 0 IF ftype% = PROGFILE THEN ListSym$ = PROGNEEDS$ IF GetListItem(CHECKSTATES$, PROGFILE) = "ON" THEN ''Add extra cost to Windows drive for ini/progman, etc. ndrive% = ASC(ucase$(WINDRIVE$)) - ASC("A") + 1 ReplaceListItem EXTRACOSTS$, ndrive%, "20480" fExtra% = 1 END IF ELSEIF ftype% = CONFIGS THEN ListSym$ = CONFNEEDS$ ELSEIF ftype% = TEMPLATE THEN ListSym$ = TEMPNEEDS$ ELSEIF ftype% = SAMPLES THEN ListSym$ = SAMPNEEDS$ ELSEIF ftype% = FITFUNC THEN ListSym$ = FITNEEDS$ ELSEIF ftype% = INIFILE THEN ListSym$ = ININEEDS$ ELSEIF ftype% = HLPFILE THEN ListSym$ = HLPNEEDS$ ELSEIF ftype% = DIMENS3 THEN ListSym$ = DIM3NEEDS$ END IF StillNeed& = GetCopyListCost(EXTRACOSTS$, ListSym$, "") cost& = 0 FOR i% = 1 TO 26 STEP 1 cost& = cost& + VAL(GetListItem(ListSym$, i%)) NEXT i% ReplaceListItem STATUSTEXT$, ftype%, STR$(cost& / 1024) + " K" IF StillNeed& > 0 THEN ReplaceListItem BIGLIST$, ftype%, "YES" ELSE ReplaceListItem BIGLIST$, ftype%, "" END IF IF fExtra% THEN ReplaceListItem EXTRACOSTS$, ndrive%, "0" END IF RestoreCursor CursorSave% ListSym$ = "" END SUB SUB RecalcPath STATIC CursorSave% = ShowWaitCursor() RecalcOptFiles PROGFILE RecalcOptFiles CONFIGS RecalcOptFiles TEMPLATE RecalcOptFiles SAMPLES RecalcOptFiles FITFUNC RecalcOptFiles INIFILE RecalcOptFiles HLPFILE RecalcOptFiles DIMENS3 RestoreCursor CursorSave% END SUB SUB SetDriveStatus STATIC drive$ = MID$(DEST$, 1, 1) ndrive% = ASC(ucase$(drive$)) - ASC("A") + 1 cost& = VAL(GetListItem(PROGNEEDS$, ndrive%)) + VAL(GetListItem(CONFNEEDS$, ndrive%)) + VAL(GetListItem(TEMPNEEDS$, ndrive%)) cost& = cost& + VAL(GetListItem(SAMPNEEDS$, ndrive%)) + VAL(GetListItem(ININEEDS$, ndrive%)) + VAL(GetListItem(HLPNEEDS$, ndrive%)) cost& = cost& + VAL(GetListItem(FITNEEDS$, ndrive%))+VAL(GetListItem(DIM3NEEDS$, ndrive%)) free& = GetFreeSpaceForDrive(drive$) ReplaceListItem DRIVETEXT$, 1, drive$ + ":" ReplaceListItem DRIVETEXT$, 2, STR$(cost& / 1024) + " K" ReplaceListItem DRIVETEXT$, 3, STR$(free& / 1024) + " K" IF free& < cost& THEN FOR i% = 1 TO NUMTYPES STEP 1 ReplaceListItem BIGLIST$, i%, "YES" NEXT i% END IF IF drive$ = WINDRIVE$ THEN ReplaceListItem DRIVETEXT$, 4, "" ReplaceListItem DRIVETEXT$, 5, "" ReplaceListItem DRIVETEXT$, 6, "" ELSE ndrive% = ASC(ucase$(WINDRIVE$)) - ASC("A") + 1 cost& = VAL(GetListItem(PROGNEEDS$, ndrive%)) + VAL(GetListItem(CONFNEEDS$, ndrive%)) + VAL(GetListItem(TEMPNEEDS$, ndrive%)) cost& = cost& + VAL(GetListItem(SAMPNEEDS$, ndrive%)) + VAL(GetListItem(ININEEDS$, ndrive%)) + VAL(GetListItem(HLPNEEDS$, ndrive%)) cost& = cost& + VAL(GetListItem(FITNEEDS$, ndrive%))+VAL(GetListItem(DIM3NEEDS$, ndrive%)) IF cost& = 0 THEN ReplaceListItem DRIVETEXT$, 4, "" ReplaceListItem DRIVETEXT$, 5, "" ReplaceListItem DRIVETEXT$, 6, "" ELSE free& = GetFreeSpaceForDrive(WINDRIVE$) ReplaceListItem DRIVETEXT$, 4, WINDRIVE$ + ":" ReplaceListItem DRIVETEXT$, 5, STR$(cost& / 1024) + " K" ReplaceListItem DRIVETEXT$, 6, STR$(free& / 1024) + " K" END IF END IF END SUB FUNCTION MakePath (szDir$, szFile$) STATIC AS STRING IF szDir$ = "" THEN MakePath = szFile$ ELSEIF szFile$ = "" THEN MakePath = szDir$ ELSEIF MID$(szDir$, LEN(szDir$), 1) = "\" THEN MakePath = szDir$ + szFile$ ELSE MakePath = szDir$ + "\" + szFile$ END IF END FUNCTION