//$LNK res "c:\windows\gfawin\install\install.res"
$DESCR DataBasics Installer
OPENW #1,0,0,_X,_Y,16+64+32
TITLEW #1,"DataBasics Installation Utility V1.0"
FONT "MS Sans Serif",HEIGHT 16,WIDTH 0,WEIGHT FW_NORMAL
FONT ORIENTATION 0,ESCAPEMENT 0,ITALIC 0,STRIKEOUT 0,UNDERLINE 0
FONT QUALITY 0,FAMILY FF_ROMAN,PITCH VARIABLE_PITCH,CHARSET ANSI_CHARSET
FONT TO fntMSans&
GRAPHMODE ,OPAQUE
t1$ = "Initialising Setup Please Wait..."
DIALOG #0,(_X-300)/2,170,280,50,"",$80400002,-15,"MS Sans Serif"
  CONTROL t1$,100,"static",$10000001,2,12,270,50
ENDDIALOG
DLG FILL 0,RGB(192,192,192)
SHOWDIALOG #0
FOR n% = 1 TO 100
  PEEKEVENT
NEXT n%
color%=SYSCOL(2)
DIM filename$(300),filesize%(300),filedir$(300)
DLG FILL 0,RGB(192,192,192)
OPTION BASE 1
windir$ = @getwindir$
@Sys_Info
a& = 1
@Call_Screen(a&)
CLOSEDIALOG #0
WIN #1
FOR n%= 1 TO 100
  PEEKEVENT
NEXT n%
@redrawscreen(TRUE)
@Dir_Dialog_From
IF e1| = 1
  IF EXIST(currentdir$+"setup.ini")
    @Read_Ini
  ELSE
    ALERT 1,"SETUP.INI File Not Found.|Unable to Continue.",1,"E&xit",k&
    CLOSEW #1
    END
  ENDIF
ELSE
  CLOSEW #1
  END
ENDIF
IF wver >= VAL(winversion$)
  @Dir_Dialog_To
  IF e| = 1
    @Check_Disk_Space
    @Test_Install_Dir
    FOR i& = 1 TO dnum&
      @Test_Sub_Dir
    NEXT i&
    IF NOT EXIST(LEFT$(installdirto$,3)+"DB LOCK.INF")
      OPEN "o",#1,LEFT$(installdirto$,3)+"DB LOCK.INF"
      FOR n = 1 TO 1000+RND(500)
        x=RND(255)
        OUT #1,x
      NEXT n
      CLOSE #1
    ENDIF
    @Install_Files
    IF auto$ = "AUTOEXEC = YES" THEN @Change_Autoexec
    IF conf$ = "CONFIG = YES" THEN @Change_Config
    IF wini$ = "WIN INI = YES" THEN @Change_Win
    IF oth$ = "OTHER = YES" THEN @Change_Other
    @End_Main
    @init_dde
    create_group(groupname$,"")
    show_group (groupname$,1)
    FOR z& = 1 TO itemnum&
      IF LEN(itemname$(z&)) > 1
        IF LEFT$(copydir$(z&),1)="\"
          add_item (LEFT$(installdirto$,2)+copydir$(z&)+iteminstall$(z&),itemname$(z&),"",0,0,0,"","",0)
        ELSE
          add_item (installdirto$+"\"+copydir$(z&)+iteminstall$(z&),itemname$(z&),"",0,0,0,"","",0)
        ENDIF
      ENDIF
    NEXT z&
    exit_progman ("0")
    @kill_dde
  ENDIF
ELSE
  ALERT 1,"Unable to Install to this|Version of Windows....",1,"&Close",a&
ENDIF
a& = 2
@Call_Screen(a&)
CLOSEW #1
> PROCEDURE Call_Screen(VAR a&)
  IF a& = 1
    grad&=LOADBMP(currentdir$+"grad.rle")
    logo& = LOADBMP(currentdir$+"vga.rle")
  ENDIF
  IF a& = 2
    FREEBMP logo&
    FREEBMP grad&
  ENDIF
RETURN
> PROCEDURE getnextdialog(filename$)
  LOCAL text$,found!,file$
  file$=installdirfrom$+"dialog.txt"
  IF EXIST(file$)
    OPEN "i",#4,file$
    REPEAT
      LINE INPUT #4,text$
      IF LEFT$(text$,1)="#" AND TRIM$(MID$(text$,2))=UPPER$(TRIM$(filename$))
        found!=TRUE
        IF message$<>"" THEN
          @infodialog(FALSE)
          message$=""
        ENDIF
        REPEAT
          LINE INPUT #4,text$
          IF LEFT$(text$,1)<>"#"
            message$=message$+text$
          ENDIF
        UNTIL LEFT$(text$,1)="#" OR EOF(#4)=TRUE
        @infodialog(TRUE)
        WIN #2
      ENDIF
    UNTIL EOF(#4)=TRUE OR found!=TRUE
    CLOSE #4
  ENDIF
RETURN
> PROCEDURE drawmeter
  COLOR 0,247
  DRAW 378,21 TO 378,99 TO 21,99
  DRAW 21,153 TO 21,119 TO 379,119
  DRAW 21,100 TO 21,21 TO 379,21
  COLOR 255,0
  DRAW 379,119 TO 379,153 TO 21,153
  BOX 22,22,379,100
  COLOR 0,7
  TEXT 150,3,"Copying Files"
  RGBCOLOR color%,RGB(192,192,192)
  FOR n%=3 TO 0 STEP -1
    BOX 0+n%,0+n%,397-n%,171-n%
  NEXT n%
  TEXT 25,23,"From:"
  TEXT 25,62,"To:"
RETURN
> PROCEDURE metertext
  COLOR 7,7
  TEXT 25, 42,UPPER$(oldfrom$)
  TEXT 25, 81,UPPER$(oldto$)
  COLOR 0,7
  TEXT 25, 42,UPPER$(from$)
  TEXT 25, 81,UPPER$(to$)
  oldfrom$=from$
  oldto$=to$
RETURN
> PROCEDURE Meter(percent&)
  WIN #2
  IF percent& <=100
    COLOR 0,247
    offset& = (358 * percent&)/100 + 20
    IF offset& > 20
      RGBCOLOR color%
      PBOX 20,119,offset&,153
      COLOR 255,0
      DRAW 19,119 TO offset&,119
      COLOR 0,247
      DRAW offset&,119 TO offset&,153
      DRAW 19,153 TO offset&,153
    ENDIF
    TEXT 200-TXTLEN(STR$(percent&)+"%")/2,102,STR$(percent&)+"%"
  ENDIF
RETURN
> PROCEDURE Sys_Info
  DLL #1,"kernel.dll" //windir$+"\system\KERNEL.dll"
    DECL DWORD GetHeapSpaces(w)
  ENDDLL
  currentdir$ = @getdir$          // current logged directory
  sysdir$ = @getsysdir$           // Windows System directory
  wver = @getwinver               // Windows version number
  cpu = @getcpu                   // CPU type
  math$ = @getmathchip$()         // Co-processor
  FREEDLL 1
RETURN
> FUNCTION getdir$()
  ~INTR($21,_AH=$19)
  drive$ = CHR$(65 + _AL)
  drive& = _AL + 65
  buffer$=SPACE$(65)
  _DL=ASC(drive$) & 31
  _DS=SWAP(V:buffer$)
  _SI=V:buffer$
  ~INTR($21,_AH=$47)
  currentdir$ = drive$+":\"+CHAR{V:buffer$}
  RETURN "a:\"
  //RETURN currentdir$
ENDFUNC

> FUNCTION getwindir$()
  buff$=SPACE$(255)
  tchars& = GetWindowsDirectory(V:buff$,255)
  windir$ = LEFT$(buff$,tchars&)
  RETURN windir$
ENDFUNC

> FUNCTION getsysdir$()
  buff$ = SPACE$(255)
  tchars& = GetSystemDirectory(V:buff$,255)
  sysdir$ = LEFT$(buff$,tchars&)
  RETURN sysdir$
ENDFUNC

> FUNCTION getwinver()
  version& = GetVersion()
  wver = ((version& MOD 256) * 100) + version& \ 256
  RETURN wver
ENDFUNC

> FUNCTION getcpu()
  flags% = GetWinFlags()
  match& = 1
  IF (flags% AND WF_CPU486) \ WF_CPU486 THEN
    cpu& = 486
  ELSE IF (flags% AND WF_CPU386) \ WF_CPU386
    cpu& = 386
  ELSE
    cpu& = 286
  ENDIF
  RETURN cpu&
ENDFUNC
> PROCEDURE redrawscreen(logo!)
  WIN #1
  PUT 0,0,grad&
  IF logo!
    PUT 105,70,logo&
  ENDIF
RETURN
> FUNCTION getmathchip$()
  flags% = GetWinFlags()
  IF flags% AND WF_80x87 THEN
    math$ = "YES"
  ELSE
    math$ = "NO"
  ENDIF
  RETURN math$
ENDFUNC
> PROCEDURE infodialog(open!)
  IF open!
    DIALOG #5,105,90,425,130,"",$80400002,-15,"MS Sans Serif"
      CONTROL "",100,"static",$10000000,50,10,350,130
      CONTROL "",104,"static",$10000007,5,5,405,110
      CONTROL "",105,"static",$10000009,6,6,405,110
      ICON "#1",2,10,10,1,1,SS_ICON
    ENDDIALOG
    DLG FILL 5,RGB(192,192,192)
    _WIN$(DLGITEM(5,100))=message$
    SHOWDIALOG #5
    FOR n%=1 TO 50
      PEEKEVENT
    NEXT n%
    WIN #2
    @drawmeter
    @Meter(percent&)
  ELSE
    CLOSEDIALOG #5
  ENDIF
RETURN
> PROCEDURE Dir_Dialog_To
  DISABLEW 1
  DIALOG #0,(_X-348)/2,260,348,150,"",$90400002,-15,"MS Sans Serif"
    CONTROL "Copy To What Directory?",100,"static",$10000000,20,30,250,20
    CONTROL "",101,"edit",$10810088,20,50,300,25
    CONTROL "&Continue",102,"button",$10010001,20,90,140,30
    CONTROL "E&xit",103,"button",$50000000,180,90,140,30
    CONTROL "",104,"static",$10000007,10,20,320,60
    CONTROL "",105,"static",$10000009,11,21,320,60
  ENDDIALOG
  SHOWDIALOG #0
  _WIN$(DLGITEM(0,101)) = "C:\"+defaultdir$
  ~SetFocus(DLGITEM(0,101))
  DO
    SLEEP
    IF MENU(1)=21
      @redrawscreen(TRUE)
    ENDIF
    SELECT MENU(6)
    CASE 102
      installdirto$ = _WIN$(DLGITEM(0,101))
      e| = 1
    CASE 103
      e| = 2
    ENDSELECT
    IF MENU(11) = WM_KEYDOWN
      SELECT MENU(12)
      CASE VK_RETURN
        installdirto$ = _WIN$(DLGITEM(0,101))
        e| = 1
      CASE VK_ESCAPE
        e| = 2
      ENDSELECT
    ENDIF
    EXIT IF e| > 0
  LOOP
  ENABLEW 1
  CLOSEDIALOG #0
  PEEKEVENT
  @redrawscreen(FALSE)
RETURN
> PROCEDURE Dir_Dialog_From
  DISABLEW 1
  DIALOG #0,(_X-348)/2,260,348,150,"",$90400002,-15,"MS Sans Serif"
    CONTROL "Copy From Where ?",100,"static",$10000000,20,30,250,20
    CONTROL "",101,"edit",$10810088,20,50,300,25
    CONTROL "&Continue",102,"button",$10010001,20,90,140,30
    CONTROL "E&xit",103,"button",$50000000,180,90,140,30
    CONTROL "",104,"static",$10000007,10,20,320,60
    CONTROL "",105,"static",$10000009,11,21,320,60
  ENDDIALOG
  SHOWDIALOG #0
  _WIN$(DLGITEM(0,101)) = currentdir$
  ~SetFocus(DLGITEM(0,101))
  DO
    SLEEP
    IF MENU(1) = 21
      @redrawscreen(TRUE)
    ENDIF
    SELECT MENU(6)
    CASE 102
      installdirfrom$ = _WIN$(DLGITEM(0,101))
      e1| = 1
    CASE 103
      e1| = 2
    ENDSELECT
    IF MENU(11) = WM_KEYDOWN
      SELECT MENU(12)
      CASE VK_RETURN
        installdirfrom$ = _WIN$(DLGITEM(0,101))
        e1| = 1
      CASE VK_ESCAPE
        e1| = 2
      ENDSELECT
    ENDIF
    EXIT IF e1| > 0
  LOOP
  ENABLEW 1
  CLOSEDIALOG #0
  FOR n%= 1 TO 50
    PEEKEVENT
  NEXT n%
  @redrawscreen(TRUE)
RETURN
> PROCEDURE Test_Install_Dir
  TRY
    MKDIR installdirto$
  CATCH
  SELECT ERR
  CASE -13
    //    RMDIR installdirto$
  ENDSELECT
RETURN
> PROCEDURE Test_Sub_Dir
  TRY
    IF LEFT$(dname$(i&),1)="\" THEN
      MKDIR LEFT$(installdirto$,2)+dname$(i&)
    ELSE
      MKDIR installdirto$+"\"+dname$(i&)
    ENDIF
  CATCH
  SELECT ERR
  CASE -13
    //RMDIR installdirto$
  ENDSELECT
RETURN
> PROCEDURE Install_Files
  DLL #1,"lzexpand.dll" // currentdir$+"lzexpand.dll"
    DECL LONG LZCopy(w,w)
  ENDDLL
  IF math$ = "YES" THEN testsystem$ = STR$(cpu&)+"MATH"
  IF math$ = "NO" THEN testsystem$ = STR$(cpu&)+"N/A"
  percent& = 0
  OPENW #2,118,255,400,174,0
  SETFONT fntMSans&
  COLOR 7
  DEFFILL 0
  CLS 7
  FOR currentdisk& = 1 TO disk&
    PEEKEVENT
    @Read_Info
    IF MENU(1)=21 THEN
      @redrawscreen(FALSE)
      @Meter(percent&)
    ENDIF
    @drawmeter
    @Meter(percent&)
    @Read_INF
    FOR i& = 1 TO filecount& - 1
      IF type$(i&) = testsystem$ || type$(i&) = "N/A"
        @Copy_File
        percent& = percent& + INT((size% / VAL(dspace$))*100)
        @Meter(percent&)
      ENDIF
    NEXT i&
  NEXT currentdisk&
  percent& = 100
  @Meter(percent&)
  PAUSE 20
  IF message$<>""
    @infodialog(FALSE)
  ENDIF
  FREEDLL 1
  CLOSEW #2
  FOR n%=1 TO 100
    PEEKEVENT
  NEXT n%
  @redrawscreen(TRUE)
RETURN
> PROCEDURE Copy_File
  from$ = UCASE$(installdirfrom$+filename$(i&))
  IF LEFT$(filedir$(i&),1)="\" THEN
    to$ = UCASE$(LEFT$(installdirto$,2)+filedir$(i&)+filename$(i&))
  ELSE
    to$ = UCASE$(installdirto$+"\"+filedir$(i&)+filename$(i&))
  ENDIF
  @getnextdialog(filename$(i&))
  @metertext
  IF NOT EXIST(from$) THEN
    ALERT 1,"ERROR !! Cannot Locate|Source File :|"+MID$(from$,RINSTR(from$,"\",LEN(from$)-1)+1)+"|File Will Be Skipped...",1," OK ",a
  ELSE
    OPEN "i",#1,from$
    OPEN "o",#2,to$
    size%=LOF(#1)
    a%=^LZCopy(_FILE(1),_FILE(2))
    CLOSE #1
    CLOSE #2
  ENDIF
RETURN
> PROCEDURE init_dde
  init_cons()
  ~SendMessage(-1,WM_DDE_INITIATE,w&,MAKELONG(app&,topic&))
  maxwait&=2000
  FOR x&=1 TO maxwait&
    PEEKEVENT
  NEXT x&
  serverw&=pm_hdl&
  ~SendMessage(-1,WM_DDE_ADVISE,w&,MAKELONG(item&,hopt&))
  wait_ack()
RETURN
> PROCEDURE init_cons()
  a$="Program Manager"+CHR$(0)
  pm_hdl&=FindWindow(0,V:a$)
  w&=WIN(1)
  a$="PROGMAN"+CHR$(0)
  t$="PROGMAN"+CHR$(0)
  item$=""
  app&=GlobalAddAtom(a$)
  topic&=GlobalAddAtom(t$)
  item&=GlobalAddAtom(item$)
  IF app&=0 OR topic&=0
    alert()
  ENDIF
RETURN
> PROCEDURE kill_cons()
  ~GlobalAddAtom(app&)
  topic&=GlobalAddAtom(topic&)
  item&=GlobalAddAtom(item&)
RETURN
> PROCEDURE alert
  ALERT 1,"No Server|",1,"Cancel",a&
  CLOSEW #1
  END
RETURN
> PROCEDURE wait_ack()
  i& = 0
  DO
    PEEKEVENT
    INC i&
  LOOP UNTIL MENU(11) = WM_DDE_ACK OR i& > maxwait&
  IF i& => maxwait&
    alert()
  ENDIF
RETURN
> PROCEDURE create_group(gname$,gpath$)
  itemalloc& = GlobalAlloc(GMEM_DDESHARE,100)
  item% = GlobalLock(itemalloc&)
  IF gname$ = ""
    ALERT 1,"CreateGroup ERROR|Bad GroupName",1,"OOPS!!!",alert|
  ELSE
    IF gpath$ <> ""
      gpath$ = ","+gpath$
    ENDIF
    group$ = "[CreateGroup("+gname$+gpath$+")]"+CHR$(0)
    POKE$ item%,group$
    ~PostMessage(serverw&,WM_DDE_EXECUTE,w&,MAKELONG(itemalloc&,0))
    wait_ack()
  ENDIF
  ~GlobalUnlock(itemalloc&)
  ~GlobalFree(itemalloc&)
RETURN
> PROCEDURE delete_group(gname$)
  itemalloc& = GlobalAlloc(GMEM_DDESHARE,100)
  item% = GlobalLock(itemalloc&)
  IF gname$ = ""
    ALERT 1,"DeleteGroup ERROR|Bad GroupName",1,"OOPS!!!",alert|
  ELSE
    group$ = "[DeleteGroup("+gname$+")]"+CHR$(0)
    POKE$ item%,group$
    ~PostMessage (serverw&,WM_DDE_EXECUTE,w&,MAKELONG(itemalloc&,0))
    wait_ack()
  ENDIF
  ~GlobalUnlock(itemalloc&)
  ~GlobalFree(itemalloc&)
RETURN
> PROCEDURE show_group(gname$,cmd%)
  itemalloc& = GlobalAlloc(GMEM_DDESHARE,100)
  item% = GlobalLock(itemalloc&)
  IF cmd% > 8 OR cmd% < 1
    ALERT 1,"ShowGroup ERROR|Bad Command Number",1,"OOPS!!!",alert|
  ELSE
    IF gname$ = ""
      ALERT 1,"ShowGroup ERROR|Bad GroupName",1,"OOPS!!!",alert|
    ELSE
      group$ = "[ShowGroup("+gname$+","+STR$(cmd%)+")]"+CHR$(0)
      POKE$ item%,group$
      ~PostMessage (serverw&,WM_DDE_EXECUTE,w&,MAKELONG(itemalloc&,1))
      wait_ack()
    ENDIF
  ENDIF
  ~GlobalUnlock(itemalloc&)
  ~GlobalFree(itemalloc&)
RETURN
> PROCEDURE add_item(cmd_line$,iname$,ipath$,iindex%,xpos%,ypos%,def_dir$,hotkey$,minimize%)
  itemalloc&=GlobalAlloc(GMEM_DDESHARE,100)
  item%=GlobalLock(itemalloc&)
  IF cmd_line$=""
    ALERT 1,"add_item error|bad command line",1,"ooops",alert|
  ELSE
    IF iname$=""
      ipath$=""
      iindex$=""
      xpos$=""
      ypos$=""
      def_dir$=""
      hotkey$=""
      minimize$=""
    ELSE IF ipath$=""
      iname$=","+iname$
      iindex$=""
      xpos$=""
      ypos$=""
      def_dir$=""
      hotkey$=""
      minimize$=""
    ELSE IF xpos%<=0
      iname$=","+iname$
      ipath$=","+ipath$
      ypos$=""
      def_dir$=""
      hotkey$=""
      minimize$=""
    ELSE IF ypos%<=0
      iname$=","+iname$
      ipath$=","+ipath$
      xpos$=","+STR$(xpos%)
      def_dir$=""
      hoykey$=""
      minimize$=""
    ELSE IF def_dir$=""
      iname$=","+iname$
      ipath$=","+ipath$
      xpos$=","+STR$(xpos%)
      ypos$=","+STR$(ypos%)
      hoykey$=""
      minimize$=""
    ELSE IF hotkey$=""
      iname$=","+iname$
      ipath$=","+ipath$
      xpos$=","+STR$(xpos%)
      ypos$=","+STR$(ypos%)
      def_dir$=","+def_dir$
      minimize$=""
    ELSE IF MINimize$=""
      iname$=","+iname$
      ipath$=","+ipath$
      xpos$=","+STR$(xpos%)
      ypos$=","+STR$(ypos%)
      def_dir$=","+def_dir$
      hotkey$=","+hotkey$
    ELSE
      iname$=","+iname$
      ipath$=","+ipath$
      xpos$=","+STR$(xpos%)
      ypos$=","+STR$(ypos%)
      def_dir$=","+def_dir$
      hotkey$=","+hotkey$
      minimize$=","+MINimize$
    ENDIF
    item$="[AddItem("+cmd_line$+iname$+ipath$+iindex$+xpos$+ypos$+def_dir$+hotkey$+MINimize$+")]"+CHR$(0)
    POKE$ item%,item$
    ~PostMessage(serverw&,WM_DDE_EXECUTE,w&,MAKELONG(itemalloc&,0))
    wait_ack()
  ENDIF
  ~GlobalUnlock(itemalloc&)
  ~GlobalFree(itemalloc&)
RETURN
> PROCEDURE exit_progman(gname$)
  itemalloc& = GlobalAlloc(GMEM_DDESHARE,100)
  item% = GlobalLock(itemalloc&)
  IF gname$ = ""
    ALERT 1,"ExitProgman ERROR|Bad GroupName",1,"oops!!",alert|
  ELSE
    group$ = "[ExitProgman("+gname$+")]"+CHR$(0)
    ~PostMessage(serverw&,WM_DDE_EXECUTE,w&,MAKELONG(itemalloc&,0))
    wait_ack()
  ENDIF
  ~GlobalUnlock(itemalloc&)
  ~GlobalFree(itemalloc&)
  WIN #1
  PUT 0,0,grad&
RETURN
> PROCEDURE kill_dde
  ~PostMessage(serverw&,WM_DDE_UNADVISE,w&,0)
  ~PostMessage(serverw&,WM_DDE_TERMINATE,w&,0)
  wait_ack()
  @kill_cons()
RETURN
> PROCEDURE End_Main
  DISABLEW 1
  IF LEN(exit_string$)<2
    exit_string$ = "Please Take A Few Minutes to Read The Manual and send in the Registration Card."
  ENDIF
  t1$ = "Hotel Perfect was sucessfully installed. Install will now Open an Application Window in the Program Manager."
  DIALOG #0,(_X-348)/2,260,348,200,"",$90400002
    CONTROL t1$,100,"static",$10000001,30,10,270,90
    CONTROL exit_string$,101,"static",$10000001,20,95,290,80
    CONTROL "E&xit",102,"button",$10000000,110,155,100,30
  ENDDIALOG
  ~SetFocus(DLGITEM(0,102))
  SHOWDIALOG #1
  REPEAT
    PEEKEVENT
  UNTIL MENU(0)=102
  CLOSEDIALOG #0
RETURN
> PROCEDURE Read_Ini
  OPEN "i",#1,currentdir$+"setup.ini"
  INPUT #1,defaultdir$
  INPUT #1,dnum&
  IF dnum& > 0
    DIM dname$(dnum&)
    FOR i& = 1 TO dnum&
      INPUT #1,dname$(i&)
    NEXT i&
  ENDIF
  INPUT #1,itemnum&
  DIM itemdir$(itemnum&),iteminstall$(itemnum&),itemname$(itemnum&),type$(itemnum&),copydir$(itemnum&)
  FOR i& = 1 TO itemnum&
    INPUT #1,iteminstall$(i&)
    INPUT #1,itemname$(i&)
    INPUT #1,type$(i&)
    INPUT #1,itemdir$(i&)
    INPUT #1,copydir$(i&)
    IF copydir$(i&) = "DEFAULT" THEN copydir$(i&) = ""
    IF copydir$(i&) <> "" THEN copydir$(i&) = copydir$(i&)+"\"
  NEXT i&
  INPUT #1,groupname$
  INPUT #1,dspace$
  INPUT #1,winversion$
  INPUT #1,disk&
  INPUT #1,exit_string$
  INPUT #1,auto$
  INPUT #1,conf$
  INPUT #1,wini$
  INPUT #1,oth$
  CLOSE #1
  dspace$=STR$(VAL(dspace$)-150000)
RETURN
> PROCEDURE Check_Disk_Space
  installdrive = ASC(LEFT$(installdirto$,1))-64
  IF DFREE(installdrive) < VAL(dspace$)
    ALERT 1,"Insuffisent Disk Space to copy|you need at least "+dspace$+" bytes free",1,"Close",a&
    CLOSEW #1
    END
  ENDIF
RETURN
> PROCEDURE Read_Info
  IF EXIST(currentdir$+"info.fil")
    DO
      PEEKEVENT
      OPEN "i",#1,currentdir$+"info.fil"
      INPUT #1,disk&
      disk& = VAL(LEFT$(STR$(disk&),1))
      CLOSE #1
      IF disk& <> currentdisk&
        //MESSAGE "Insert disk "+STR$(currentdisk&)+" in Disk Drive","Disk Change",MB_RETRYCANCEL|MB_TASKMODAL,n&
        ALERT 3,"Please Insert disk "+STR$(currentdisk&)+"|in Disk Drive "+UPPER$(LEFT$(currentdir$,2)),1," OK |Cancel",n&
      ENDIF
    LOOP UNTIL disk& = currentdisk& || n& = IDCANCEL
    IF message$<>"" THEN
      ENABLEW DLG(5)
      ~SetFocus(DLG(5))
    ENDIF
    IF n& = IDCANCEL
      CLOSEW #2
      CLOSEW #1
      END
    ENDIF
  ELSE
    DO
      MESSAGE "INFO.FIL Was Not Found! Cannot Continue.","File Not Found !",MB_RETRYCANCEL|MB_SYSTEMMODAL,n&
    LOOP UNTIL n& = IDCANCEL
    CLOSEW #1
    END
  ENDIF
RETURN
> PROCEDURE Read_INF
  IF EXIST(currentdir$+"file.inf")
    OPEN "i",#1,currentdir$+"file.inf"
    filecount&=1
    DO
      INPUT #1,filename$(filecount&)
      INPUT #1,filesize%(filecount&)
      INPUT #1,filedir$(filecount&)
      IF filedir$(filecount&) = "DEFAULT" THEN filedir$(filecount&) = ""
      IF filedir$(filecount&) <> "" THEN filedir$(filecount&) = filedir$(filecount&)+"\"
      filecount&++
      EXIT IF filecount& > 299
    LOOP UNTIL EOF(#1)
    CLOSE #1
  ELSE
    DO
      MESSAGE "FILE.INF Was Not Found! Cannot Continue.","File not Found",MB_RETRYCANCEL|MB_SYSTEMMODAL,n&
    LOOP UNTIL n& = IDCANCEL
    CLOSEW #1
  ENDIF
RETURN
> PROCEDURE Change_Autoexec
  MESSAGE "Installer Must Make Changes To Your AUTOEXEC.BAT File.","AUTOEXEC.BAT CHANGE",MB_YESNOCANCEL|MB_TASKMODAL,n&
  IF n& = IDCANCEL
    CLOSEW #1
    END
  ENDIF
  IF n& = IDYES
    install_drive$ = LEFT$(installdirto$,1)
    OPEN "a",#2,install_drive$ + ":\autoexec.bat"
    OPEN "i",#1,currentdir$+"setup.ini"
    autoexec$ = ""
    DO
      LINE INPUT #1,junk$
    LOOP UNTIL junk$ = "[AUTOEXEC]"
    DO
      LINE INPUT #1,junk$
      EXIT IF junk$ = "[CONFIG]"
      PRINT #2,junk$
    LOOP
    CLOSE #1
    CLOSE #2
  ENDIF
RETURN
> PROCEDURE Change_Config
  MESSAGE "Installer must make changes to your Config.sys file.","Config.sys Change",MB_YESNOCANCEL|MB_TASKMODAL,n&
  IF n& = IDCANCEL
    CLOSEW #1
    END
  ENDIF
  IF n& = IDYES
    install_drive$ = LEFT$(installdirto$,1)
    OPEN "a",#2,install_drive$ + ":\config.sys"
    OPEN "i",#1,currentdir$+"setup.ini"
    config$ = ""
    DO
      LINE INPUT #1,junk$
    LOOP UNTIL junk$ = "[CONFIG]"
    DO
      LINE INPUT #1,junk$
      EXIT IF junk$ = "[WIN INI]"
      PRINT #2,junk$
    LOOP
    CLOSE #1
    CLOSE #2
  ENDIF
RETURN
> PROCEDURE Change_Win
  MESSAGE "Installer must make changes to your Win.ini file.","Win.ini Change",MB_YESNOCANCEL|MB_TASKMODAL,n&
  IF n& = IDCANCEL
    CLOSEW #1
    END
  ENDIF
  IF n& = IDYES
    OPEN "a",#2,windir$+"\win.ini"
    OPEN "i",#1,currentdir$+"setup.ini"
    win_ini$ = ""
    DO
      LINE INPUT #1,junk$
    LOOP UNTIL junk$ = "[WIN INI]"
    PRINT #2,""
    DO
      LINE INPUT #1,junk$
      EXIT IF junk$ = "[OTHER]"
      PRINT #2,junk$
    LOOP
    CLOSE #1
    CLOSE #2
  ENDIF
RETURN
> PROCEDURE Change_Other
  OPEN "i",#1,currentdir$+"setup.ini"
  change_other$ = ""
  change_other_name$ = ""
  DO
    LINE INPUT #1,junk$
  LOOP UNTIL junk$ = "[OTHER]"
  INPUT #1,change_other_name$
  MESSAGE "Installer must make changes to your "+change_other_name$+" file.",change_other_name$+" Change",MB_YESNOCANCEL|MB_TASKMODAL,n&
  IF n& = IDCANCEL
    CLOSEW #1
    END
  ENDIF
  IF n& = IDYES
    //    IF EXIST(installdirto$+"\"+change_other_name$)
    //    OPEN "a",#2,installdirto$+"\"+change_other_name$
    //  ELSE
    OPEN "o",#2,installdirto$+"\"+change_other_name$
    //  ENDIF
    DO
      LINE INPUT #1,junk$
      PRINT #2,junk$
    LOOP UNTIL EOF(#1)
    CLOSE #2
  ENDIF
  CLOSE #1
RETURN
