; This IPL converts a text file attached to PTR to HP BASIC code ; on the terminal screen which can be copied into a basic project. ; ENTER # TO CONTINUE ? prompts inserted every 22 lines separated ; by blank space before/after, should look OK on either 24 or 25 lines. ; To use attach file to PTR and run BASCONV, prompts for starting ; line and increment. Note!!! runs in decimal mode, to terminate and ; restore normal octal mode put EOF on the last line of the input file. ; Without this, hangs at end of file, halt, run 2 to prompt and OCTAL ; to avoid operating in decimal mode and causing major difficulty when ; you PUT or something thinking you're in octal mode. ; Original hack 7/27/07 last mod 8/6/07 DECIMAL DEFINE BASCONV ;don't feel like converting numbers to octal DECIMAL CRLF "Warning.. operating in DECIMAL mode, if error occurs be sure" $PRINT CRLF "to reset to OCTAL mode before using anything requiring that." $PRINT CRLF "Hit enter for prompts to exit. Text must be attached to PTR." $PRINT CRLF CRLF "Enter starting line: " $PRINT $IN 32 $APPEND $VAL "Enter increment : " $PRINT $IN 32 $APPEND $VAL OVER OVER ADD IFNZ ;if numbers actually entered SWAP DUP PNUM OVER ADD " PRINT" $PRINT CRLF ;kick it off #0 S>Z ;line count on Z DO ;until nothing left to do Z>S DUP INC S>Z ;get line count, inc stored copy 22 SUB IFZ ;if line 22 Z>S DROP #1 S>Z ;reset count DUP PNUM OVER ADD " PRINT" $PRINT CRLF DUP PNUM OVER ADD " PRINT " $PRINT 34 PCHR "ENTER # TO CONTINUE " $PRINT 34 PCHR ";" $PRINT CRLF DUP PNUM OVER ADD " INPUT N" $PRINT CRLF DUP PNUM OVER ADD " PRINT" $PRINT CRLF ENDIF MS$IN ;get a line of input "EOF" $EQUAL IFZ ;if not end of text $LEN IFNZ ;if not empty convert chars #0 $LEN DEC +DO ;loop thru all chars INDEX DUP $GET ;get char from string DUP CASE = 34 DROP 96 ;change quotes to single quote = 95 DROP 45 ;change underscore to dash ; > 97 DUP CASE < 123 32 SUB ENDCASE ;lc to uc ; PT HP-BASIC supports lower case in prints, ; but the ~ char abandons the line so change that... = 126 DROP 45 ;change ~ to dash ENDCASE $PUT ;char back in string +LOOP DUP PNUM OVER ADD " PRINT " $PRINT 34 PCHR ;start print $LEN 55 SUB IF<0 ;if short enough $PRINT 34 PCHR CRLF ;print whole line ELSE #0 42 $SLICE $PRINT 34 PCHR ";" $PRINT CRLF ;1st half DUP PNUM OVER ADD " PRINT " $PRINT 34 PCHR ;start new line 43 $LEN $SLICE $PRINT 34 PCHR CRLF ;2nd half $DROP ;original string ENDIF ELSE DUP PNUM OVER ADD " PRINT" $PRINT CRLF ;empty line $DROP ;empty string ENDIF #1 ;loop for more ELSE ;EOF on line $DROP ;EOF line #0 ;terminate ENDIF WHILE ENDIF DROP DROP ;line number and increment OCTAL END OCTAL CONSOLE