;       $VER: Installation TPP V4.00E (21.06.92)

.BRA {
.KET }

; default root directory

Set DefaultDir "work:tpp"

; set some internal flags
Set ARexxIsInstalled Yes
Set PaxTeXIsInstalled Yes

Lab Start

; get the root directory of `TeXt Plus Professional'

Echo "Please, enter a name for the TeXt"
Echo "Plus Professional root-directory."
Echo "Directory (<Return> = $DefaultDir) ? " NoLine

; unset previous value

UnSet Directory

; get target directory

Set >NIL: Directory ?

; If only <Return> has been pressed, use <DefaultDir>

If "$Directory" EQ "*$Directory"
        Set Directory $DefaultDir
EndIf

; remember the original path

Set OrigDir $Directory

; check wether a '/' is to be appended to the directory name

FailAt 21

Assign >NIL: ${Directory} Exists

If FAIL
    FailAt 10

    ; directory already exists

    If NOT EXISTS $Directory
        FailAt 21

        ; okay, try to make the directory

        MakeDir "$Directory"

        ; Das war nichts ...

        If FAIL
            Echo "*NUnable to make $Directory"

            FailAt 10

            ; back where we started

            Skip Back Start
        EndIf
    EndIf

    ; attach an icon to the directory

    Copy tpp.info "$Directory.info"

    ; append a '/' to the directory-name

    Set Temp "$Directory/"

    Set Directory $Temp

    UnSet Temp
EndIf

; unpack main binaries

:c/Lha -q x tpp/bin/TPPbin.lha "${Directory}"

; unpack documentation

:c/Lha -q x tpp/doc/TPPdoc.lha "${Directory}"

Set DocDefaultDir "S:"

Lab DocStart

; Where to place 'TPP.guide'?

Echo "*NPlease, enter the directory-name, where"
Echo "the HyperText-documentation is to be installed to."
Echo "Directory (<Return> = $DocDefaultDir) ? " NoLine

; unset previously set value

UnSet DocDirectory

; get target directory

Set >NIL: DocDirectory ?

; if only <Return> has been pressed, use <DocDefaultDir>

If "$DocDirectory" EQ "*$DocDirectory"
        Set DocDirectory $DocDefaultDir
EndIf

; check wether a '/' is to be appended to the directory name

FailAt 21

Assign >NIL: ${DocDirectory} Exists

If FAIL
    FailAt 10

    ; directory already exists?

    If NOT EXISTS $DocDirectory
        FailAt 21

        ; okay, try to make a directory

        MakeDir "$DocDirectory"

        ; failed

        If FAIL
            Echo "*NUnable to make $DocDirectory"

            FailAt 10

            ; back where be started

            Skip Back DocStart
        EndIf
    EndIf
EndIf

; copy hypertext documentation
Copy ${Directory}doc/TPP.guide(.info|%) $DocDirectory Quiet
; and delete
Delete >NIL: ${Directory}doc/TPP.guide(.info|%)

; copy the readme file
Copy LiesMich(.info|%) ${Directory}doc Quiet

; copy the configuration files

Copy tpp/config "${Directory}config" All Quiet

; and the parse-files,

Copy tpp/parse "${Directory}parse" All Quiet

; the examples,

Copy tpp/example "${Directory}example" All Quiet

; the picture, and

Copy tpp/iff "${Directory}iff" All Quiet

; the example mailmerge file

Copy tpp/mailmerge "${Directory}mailmerge" All Quiet

; copy additional pd-software MSClock23 und Find20

Copy tpp/pd "${Directory}pd" All Quiet

; create the text-Directory

MakeDir "${Directory}text"

; copy the handler

Copy l/TextPlus-Handler L: Quiet

; copy some icons (but not rexx.info)

Copy tpp/[a-qs-z]#?.info "${Directory}" Quiet

; Copy Nico Franois' powerpacker.library and reqtools.library

Echo "*NDo you want to install powerpacker.library"
Echo "1.5 (35.344) and reqtools.library 1.0e (37.726)?"
Echo "You should only hit 'n' now, if you already"
Echo "installed newer versions than those above. "

Ask "y = Yes, n = No ?"

IF WARN
    Copy libs/(powerpacker|reqtools).library LIBS: Quiet
EndIF

; is there a 'rexx:'-directory

If NOT EXISTS REXX:

    ; unfortunately not

    Echo "*NThere is no REXX:-directory!"
    Echo "The ARexx-macros are not going to be installed."
    Echo "If you nevertheless want to install them, you"
    Echo "have to invoke this script for a second time,"
    Echo "AFTER you have installed ARexx!"
    Echo "Working with TPP without ARexx is not sensible!"

    Set ARexxIsInstalled No

EndIf

; not everybody gets macros ...

If NOT $ARexxIsInstalled EQ No

    ; copy the arexx macros
    Copy tpp/rexx/tpl rexx:tpl All Quiet
    Copy tpp/rexx/#?.tpl rexx: All Quiet
    Copy tpp/rexx/#?.sd rexx: All Quiet

EndIf

; Is PaxTeX installed?

IF NOT EXISTS TeX:macros

    ; unfortunately not

    Echo "*NThere is no directory 'TeX:macros'!"
    Echo "The TeX-macros are not going to be installed."
    Echo "If you nevertheless want to install them, you"
    Echo "have to invoke this script for a second time,"
    Echo "AFTER you have installed PasTeX!"
    Echo "You cannot compile or print documents without"
    Echo "the TeX-macros!"

    Set PasTeXIsInstalled No

EndIf

; Without TeX we are lost

If NOT $PasTeXIsInstalled EQ No

    ; copy the tex-macros
    Copy tpp/tex/macros TeX:macros All Quiet

EndIf

; this is the end of the script as I know it ...

Echo "*NTeXt Plus Professional has been installed."
Echo "You only have to add the following line"
Echo "to your S:Startup-Sequence or S:User-Startup:"

Echo "*NAssign TPP: $OrigDir"

; bitch a bit
IF $ARexxIsInstalled EQ No

Echo "*NDo not forget to install the ARexx macros!"

EndIf

IF $PasTeXIsInstalled EQ No

Echo "*NDo not forget to install the PasTeX macros!"

EndIf

; execute the assign for prophylactical reasons
Assign >NIL: TPP: "$OrigDir"

Echo "*NEnjoy TeXt Plus Professional!"
