! Problem: How do I turn a program into an INDEXED file (or LIST it out

! to a TEXT or ASCII file) from within a program?

! Solution: Use a Ghost Task

10 REM "PJEXPORT -- Use a Ghost Task to turn a program into an INDEXED FILE

15 START 1,"G0" ! Start up a ghost task

20 OPEN(1) "G0" ! Open a channel to it

25 GOSUB 07000 ! Get response from ghost

30 PRINT(1)"LOAD"+QUO+"ID"+QUO, ! Load a program into the ghost

35 GOSUB 07000 ! Get response from ghost

40 PRINT(1)"OPEN(1)"+QUO+ ! Open a predefined INDEXED file to a

"ID.IND"+QUO ! channel in the ghost

45 GOSUB 7000 ! Get response from ghost

50 PRINT(1)"LIST(1)", ! List the program to the file

55 GOSUB 7000 ! Get response from ghost

60 PRINT(1)"END", ! Close the ghost task channel

70 CLOSE(1) ! Close the ghost task

80 RELEASE "G0" ! Release the ghost task

90 END ! The end.

7000 REM "GRAB RESPONSE FROM GHOST

7020 INPUT(1,ERR=7021) A$; ! INPUT from the ghost until we hit an

GOTO 7020 ! error, discard the input

7030 RETURN ! Go back

!NOTES:

! This can also be used to automated the process of turning a list of

! programs into INDEXED files by adding the apporpriate code. Use a SORT

! file containg the list of programs. The inverse is possible with the

! MERGE and SAVE commands sent to the ghost reconstitute programs out

! of INDEXED files.

!

! It is very inportant that QUO is used for quotes sent to the ghost.

! Make sure all possible responses from the ghost are caught with INPUT

! or an ERROR 13 could result. PRINT the contents of A$ to monitor the

! progress.