'************************************************************************
'*
'*  SNA Server 2.11 Win16 Client setup script
'*
'*  For use with the Microsoft Setup Toolkit, Windows 3.1 SDK version.
'*
'************************************************************************

'$define DEBUG

'$include 'setupapi.inc'
'$include 'msdetect.inc'

const IDOK      = 1
const IDCANCEL  = 2
const IDABORT   = 3
const IDRETRY   = 4
const IDIGNORE  = 5
const IDYES     = 6
const IDNO      = 7

const MBOK      = 0
const MBOKC     = 1
const MBARI     = 2
const MBYNC     = 3
const MBYN      = 4
const MBRC      = 5
const MISTOP    = 16
const MIQUEST   = 32
const MIEXCL    = 48
const MIINFO    = 64
const MBTASK    = 8192

const SUOK           = 7500
const SUNOMEM        = 7502
const SULANMANINI    = 7511
const SULANMANVER    = 7512
const SUWINVER       = 7514
const SUBADLANMANINI = 7523
const SUBADWININI    = 7524
const SUOPENREADERR  = 7525
const SUOPENWRITEERR = 7526

const TIBACKUPEXT     = 1
const TIHOMEDIR       = 2
const TIREMSRV1       = 3
const TIREMSRV2       = 4
const TIFILEERROR     = 5
const TINOSTYPE       = 6
const TINOSVERSION    = 7
const TINOSLANMAN     = 8
const TINOSLANSERVER  = 9
const TINOSWFW        = 10
const TINOSNOVELL     = 11
const TINOSBANYAN     = 12
const TINOSTCP        = 13
const TINETWAREDOMAIN = 14
const TISOURCEDIR     = 15
const TISTGROUP       = 16
const TINOSNB         = 17

const NOSLANMAN  = 1
const NOSWFW     = 2
const NOSNOVELL  = 3
const NOSBANYAN  = 4
const NOSTCP     = 5
const NOSNB      = 6


''Dialog ID's
const WELCOME        = 100
const WELCOMEA       = 101
const WELCOMEN       = 102
const ASKQUIT        = 200
const EXITQUIT       = 600
const APPHELP        = 900
const SELHELP        = 910
const REMHELP        = 920
const SYSFILEOPT     = 1200
const CSPATH         = 1300
const CSPATHN        = 1301
const SELECTION      = 1400
const REMOTE         = 1600
const SUCCESSINSTALL = 1700
const SUCCESSREMOVE  = 2100
const CONFIRMREMOVE  = 1800
const BADPATH        = 6400
const BADNWDOMAIN    = 6410
const NOSTYPES       = 1500
const NOSHELP        = 1510
const NWDOMAIN       = 1520
const NWDOMAINHELP   = 1530
const STGROUP        = 1540
const STGROUPHELP    = 1545
const TCPLRSELECT    = 1550
const TCPREMOTE      = 1560
const TCPREMHELP     = 1565
const OPTIONFILES    = 1570
const OPTFILESHELP   = 1575


''Default install directory
const DEFDEST$ = "C:\SNA.WIN"

global DEST$        ''Default destination directory.
global OPTCUR$      ''Option selection from option dialog.
global USERFUNC$    ''Install, remove, or touch system files
global BADFILE$
global SNASRC$
global REMSRV1$
global REMSRV2$
global LOCREM$
global RC%
global RC2%
global ANS%
global dlg%
global ErrFlag%
global ETXT$
global ECAP$
global ESTYL%
global WINDIR$
global WINSYSDIR$
global Domain$
global STGroupName$
global TmpPath$
global TempDir$
global CURSOR%
global fInstall3270%
global fInstall5250%
global fInstallODBC%
global fNosLanman%
global fNosLanServer%
global fNosWFW%
global fNosNovell%
global fNosBanyan%
global fNosTCP%
global fNosNB%
global iSelect%
global iNosInUse%
global fFirstInstall%
global fCopySnaDlls%
global fCopyOtherFiles%
global fRemoveSnaDlls%
global fRemoveOtherFiles%
global fAdminInstall%
global fNetwkInstall%
global fInTcpRemote%
global IA%
global IB%
global LA%
global LB%

declare sub Install
declare sub Remove
declare sub ErrChk

declare function MakePath     ( szDir$, szFile$ ) as string
declare function NukeFilesInSection ( szSecName$, szDir$ ) as integer

declare function SNAValidate     lib "win16cl.dll" as integer
declare function SNAInstall      lib "win16cl.dll" as integer
declare function SNARemove       lib "win16cl.dll" as integer
declare function SNAGetString    lib "win16cl.dll" ( ident%, ST$, bytecnt% ) as integer
declare function SNAGetInt       lib "win16cl.dll" ( ident%, X as pointer to integer ) as integer
declare function SNASetString    lib "win16cl.dll" ( ident%, ST$ ) as integer
declare function SNASetInt       lib "win16cl.dll" ( ident%, X as pointer to integer ) as integer
declare function SNARmDir        lib "win16cl.dll" ( ST$ ) as integer
declare function SNAInstallODBC  lib "win16cl.dll" ( ST1$, ST2$, ST3$ ) as integer
declare function SNACreateFont   lib "win16cl.dll" ( i%, ST1$, ST2$, ST3$ ) as integer
declare function SNAValidSvr     lib "win16cl.dll" ( ST$, X as pointer to integer ) as integer
declare function SNAParseRemLine lib "win16cl.dll" ( ST$, W as pointer to integer, X as pointer to integer, Y as pointer to integer, Z as pointer to integer) as integer



Init:
    CUIDLL$   = "mscuistf.dll"          ''Custom user interface dll
    HELPPROC$ = "FHelpDlgProc"          ''Help dialog procedure

    SetBitmap CUIDLL$, 1
    SetTitle  "Microsoft SNA Server 2.11 -- Windows 3.x SNA Client Setup"

    szInf$ = GetSymbolValue( "STF_SRCINFPATH" )
    if szInf$ = "" then
      szInf$ = GetSymbolValue( "STF_CWDDIR" ) + "WIN16CL.INF"
    endif

    ReadInfFile szInf$

    OPTCUR$    = "1"
    i%         = SetSizeCheckMode( scmOff )
    ErrFlag%   = 0

    DEST$        = ""
    Domain$      = "DOMAIN"
    LOCREM$      = "LOCAL"
    REMSRV1$     = ""
    REMSRV2$     = ""
    SNASRC$      = GetSymbolValue( "STF_SRCDIR" )
    RC%          = SNASetString( TISOURCEDIR, SNASRC$ )

    ' STGroupName gets this default value because it causes enough
    ' space to be allocated in the string to hold the real group
    ' name that gets returned from our DLL through SNAGetString().

    STGroupName$ = "1234567890123456789012345678901234567890123456789012345678901234567890"

    WINDIR$    = GetWindowsDir()
    WINSYSDIR$ = GetWindowsSysDir()
    WINMAJVER% = GetWindowsMajorVersion()
    WINMINVER% = GetWindowsMinorVersion()

    TempDir$   = GetEnvVariableValue( "TMP" )
    if TempDir$ = "" then
      TempDir$ = "C:\"
    endif

    fFirstInstall%   = 1
    fCopySnaDlls%    = 1
    fCopyOtherFiles% = 1
    fInstallODBC%    = 1
    fInstall3270%    = 1
    fAdminInstall%   = 0
    fNetwkInstall%   = 0
    fInTcpRemote%    = 0

    if INSTR( Command$, "/A" ) >0 or INSTR( Command$, "/a" ) >0 then
      fAdminInstall% = 1
    endif
    if INSTR( Command$, "/N" ) >0 or INSTR( Command$, "/n" ) >0 then
      fNetwkInstall% = 1
    endif

    if WINMAJVER% < 3 then
      fInstall3270% = 0
    elseif WINMAJVER% = 3 then
      if WINMINVER% < 10 then
        fInstall3270% = 0
      endif
    endif
    fInstall5250% = fInstall3270%


Validate:
    RC% = SNAValidate

    ErrChk
    if ANS% <> IDIGNORE then
      if ANS% = IDRETRY then
        goto Validate
      endif
    endif

    TMPDEST$   = DEFDEST$
    iNosInUse% = 0

    RC% = SNAGetInt( TINOSLANMAN,    VARPTR( fNosLanman% ))
    RC% = SNAGetInt( TINOSLANSERVER, VARPTR( fNosLanServer% ))
    RC% = SNAGetInt( TINOSWFW,       VARPTR( fNosWFW% ))
    RC% = SNAGetInt( TINOSNOVELL,    VARPTR( fNosNovell% ))
    RC% = SNAGetInt( TINOSBANYAN,    VARPTR( fNosBanyan% ))
    RC% = SNAGetInt( TINOSTCP,       VARPTR( fNosTCP% ))
    RC% = SNAGetInt( TINOSNB,        VARPTR( fNosNB% ))

    iNosCount% = 0
    if fNosLanman% = 1 or fNosLanServer% = 1 then
      iNosCount% = iNosCount% + 1
    endif
    if fNosNovell% = 1 then
      iNosCount% = iNosCount% + 1
    endif
    if fNosBanyan% = 1 then
      iNosCount% = iNosCount% + 1
    endif
    if fNosTCP% = 1 then
      iNosCount% = iNosCount% + 1
    endif

    if iNosCount% > 0 then  '' set iNosInUse
      if fNosTCP% = 1 then
        iNosInUse% = NOSTCP
      elseif fNosWFW% = 1 then
        iNosInUse% = NOSWFW
      elseif fNosLanman% = 1 then
        iNosInUse% = NOSLANMAN
      elseif fNosLanServer% = 1 then
        iNosInUse% = NOSLANMAN
      elseif fNosNovell% = 1 then
        iNosInUse% = NOSNOVELL
      elseif fNosBanyan% = 1 then
        iNosInUse% = NOSBANYAN
      endif
    endif

    RC% = SNASetInt( TINOSTYPE, VARPTR( iNosInUse% ))

    if iNosInUse% = NOSTCP then
      LOCREM$ = "REMOTE"
    endif

    if fNosBanyan% = 1 then
      RC% = SNAGetString( TISTGROUP, STGroupName$, 63 )
      if STGroupName$ = "" then
        STGroupName$ = "group@org"
      endif
    endif

    '
    ' Pick up our settings in WIN.INI, if they exist.
    '
    if DoesIniSectionExist( "WIN.INI", "Wnap" ) = 1 then
      fFirstInstall% = 0

      if DoesIniKeyExist( "WIN.INI", "Wnap", "WBinPath" ) = 1 then
        TMPDEST$ = GetIniKeyString( "WIN.INI", "Wnap", "WBinPath" )

        if TMPDEST$ = "" then
          TMPDEST$ = DEFDEST$
        endif
      endif

      if DoesIniKeyExist( "WIN.INI", "Wnap", "StGroupName" ) = 1 then
        STGroupName$ = GetIniKeyString( "WIN.INI", "Wnap", "StGroupName" )
      endif

      if DoesIniKeyExist( "WIN.INI", "Wnap", "NosSetup" ) = 1 then
        TMPNOS$ = GetIniKeyString( "WIN.INI", "Wnap", "NosSetup" )
        if TMPNOS$ = "LANMAN" then
          iNosInUse% = NOSLANMAN
        elseif TMPNOS$ = "WFW" then
          iNosInUse% = NOSWFW
        elseif TMPNOS$ = "NOVELL" then
          iNosInUse% = NOSNOVELL
        elseif TMPNOS$ = "VINES" then
          iNosInUse% = NOSBANYAN
        elseif TMPNOS$ = "TCPIP" then
          iNosInUse% = NOSTCP
''--    elseif TMPNOS$ = "NETBIOS" then
''--    iNosInUse% = NOSNB
        endif
      endif

      RC% = SNASetInt( TINOSTYPE, VARPTR( iNosInUse% ))

      if DoesIniKeyExist( "WIN.INI", "Wnap", "NetSetup" ) = 1 then
         TMPNET$ = GetIniKeyString( "WIN.INI", "Wnap", "NetSetup" )
        if TMPNET$ = "YES" then
          fNetwkInstall% = 1
        else
          fNetwkInstall% = 0
        endif
      endif

      if DoesIniKeyExist( "WIN.INI", "Wnap", "LocalFlag" ) = 1 then
        Tmp$ = GetIniKeyString( "WIN.INI", "Wnap", "LocalFlag" )
        if Tmp$ = "LOCAL" or Tmp$ = "REMOTE" then
          LOCREM$ = Tmp$
        endif
      endif 

      if DoesIniKeyExist( "WIN.INI", "Wnap", "Remote" ) = 1 then
        RSRVSTR$ = GetIniKeyString( "WIN.INI", "Wnap", "Remote" )

        '' Separate RSRVSTR$ into REMSRV1$ and REMSRV2$
        if RSRVSTR$ <> "" then

          RSRVSTR$ = LTRIM$( RTRIM$( RSRVSTR$ ))
          if iNosInUse% <> NOSTCP then  '' allow lower-case w/TCP
            RSRVSTR$ = UCASE$( RSRVSTR$ )
          endif

          RC% = SNAParseRemLine( RSRVSTR$, VARPTR( IA% ), VARPTR( LA% ), VARPTR( IB% ), VARPTR( LB% ))

          REMSRV1$ = ""
          REMSRV2$ = ""

          if IA% > 0 then
            REMSRV1$ = MID$( RSRVSTR$, IA%, LA% )
          endif

          if IB% > 0 then
            REMSRV2$ = MID$( RSRVSTR$, IB%, LB% )
          endif

        endif  ''RSRVSTR$ <> ""
      endif  ''Key "Remote" exists
    endif  ''Section "Wnap" exists

    DEST$  = UCASE$( TMPDEST$ )
    RC% = SNASetString( TIHOMEDIR, DEST$ )
    RC% = SNAGetInt( TINOSTYPE, VARPTR( iNosInUse% ))

    if REMSRV1$ <> "" then
      if iNosInUse% = NOSNOVELL or iNosInUse% = NOSBANYAN then
        Domain$ = REMSRV1$
      else
        if iNosInUse% = NOSTCP and LOCREM$ = "LOCAL" then
          Domain$ = REMSRV1$
        endif
      endif
    endif

Welcome:
    if fAdminInstall% = 1 then
      dlg% = WELCOMEA
    elseif fNetwkInstall% = 1 then
      dlg% = WELCOMEN
    else
      dlg% = WELCOME
    endif

    sz$ = UIStartDlg( CUIDLL$, dlg%, "FInfoDlgProc", APPHELP, HELPPROC$ )

    if sz$ = "CONTINUE" then
      UIPop 1
    else
      gosub AskQuit
      goto Welcome
    endif

    if fFirstInstall% = 1 then
      goto PermCheck
    endif

SelectL:
    SetSymbolValue "EditTextIn", DEST$
    SetSymbolValue "RadioDefault", OPTCUR$

SelectL1:
    sz$ = UIStartDlg( CUIDLL$, SELECTION, "FSelectDlgProc", SELHELP, HELPPROC$ )
    OPTCUR$ = GetSymbolValue( "ButtonChecked" )

    if sz$ = "CONTINUE" then
      UIPop 1
    elseif sz$ = "REACTIVATE" then
      goto SelectL1
    else
      gosub AskQuit
      goto SelectL
    endif

    if OPTCUR$ = "1" then
      USERFUNC$ = "SYSFILES"
      goto NosTypes
    elseif OPTCUR$ = "2" then
      USERFUNC$ = "REMOVE"
      goto ConfirmRemove
    endif

PermCheck:
    if fFirstInstall% = 1 then
      if DoesFileExist( MakePath( SNASRC$, "WDMOD.DL$" ), femExists ) = 0 then
        if DoesFileExist( MakePath( SNASRC$, "WDMOD.DLL" ), femExists ) = 0 then
          i% = DoMsgBox( "For your initial SNA client installation, you must run Setup from floppy disk, or from the CLIENTS\Win3x share on a SNA server.", "Setup Message", MB_OK+MBTASK+MISTOP )
          ErrFlag% = 1
          goto Quit
        endif
      endif
    endif

    if IsWindowsShared() = 1 then
      if fAdminInstall% = 0 then
        if DoesFileExist( MakePath( WINSYSDIR$, "WDMOD.DLL" ), femExists ) = 1 then
          fCopySnaDlls% = 0
        else
          i% = DoMsgBox( "You must run SETUP /A as an administrative user so the SNA Client files can be copied to your shared Windows directory ("+WINSYSDIR$+").", "Setup Message", MB_OK+MBTASK+MISTOP )
          ErrFlag% = 1
          goto Quit
        endif
      else
        if IsDirWritable( WINSYSDIR$ ) = 0 then
          i% = DoMsgBox( "Setup needs to copy files into your shared Windows directory ( "+WINSYSDIR+" ), but you don't have permission.  Please log on as an administrative user and run Setup again.", "Setup Message", MB_OK+MBTASK+MISTOP )
          ErrFlag% = 1
          goto Quit
        endif
      endif
    endif

GetPath:
    SetSymbolValue "EditTextIn", DEST$
    SetSymbolValue "EditFocus", "END"
    SetSymbolValue "EditTextLim", "255"
    if fNetwkInstall% = 1 and fFirstInstall% = 1 then
      SetSymbolValue "EditTextIn", ""
    endif

GetPathL1:
    if fNetwkInstall% = 1 then
      dlg% = CSPATHN
    else
      dlg% = CSPATH
    endif
    sz$ = UIStartDlg( CUIDLL$, dlg%, "FEditDlgProc", APPHELP, HELPPROC$ )

    TmpPath$ = GetSymbolValue( "EditTextOut" )

    if sz$ = "CONTINUE" then
      if IsDriveValid(MID$(TmpPath$,1,1)) = 0 or MID$(TmpPath$,2,1) <> ":" or MID$(TmpPath$,3,1) <> "\" then
        gosub BadPath
        goto GetPathL1
      endif

      DEST$ = TmpPath$

      if IsDriveNetwork( MID$( DEST$, 1, 1 )) = 1 then

        if fNetwkInstall% = 1 then
          if DoesFileExist( MakePath( DEST$, "WNAP.EXE" ), femExists ) = 0 then
            i% = DoMsgBox( "Setup can't find the SNA files in "+DEST$+".  Press OK to try another path.", "Setup Message", MBOK+MBTASK+MISTOP )
            goto GetPathL1
          else
            fCopyOtherFiles% = 0
          endif
        else

          if fAdminInstall% = 0 then
            i% = DoMsgBox( "To install the SNA Client on a network drive, you must run SETUP /A.  Press OK to exit Setup, or Cancel to try another path.", "Setup Message", MBOKC+MBTASK+MISTOP )
            if i% = IDCANCEL then
              goto GetPathL1
            else
              ErrFlag% = 1
              goto Quit
            endif
          endif

          if IsDirWritable( DEST$ ) = 0 then
            i% = DoMsgBox( "You don't have permission to copy files to "+DEST$+".  Press OK to exit Setup, or Cancel to enter a different path.", "Setup Message", MBOKC+MBTASK+MISTOP )
            if i% = IDCANCEL then
              goto GetPathL1
            else
              ErrFlag% = 1
              goto Quit
            endif
          endif

        endif
      endif

      UIPop 1

    elseif sz$ = "REACTIVATE" then
      goto GetPathL1
    elseif sz$ = "BACK" then
      UIPop 1
      goto Welcome
    else
      gosub AskQuit
      goto GetPath
    endif

    RC% = SNASetString( TIHOMEDIR, DEST$ )

NosTypes:
    RC% = SNAGetInt( TINOSLANMAN,    VARPTR( fNosLanman% ))
    RC% = SNAGetInt( TINOSLANSERVER, VARPTR( fNosLanServer% ))
    RC% = SNAGetInt( TINOSWFW,       VARPTR( fNosWFW% ))
    RC% = SNAGetInt( TINOSNOVELL,    VARPTR( fNosNovell% ))
    RC% = SNAGetInt( TINOSBANYAN,    VARPTR( fNosBanyan% ))
    RC% = SNAGetInt( TINOSTCP,       VARPTR( fNosTCP% ))
    RC% = SNAGetInt( TINOSNB,        VARPTR( fNosNB% ))

    SetSymbolValue "OptionsGreyed", ""
    iNosCount% = 0

    if fNosLanman% = 1 or fNosLanServer = 1 then
        iNosCount% = iNosCount% + 1
    else
        AddListItem "OptionsGreyed", "1"
    endif

    if fNosNovell% = 1 then
        iNosCount% = iNosCount% + 1
    else
        AddListItem "OptionsGreyed", "2"
    endif

    if fNosBanyan% = 1 then
        iNosCount% = iNosCount% + 1
    else
        AddListItem "OptionsGreyed", "3"
    endif

    if fNosTCP% = 1 then
        iNosCount% = iNosCount% + 1
    else
        AddListItem "OptionsGreyed", "4"
    endif

''--if fNosNB% = 1 then
''--    iNosCount% = iNosCount% + 1
''--else
''--    AddListItem "OptionsGreyed", "5"
''--endif

    if iNosCount% = 0 then
      i% = DoMsgBox( "Setup is unable to detect any network on this computer.  Please install a network and try Setup again later.", "Setup Message", MB_OK+MBTASK+MISTOP )
      ErrFlag% = 1
      goto Quit
    endif

    '' Okay, at this point we have one or more NOSs installed.
    '' Only do this dialog if we have TWO or more!

    if iNosCount% < 2 then
      goto Remote
    endif

    '' Set up the dialog box... map NOS type to default
    '' radio button selection.

    RC% = SNAGetInt( TINOSTYPE, VARPTR( iSelect% ))
    if iSelect% = 2 then  ' WFW
        iSelect% = 1
    elseif iSelect% > 2 then
        iSelect% = iSelect% - 1
    endif
    SetSymbolValue "RadioDefault", STR$( iSelect% )

    '' Do the box...
NosTypesL1:
    sz$ = UIStartDlg( CUIDLL$, NOSTYPES, "FRadioDlgProc", NOSHELP, HELPPROC$ )

    if sz$ = "CONTINUE" then
      '' Write new NOS type...

      OPTCUR$    = GetSymbolValue( "ButtonChecked" )
      iNosInUse% = VAL( OPTCUR$ )

      if iNosInUse% = NOSLANMAN and fNosWFW% = 1 then
          iNosInUse% = NOSWFW
      elseif iNosInUse% >= 2 then
          iNosInUse% = iNosInUse% + 1 'cause LM and WFW are both selection #1
      endif

      RC% = SNASetInt( TINOSTYPE, VARPTR( iNosInUse% ))

      UIPop 1

    elseif sz$ = "REACTIVATE" then
      goto NosTypesL1
    else
      gosub AskQuit
      goto NosTypes
    endif

Remote:
    if iNosInUse% = NOSNOVELL or iNosInUse% = NOSBANYAN then
      goto GetNWDomain
    endif

    if LOCREM$ = "LOCAL" then
      OPTCUR$ = "1"
    else
      OPTCUR$ = "2"
    endif

    SetSymbolValue "RadioDefault", OPTCUR$
    SetSymbolValue "OptionsGreyed", ""

    if iNosInUse% = NOSTCP then
      goto TcpLRSelect
    endif

    SetSymbolValue "EditTextLim", "15"
    SetSymbolValue "EditTextIn",  REMSRV1$  '' causes domain name to appear when local
    SetSymbolValue "Edit2TextIn", REMSRV2$

''  if LOCREM$ = "LOCAL" then
''    SetSymbolValue "EditTextIn", ""
''  endif

RemoteL1:
    sz$ = UIStartDlg( CUIDLL$, REMOTE, "FRemoteDlgProc", REMHELP, HELPPROC$ )

    OPTCUR$ = GetSymbolValue( "ButtonChecked" )

      if sz$ = "CONTINUE" then
        UIPop 1

        if OPTCUR$ = "1" then
          TA$ = ""
          TB$ = ""
          REMSRV1$ = ""
          REMSRV2$ = ""
          LOCREM$ = "LOCAL"

          goto GetNWDomain

        else
          TA$ = UCASE$( LTRIM$( RTRIM$( GetSymbolValue( "EditTextOut" ))))
          TB$ = UCASE$( LTRIM$( RTRIM$( GetSymbolValue( "Edit2TextOut" ))))

SvrNameCheck:
          '' Check each remote servername for validity.
          RC%  = SNAValidSvr( TA$, VARPTR( IA% ))
          RC2% = SNAValidSvr( TB$, VARPTR( IB% ))

          if RC2% = 1 or RC2% = 2 then
            RC2% = 0  '' ignore blank name2
          endif

          if RC% = 1 or RC% = 2 then
            ANS% = DoMsgBox( "For remote operation, you must enter the primary server name.", "Error", MIEXCL+MBOK )
            if fInTcpRemote% = 1 then
              goto TcpRemote
            else
              goto Remote
            endif

          elseif RC% <> 0 or RC2% <> 0 then
            ANS% = DoMsgBox( "Invalid server name.", "Error", MIEXCL+MBOK )

            if fInTcpRemote% = 1 then
              goto TcpRemote
            else
              goto Remote
            endif
          endif

          '' At this point, we think we have valid server names.
          REMSRV1$ = ""
          while IA% <= LEN( TA$ )
              REMSRV1$ = REMSRV1$+MID$( TA$, IA%, 1 )
              IA% = IA% + 1
          wend

          REMSRV2$ = ""
          if IB% > 0 then
            while IB% <= LEN( TB$ )
              REMSRV2$ = REMSRV2$+MID$( TB$, IB%, 1 )
              IB% = IB% + 1
            wend
          endif

          if REMSRV1$ = "" then
            LOCREM$ = "LOCAL"
          else
            LOCREM$ = "REMOTE"
          endif

          if fInTcpRemote% = 1 then
            goto SvrNameCheckOk
          endif

        endif  '' OPTCUR$ <> "1"

    elseif sz$ = "REACTIVATE" then
      goto RemoteL1

    elseif sz$ = "BACK" then
      UIPop 1
      goto NosTypes

    else
      gosub AskQuit
      goto Remote

    endif

    goto OptFiles


TcpLRSelect:
    sz$ = UIStartDlg( CUIDLL$,TCPLRSELECT,"FRadioDlgProc",REMHELP,HELPPROC$ )

    if sz$ = "CONTINUE" then
      OPTCUR$ = GetSymbolValue( "ButtonChecked" )
      UIPop 1

      if OPTCUR$ = "1" then
        LOCREM$ = "LOCAL"
      else
        LOCREM$ = "REMOTE"
      endif

      if LOCREM$ = "LOCAL" then
        goto GetNWDomain
      else
        goto TcpRemote
      endif

    elseif sz$ = "REACTIVATE" then
      goto TcpLRSelect

    else
      gosub AskQuit
      goto TcpLRSelect
    endif


TcpRemote:
    SetSymbolValue "EditTextIn", REMSRV1$
    SetSymbolValue "Edit2TextIn", REMSRV2$
    SetSymbolValue "EditTextLim", "255"
    SetSymbolValue "RadioDefault", "2"

TcpRemoteL1:
    sz$ = UIStartDlg( CUIDLL$,TCPREMOTE,"FRemoteDlgProc",TCPREMHELP,HELPPROC$ )

    if sz$ = "CONTINUE" then
      TA$ = LTRIM$( RTRIM$( GetSymbolValue( "EditTextOut" )))
      TB$ = LTRIM$( RTRIM$( GetSymbolValue( "Edit2TextOut" )))

      UIPop 1

      fInTcpRemote% = 1
      goto SvrNameCheck

SvrNameCheckOK:
      fInTcpRemote% = 0
      goto OptFiles

    elseif sz$ = "REACTIVATE" then
      goto TcpRemoteL1
    elseif sz$ = "BACK" then
      UIPop 1
      goto TcpLRSelect
    else
      gosub AskQuit
      goto TcpRemote
    endif


GetNWDomain:
''--if iNosInUse% = NOSLANMAN or iNosInUse% = NOSWFW then
''--  goto OptFiles
''--endif

''--if iNosInUse% = NOSNB and LOCREM$ = "REMOTE" then
''--  goto OptFiles
''--endif

    '' Do dialog for Netware domain name
    SetSymbolValue "EditTextIn",  Domain$
    SetSymbolValue "EditFocus",   "ALL"
    if iNosInUse% = NOSTCP then
      SetSymbolValue "EditTextLim", "255"
    else
      SetSymbolValue "EditTextLim", "15"
    endif

GetNWDomainL1:
    sz$ = UIStartDlg( CUIDLL$,NWDOMAIN,"FEditDlgProc",NWDOMAINHELP,HELPPROC$ )

    Tmp$ = GetSymbolValue( "EditTextOut" )

    if sz$ = "CONTINUE" then
      if Tmp$ = "" then
        gosub BadNWDomain
        goto GetNWDomainL1
      endif

      if LEN( Tmp$ ) > 15 then
        gosub BadNWDomain
        goto GetNWDomainL1
      endif

      ilen% = LEN( Tmp$ )
      ia% = 1
      while MID$( Tmp$, ia%, 1 ) = "\" and ia% <= ilen%
        ia% = ia% + 1
      wend
      if ia% > ilen% then
        gosub BadNWDomain
        goto GetNWDomainL1
      endif

      Domain$ = UCASE$( MID$( Tmp$, ia%, ilen% - ia% + 1 ))
      RC% = SNASetString( TINETWAREDOMAIN, Domain$ )

      UIPop 1

    elseif sz$ = "REACTIVATE" then
      goto GetNWDomainL1

    elseif sz$ = "BACK" then
      UIPop 1
      if iNosInUse% = NOSTCP then
        goto TcpLRSelect
      elseif iNosInUse% = NOSLANMAN or iNosInUse% = NOSWFW then
        goto Remote
      elseif DoesFileExist( MakePath( DEST$, "WNAP.EXE" ), femExists ) = 0 then
        goto GetPath
      else
        if iNosInUse% = NOSBANYAN or iNosInUse% = NOSNOVELL then
          if iNosCount% = 1 then
            goto SelectL
          else
            goto NosTypes
          endif
        elseif iNosInUse% = NOSTCP then
          goto TcpLRSelect
        else
          goto Remote
        endif
        '' goto SelectL
      endif

    else
      gosub AskQuit
      goto GetNWDomain

    endif


GetSTGroupName:
    if iNosInUse% <> NOSBANYAN then
      goto OptFiles
    endif

    '' Do dialog for StreetTalk group name
    SetSymbolValue "EditTextIn",  STGroupName$
    SetSymbolValue "EditFocus",   "ALL"
    SetSymbolValue "EditTextLim", "32"

GetSTGroupL1:
    sz$  = UIStartDlg( CUIDLL$,STGROUP,"FEditDlgProc",STGROUPHELP,HELPPROC$ )
    Tmp$ = GetSymbolValue( "EditTextOut" )

    if sz$ = "CONTINUE" then
      STGroupName$ = Tmp$
      RC%  = SNASetString( TISTGROUP, STGroupName$ )
      UIPop 1
    elseif sz$ = "REACTIVATE" then
      goto GetSTGroupL1
    elseif sz$ = "BACK" then
      UIPop 1
      goto GetNWDomain
    else
      gosub AskQuit
      goto GetSTGroupName
    endif


OptFiles:
    if fFirstInstall% = 0 then
      goto ReviewChoices
    endif

    SetSymbolValue "OptionsGreyed", ""
    SetSymbolValue "CheckItemsIn",  ""

    if fInstallODBC% = 1 then
      AddListItem "CheckItemsIn", "ON"
    else
      AddListItem "CheckItemsIn", "OFF"
    endif

    if fInstall3270% = 1 then
      AddListItem "CheckItemsIn", "ON"
    else
      AddListItem "CheckItemsIn", "OFF"
    endif

    if fInstall5250% = 1 then
      AddListItem "CheckItemsIn", "ON"
    else
      AddListItem "CheckItemsIn", "OFF"
    endif

OptFilesL1:
    sz$ = UIStartDlg( CUIDLL$, OPTIONFILES, "FCheckDlgProc", NOSHELP, HELPPROC$ )

    if sz$ = "CONTINUE" then
      Check$ = ""
      i% = 1

OptFilesLoop2:
      Tmp$ = GetListItem( "CheckItemsOut", 1 )
      if Tmp$ = "OFF" then
        fInstallODBC% = 0
      else
        fInstallODBC% = 1
      endif

      Tmp$ = GetListItem( "CheckItemsOut", 2 )
      if Tmp$ = "OFF" then
        fInstall3270% = 0
      else
        fInstall3270% = 1
      endif

      Tmp$ = GetListItem( "CheckItemsOut", 3 )
      if Tmp$ = "OFF" then
        fInstall5250% = 0
      else
        fInstall5250% = 1
      endif

      UIPop 1

    elseif sz$ = "REACTIVATE" then
      goto OptFilesL1
    elseif sz$ = "BACK" then
      UIPop 1
      '' goto somewhere
    else
      gosub AskQuit
      goto OptFiles
    endif


ReviewChoices:
SysFilesTest:
    if USERFUNC$="SYSFILES" then

SysFilesHere:
      CURSOR% = ShowWaitCursor()
      RC%  = SNAInstall
      RestoreCursor CURSOR%

      ErrChk
      if ANS% = IDRETRY then
        goto SysFilesHere
      endif
    else
      Install
    endif

    if iNosInUse% = NOSNOVELL or iNosInUse% = NOSBANYAN then
      Tmp$ = Domain$
    else
      if LOCREM$ = "LOCAL" and (iNosInUse% = NOSTCP or iNosInUse% = NOSNB or iNosInUse% = NOSLANMAN or iNosInUse% = NOSWFW ) then
        Tmp$ = Domain$
      else
        Tmp$ = ""
        if REMSRV1$ <> "" then
          Tmp$ = Tmp$+"\\"+REMSRV1$
        endif
        if REMSRV2$ <> "" then
          Tmp$ = Tmp$+" \\"+REMSRV2$
        endif
      endif
    endif

    '' Write strings into WIN.INI
    CreateIniKeyValue "WIN.INI", "Wnap", "WBinPath", DEST$, cmoOverwrite
    CreateIniKeyValue "WIN.INI", "Wnap", "Remote", Tmp$, cmoOverwrite
    CreateIniKeyValue "WIN.INI", "Wnap", "LocalFlag", LOCREM$, cmoOverwrite
    if iNosInUse% = NOSBANYAN then
      CreateIniKeyValue "WIN.INI", "Wnap", "StGroupName", STGroupName$, cmoOverwrite
    endif

    if iNosInUse% = NOSLANMAN then
      TMPNOS1$ = "LANMAN"
      TMPNOS2$ = "LANMAN"
    elseif iNosInUse% = NOSWFW then
      TMPNOS1$ = "LANMAN"
      TMPNOS2$ = "WFW"
    elseif iNosInUse% = NOSNOVELL then
      TMPNOS1$ = "NOVELL"
      TMPNOS2$ = "NOVELL"
    elseif iNosInUse% = NOSBANYAN then
      TMPNOS1$ = "VINES"
      TMPNOS2$ = "VINES"
    elseif iNosInUse% = NOSTCP then
      TMPNOS1$ = "TCPIP"
      TMPNOS2$ = "TCPIP"
''--elseif iNosInUse% = NOSNB then
''--  TMPNOS1$ = "NETBIOS"
''--  TMPNOS2$ = "NETBIOS"
    endif
    CreateIniKeyValue "WIN.INI", "Wnap", "NosType",  TMPNOS1$, cmoOverwrite
    CreateIniKeyValue "WIN.INI", "Wnap", "NosSetup", TMPNOS2$, cmoOverwrite

    if fNetwkInstall% = 1 then
      Tmp$ = "YES"
    else
      Tmp$ = "NO"
    endif
    if fAdminInstall% = 1 and IsDriveNetwork( MID$( DEST$, 1, 1 )) = 1 then
      Tmp$ = "YES"
    endif
    CreateIniKeyValue "WIN.INI", "Wnap", "NetSetup", Tmp$, cmoOverwrite

    CreateIniKeyValue "WIN.INI", "Wnap", "CA400", "NO", cmoNone
    CreateIniKeyValue "WIN.INI", "Wnap", "CA400SharedFolders", "NO", cmoNone

    '' Adjust NetHeapSize if WFW
    if iNosInUse% = NOSWFW then
      TMPSYS$ = MakePath( GetWindowsDir(), "SYSTEM.INI" )
      if DoesIniKeyExist( TMPSYS$, "386Enh", "netheapsize" ) = 1 then
        Tmp$ = GetIniKeyString( TMPSYS$, "386Enh", "netheapsize" )
        NHS% = VAL( Tmp$ )
        if NHS% < 32 then
          CreateIniKeyValue TMPSYS$, "386Enh", "netheapsize", "32", cmoOverwrite
        endif
      endif
      CreateIniKeyValue TMPSYS$, "network", "PreferredRedir", "FULL", cmoOverwrite
      CreateIniKeyValue TMPSYS$, "network", "DirectHost", "NO", cmoOverwrite
    endif

    goto Quit

ConfirmRemove:
    fRemoveSnaDlls% = 1
    fRemoveOtherFiles% = 1

    sz$ = UIStartDlg( CUIDLL$, CONFIRMREMOVE, "FInfoDlgProc", APPHELP,HELPPROC$ )

    if sz$ = "CONTINUE" then
      UIPop 1
    elseif sz$ = "REACTIVATE" then
      goto GetPathL1
    elseif sz$ = "BACK" then
      UIPop 1
      goto SelectL
    else
      gosub AskQuit
      goto GetPath
    endif

    if IsWindowsShared() = 1 then
      if fAdminInstall% = 1 then
        i% = DoMsgBox( "Are you sure you want to remove SNA files from your shared Windows directory ("+WINSYSDIR$+")?", "Confirm Removal", MBYN+MIQUEST )
        if i% = IDNO then
          fRemoveSnaDlls% = 0
        endif
      else
        fRemoveSnaDlls% = 0
      endif
    endif

    if fAdminInstall% = 0 and fNetwkInstall% = 0 then
      if IsDriveNetwork( MID$( DEST$, 1, 1 )) = 1 then
        i% = DoMsgBox( "You must run SETUP /A to remove the SNA files from the network directory "+DEST$+".", "Removal", MBOK+MIQUEST )
        ErrFlag% = 1
        goto Quit
      endif
    endif

    if fNetwkInstall% = 1 then
      if fAdminInstall% = 0 then
        fRemoveOtherFiles% = 0
      else
        i% = DoMsgBox( "Are you sure you want to remove the shared SNA files from "+DEST$+"?", "Confirm Removal", MBYN+MIQUEST )
        if i% = IDNO then
          fRemoveOtherFiles% = 0
        endif
      endif
    endif

    Remove
    goto Quit

Quit:
    ON ERROR goto ErrQuit
    if ErrFlag% = 1 then
      end
    endif
    if USERFUNC$ = "REMOVE" then
      ERR = 0
    endif
    if ERR = 0 then
      if USERFUNC$ = "REMOVE" then
        dlg% = SUCCESSREMOVE
      else
        dlg% = SUCCESSINSTALL
      endif
    else
      end
    endif

QuitL1:
    sz$ = UIStartDlg( CUIDLL$, dlg%, "FInfo0DlgProc", 0, "" )
    if sz$ = "REACTIVATE" then
      goto QuitL1
    endif
    UIPop 1
    end

'==========================================================================
ErrQuit:
    i% = DoMsgBox( "Setup sources were apparently corrupted.", "Setup Message", MB_OK+MBTASK+MISTOP )
    end

BadPath:
    sz$ = UIStartDlg( CUIDLL$, BADPATH, "FInfo0DlgProc", 0, "" )
    if sz$ = "REACTIVATE" then
        goto BadPath
    endif
    UIPop 1
    return

BadNWDomain:
    sz$ = UIStartDlg( CUIDLL$, BADNWDOMAIN, "FInfo0DlgProc", 0, "" )
    if sz$ = "REACTIVATE" then
        goto BadNWDomain
    endif
    UIPop 1
    return

AskQuit:
    ANS% = DoMsgBox( "SNA Server Client software setup is not yet complete.  Are you sure you want to exit?", "Early Exit", MBYN+MIQUEST )
    if ANS% = IDYES then
      UIPopAll
      end
    else
      UIPop 1
    endif
    return

'*************************************************************************
sub Install static
    SrcDir$ = GetSymbolValue( "STF_SRCDIR" )
    CreateDir DEST$, cmoNone
    CURSOR% = ShowWaitCursor()

    '' Rename old EHNAPPC DLLs if appropriate

    if DoesFileExist(MakePath(WINSYSDIR$,"EHNAPPC.DLL"),femExists) = 1 then
      if DoesFileExist(MakePath(WINSYSDIR$,"EHNAPPC.MS0"),femExists) = 0 then

        ANS% = DoMsgBox( "Setup found an existing version of EHNAPPC.DLL in your Windows system directory.  Back it up as EHNAPPC.MS0?", "Backup File", MBYN+MIQUEST )

        if ANS% = IDYES then
          CopyFile MakePath(WINSYSDIR$,"EHNAPPC.DLL"),MakePath(WINSYSDIR$,"EHNAPPC.MS0"),cmoCopy,0
        endif
      endif
    endif

    if DoesFileExist(MakePath(WINSYSDIR$,"EHNRTRW.DLL"),femExists) = 1 then
      if DoesFileExist(MakePath(WINSYSDIR$,"EHNRTRW.MS0"),femExists) = 0 then

        ANS% = DoMsgBox( "Setup found an existing version of EHNRTRW.DLL in your Windows system directory.  Back it up as EHNRTRW.MS0?", "Backup File", MBYN+MIQUEST )

        if ANS% = IDYES then
          CopyFile MakePath(WINSYSDIR$,"EHNRTRW.DLL"),MakePath(WINSYSDIR$,"EHNRTRW.MS0"),cmoCopy,0
        endif
      endif
    endif

    if fCopyOtherFiles% = 1 then
      AddSectionFilesToCopyList "SnaFiles",      SrcDir$, DEST$
      AddSectionFilesToCopyList "SetupFiles",    SrcDir$, DEST$
    endif

    if fCopySnaDlls% = 1 then
      AddSectionFilesToCopyList "SnaDlls",       SrcDir$, WINSYSDIR$
      AddSectionFilesToCopyList "OtherDlls",     SrcDir$, WINSYSDIR$
    endif

    SrcDir2$ = SrcDir$+"odbc\"
    DEST2$ = MakePath( DEST$, "odbc" )
    if fInstallODBC% = 1 and fCopyOtherFiles% = 1 then
      CreateDir DEST2$, cmoNone
      AddSectionFilesToCopyList "OdbcFiles", SrcDir2$, DEST2$
    endif

    if fInstall3270% = 1 and fCopyOtherFiles% = 1 then
      AddSectionFilesToCopyList "Em3270Files", SrcDir$, DEST$
    endif

    if fInstall3270% = 1 or fInstall5250% = 1 then
      if IsWindowsShared() = 0 or fAdminInstall% = 1 then
        AddSectionFilesToCopyList "EmulatorFont", SrcDir$, WINSYSDIR$
      endif
    endif

    if fInstall5250% = 1 and fCopyOtherFiles% = 1 then
      CreateDir MakePath( DEST$, "charsets" ), cmoNone
      CreateDir MakePath( DEST$, "kbdinfo" ),  cmoNone
      CreateDir MakePath( DEST$, "mri2924" ),  cmoNone

      '' 5250 files
      AddSectionFilesToCopyList "Em5250Files",    SrcDir$, DEST$
      AddSectionFilesToCopyList "Em5250Dlls",     SrcDir$, DEST$
      AddSectionFilesToCopyList "Em5250Charsets", SrcDir$, DEST$
      AddSectionFilesToCopyList "Em5250Kbdinfo",  SrcDir$, DEST$
      AddSectionFilesToCopyList "Em5250Mri2924",  SrcDir$, DEST$
    endif

    RestoreCursor CURSOR%
    CopyFilesInCopyList

    '' Create the Lucida Typewriter font if necessary
    if IsWindowsShared() = 0 or fAdminInstall% = 1 then
      if fInstall3270% = 1 or fInstall5250% = 1 then
        Tmp1$  = MakePath( WINSYSDIR$, "ltype.fot" )
        Tmp2$  = "ltype.ttf"
        Tmp3$  = WINSYSDIR$
        RC% = SNACreateFont( 0, Tmp1$, Tmp2$, Tmp3$ )
      endif
    endif

InstallHere:
    CURSOR% = ShowWaitCursor()
    RC%  = SNAInstall
    RestoreCursor CURSOR%

    ErrChk
    if ANS% = IDRETRY then
      goto InstallHere
    endif

    if fInstallODBC% = 1 then
      CopyFile MakePath( DEST2$, "CTL3DV2.DLL" ), MakePath( WINSYSDIR$, "CTL3DV2.DLL" ), cmoCopy, 0
      S1$ = DEST2$+"\odbc.inf"
      S2$ = "StarSQL"

      RC% = SNAInstallODBC( S1$, DEST2$, S2$ )
      RemoveFile MakePath( DEST2$, "CTL3DV2.DLL"), cmoForce
    endif

    CreateProgmanGroup "SNA Server", "", cmoNone
    CreateProgmanItem  "SNA Server", "SNA Server Client Setup", MakePath(DEST$,"SETUP.EXE"), "", cmoOverwrite

    if fInstallODBC% = 1 then
      CreateProgmanItem  "SNA Server", "ODBC Administrator", MakePath(DEST2$,"ODBCADM.EXE"), "", cmoOverwrite
    endif

    if fInstall3270% = 1 then
      CreateProgmanItem  "SNA Server", "SNA Server 3270 Applet", MakePath(DEST$,"WIN3270.EXE"), "", cmoOverwrite
    endif

    if fInstall5250% = 1 then
      CreateProgmanItem  "SNA Server", "SNA Server 5250 Applet", MakePath(DEST$,"WIN5250.EXE"), "", cmoOverwrite
    endif

ENDOSUB:
end sub

'*************************************************************************
sub Remove static
    SrcDir$ = GetSymbolValue( "STF_SRCDIR" )
    ReadInfFile MakePath( SrcDir$, "WIN16CL.INF" )

RemoveHere:
    CURSOR% = ShowWaitCursor()
    RC%  = SNARemove
    RestoreCursor CURSOR%

    ErrChk
    if ANS% = IDRETRY then
      goto RemoveHere
    endif

    CURSOR% = ShowWaitCursor()
    RemoveIniSection "WIN.INI", "Wnap", cmoNone
    RemoveIniSection "WIN.INI", "SnaServerWin3270", cmoNone

    '' Remove files by IniSection.
    if fRemoveSnaDlls% = 1 then
      i% = NukeFilesInSection( "SnaDlls", WINSYSDIR$ )
    endif

    '' Remove files by directory name.
    if fRemoveOtherFiles% = 1 then
      SetSymbolValue "NukeDirList", ""
      if fInstall5250% = 1 then
        AddListItem "NukeDirList", MakePath( DEST$, "charsets" )
        AddListItem "NukeDirList", MakePath( DEST$, "kbdinfo"  )
        AddListItem "NukeDirList", MakePath( DEST$, "mri2924"  )
      endif

      if fInstallODBC% = 1 then
        if DoesFileExist( MakePath( DEST$, "odbc\odbc.inf" ), femExists ) = 1 then
          AddListItem "NukeDirList", MakePath( DEST$, "odbc"  )
        endif
      endif

      AddListItem "NukeDirList", DEST$

      ListSize% = GetListLength( "NukeDirList" )
      Count%    = 1
RemLoop1:
      TmpDir$   = GetListItem( "NukeDirList", Count% )
      kill MakePath( TmpDir$, "*.*" )
      RC% = SNARmDir( TmpDir$ )
      Count% = Count% + 1
      if Count% <= ListSize% then
        goto RemLoop1
      endif
    endif

    '' Rename backed-up EHNAPPC.MS0 back to EHNAPPC.DLL.

    if DoesFileExist( MakePath( WINSYSDIR$, "EHNAPPC.MS0" ), femExists ) = 1 then
      if DoesFileExist( MakePath( WINSYSDIR$, "EHNAPPC.DLL" ), femExists ) = 0 then
        CopyFile MakePath( WINSYSDIR$, "EHNAPPC.MS0" ), MakePath( WINSYSDIR$, "EHNAPPC.DLL" ), cmoCopy, 0
      endif
    endif
    if DoesFileExist( MakePath( WINSYSDIR$, "EHNRTRW.MS0" ), femExists ) = 1 then
      if DoesFileExist( MakePath( WINSYSDIR$, "EHNRTRW.DLL" ), femExists ) = 0 then
        CopyFile MakePath( WINSYSDIR$, "EHNRTRW.MS0" ), MakePath( WINSYSDIR$, "EHNRTRW.DLL" ), cmoCopy, 0
      endif
    endif

    ERR = 0
    RestoreCursor CURSOR%
end sub

'*************************************************************************
sub ErrChk static
    ANS% = 0
    ECAP$ = "Error"

    select case RC%
      case SUOK
      case SUNOMEM
        ETXT$   = "Insufficient memory to run Setup.  Close some applications, Retry or Cancel, and rerun Setup."
        ESTYL% = MIEXCL + MBRC

      case SULANMANVER
        ETXT$   = "Unsupported network version.  SNA Server requires Microsoft LAN Manager version 2.0c or higher."
        ESTYL% = MIEXCL + MBOK

      case SUWINVER
        ETXT$   = "Unsupported Windows Version.  SNA Server requires Windows 3.0 or higher."
        ESTYL% = MIEXCL + MBOK

      case SUBADLANMANINI
        ETXT$   = "Corrupted LANMAN.INI File.  Repair the file and rerun Setup."
        ESTYL% = MIEXCL + MBOK

      case SUBADWININI
        ETXT$   = "Corrupted WIN.INI File.  Repair the file and rerun Setup."
        ESTYL% = MIEXCL + MBOK

      case SUOPENREADERR
        BADFILE$     = STRING$( 15, 32 )
        RC%       = SNAGetString( TIFILEERROR, BADFILE$, 15 )
        ETXT$   = "Error opening or reading: " + BADFILE$
        ESTYL% = MIEXCL + MBARI

      case SUOPENWRITEERR
        BADFILE$     = STRING$( 15, 32 )
        RC%       = SNAGetString( TIFILEERROR, BADFILE$, 15 )
        ETXT$   = "Error opening or writing: " + BADFILE$
        ESTYL% = MIEXCL + MBARI

      case else

    end select

    if RC% > SUOK then
      ANS% = DoMsgBox( ETXT$, ECAP$, ESTYL% )
      if ANS% = IDOK then
        end
      elseif ANS% = IDCANCEL then
        end
      endif
    endif

end sub

'*************************************************************************
function NukeFilesInSection( szSecName$, szDir$ ) static as integer
    ListName$ = "NukeList"
    MakeListFromSectionKeys ListName$, szSecName$
    ListSize% = GetListLength( ListName$ )
    Count%    = 1
    Eflag%    = 0

NukeLoop1:
    KeyName$  = CHR$(34)+GetListItem( ListName$, Count% )+CHR$(34)
    KeyStr$   = GetIniKeyString( MakePath( DEST$, "WIN16CL.INF" ), szSecName$, KeyName$ )
    FileName$ = GetNthFieldFromIniString( KeyStr$, 12 )
    FilePath$ = MakePath( szDir$, FileName$ )

    RemoveFile  FilePath$, cmoForce
    if DoesFileExist( FilePath$, femExists ) then
      Eflag% = 1
    endif

    Count% = Count% + 1
    if Count% <= ListSize% then
      goto NukeLoop1
    endif

    NukeFilesInSection = Eflag%

end function

'*************************************************************************
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$
    endif
end function
