' PLAYFILE.BAS ' ' Sample playback program for the PPC-1000 ' ' The program prompts for a text file containing the PPC ' commands to be executed. We then send each code to the PPC ' and display all responses in a small text window at the bottom ' of the screen. ' ' Check the following - you should include this in your code... ' OPEN "COM2:9600,N,8,1,RS,CS,DS" FOR RANDOM AS #1 ' ' first you should send a CR-LF to the PPC - you must send this ' after it has completed its power-on self test. ' PRINT #1, CHR$(13) FOR i = 1 TO 10000 ' give the PPC a chance to process NEXT i GOSUB 1000 ' wait for the PPC to acknowledge with ' a > symbol ' ' display all responses from the PPC - note that since the PPC echo's ' all input, we will strip incoming CR-LF's. ' CLS COLOR 15, 1 PRINT " " PRINT " Playfile - sample program to send a file of commands to the PPC-1000 " PRINT " " COLOR 7, 0 PRINT ' ' get text file name from user ' INPUT "Enter name of text command file :"; fl$ LOCATE 5, 1 PRINT " Command to PPC Response " PRINT " ------------------ ---------------" VIEW PRINT 8 TO 23 ' open text file and the play it to the PPC ' OPEN fl$ FOR INPUT AS #2 WHILE NOT (EOF(2)) ' until all commands sent INPUT #2, a$ PRINT a$; ' display file command on screen IF LEN(a$) < 2 THEN END ' if < 2 chars then a bad command FOR i = 1 TO LEN(a$) PRINT #1, MID$(a$, i, 1); FOR j = 1 TO 2000 ' set for your computer speed NEXT j ' a pentium is too fast for NEXT i ' the PPC to take all at once PRINT , , ; GOSUB 1000 ' wait for the PPC to execute PRINT WEND CLOSE #1 CLOSE #2 END ' ' Subroutine to look for the > symbol that the PPC when it has ' completed a command. Note we print all chars the PPC sends back. ' ' If you code an application in BASIC, you should use the Declare SUB ' to make this an easy to use (and reusable) module ' 1000 : DO a$ = "" IF NOT (EOF(1)) THEN ' check the receive buffer a$ = INPUT$(1, 1) ' got a char from PPC IF LEN(a$) <> 0 THEN ' is it a vaild char ? SELECT CASE a$ CASE IS = CHR$(13) ' strip CR CASE IS = CHR$(10) ' strip LF CASE ELSE PRINT a$; END SELECT END IF END IF LOOP WHILE a$ <> ">" ' loop until we get a "finished" WHILE NOT (EOF(1)) ' flush the receive buffer a$ = INPUT$(1, 1) WEND RETURN