This program turns a Basic program into an INDEXED file (or lists it to a text file) from inside another program. It starts a ghost task, sends it LOAD, OPEN and LIST commands, and reads back each response.
! 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 Task10 REM "PJEXPORT -- Use a Ghost Task to turn a program into an INDEXED FILE15 START 1,"G0" ! Start up a ghost task20 OPEN(1) "G0" ! Open a channel to it25 GOSUB 07000 ! Get response from ghost30 PRINT(1)"LOAD"+QUO+"ID"+QUO, ! Load a program into the ghost35 GOSUB 07000 ! Get response from ghost40 PRINT(1)"OPEN(1)"+QUO+ ! Open a predefined INDEXED file to a "ID.IND"+QUO ! channel in the ghost45 GOSUB 7000 ! Get response from ghost50 PRINT(1)"LIST(1)", ! List the program to the file55 GOSUB 7000 ! Get response from ghost60 PRINT(1)"END", ! Close the ghost task channel70 CLOSE(1) ! Close the ghost task80 RELEASE "G0" ! Release the ghost task90 END ! The end.7000 REM "GRAB RESPONSE FROM GHOST7020 INPUT(1,ERR=7021) A$; ! INPUT from the ghost until we hit an GOTO 7020 ! error, discard the input7030 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.Notes
- To convert a list of programs, read their names from a SORT file and repeat the steps for each one.
- You can do the reverse, rebuilding programs from INDEXED files, by sending MERGE and SAVE commands to the ghost.
- Always use QUO for quotes in commands sent to the ghost.
- Catch every response from the ghost with INPUT, or an ERROR 13 can result. PRINT the contents of A$ to monitor progress.