SRC" plasma.4th"
SRC" conio.4th"

: [THEN] ; IMMEDIATE ( PLACE HOLDER TO RESUME EXECUTION )
DEFER [ELSE] ( SKIP UNTIL [THEN] IF EXECUTED )
: [IF] ( F -- )
  NOT IF ( SKIP CODE IN BETWEEN [ELSE] OR [THEN] )
    [COMPILE] [ELSE]
  THEN
; IMMEDIATE
:NONAME ( [ELSE] )
  1 >R
  BEGIN
    BL WORD FIND IF
      CASE
        ' [ELSE] OF
          R@ 1 = IF ( RESUME EXECUTING AT MATCHING [ELSE] )
            R> DROP DROP EXIT
          THEN
          ENDOF
        ' [THEN] OF
          R> 1- ?DUP 0= IF ( EXIT AT FINAL [THEN] )
            DROP EXIT
          THEN
          >R
          ENDOF
        ' [IF] OF ( CHECK FOR NESTED [IF] )
          R> 1+ >R
          ENDOF
      ENDCASE
    ELSE
      DROP
    THEN
  AGAIN
; IMMEDIATE IS [ELSE]

: STRINPUT ( STR -- )
  DUP 1+ 255 ACCEPT -TRAILING SWAP C!
;
: STRING CREATE 256 ALLOT DOES> ; ( JUST ALLOCATE THE BIGGEST STRING POSSIBLE )

: CONFIRM" ( -- F )
  COMPILE ."
  ."  (Y/N)"
  KEY CR TOUPPER CHAR Y =
;

STRING DEST
STRING FILELIST

0 0 40 24 VIEWPORT
HOME
12 SPACES INVERSETEXT
." PLASMA HD INSTALL"
NORMALTEXT CR CR
0 1 40 23 VIEWPORT
." Enter destination " DEST STRINPUT
DEST C@ 0= ?ABORT" Destination required"
." Copying system files to " DEST (.") CR
FILELIST " -R EDITOR.README PL* CMD* SYS " STRCPY DEST STRCAT
" COPY" SWAP LOADMOD

CONFIRM" Copy demos?" [IF]
  FILELIST " -R DEMOS " STRCPY DEST STRCAT
  " COPY" SWAP LOADMOD
[THEN]

CONFIRM" Copy build tools?" [IF]
  DEST " /BLD" STRCAT DROP
  " NEWDIR" DEST LOADMOD
  FILELIST " BLD/PLASM BLD/CODEOPT " STRCPY
  DEST STRCAT
  " COPY" SWAP LOADMOD
  FILELIST " -R BLD/INC " STRCPY DEST STRCAT
  " COPY" SWAP LOADMOD

  CONFIRM" Copy sample code?" [IF]
    FILELIST " -R BLD/SAMPLES " STRCPY DEST STRCAT
    " COPY" SWAP LOADMOD
  [THEN]

[THEN]

." Done" CR
0 0 40 24 VIEWPORT
BYE
