;Copy specified number of bytes from MS input ;to named library segment. Name must match first ;word of IPL, for multi-word programs use MKWORD/ENDWORD ;to encapsulate sub-words and main word into a single word ;Usage: #bytes "NAME" MS2L ;modified 2/13/08 to use lib2.ipl's LBUF var if it exists ;(otherwise defaults LBUF to buffer 3), lib2.ipl has no MSSCAN ;so define it if it doesn't exist OCTAL "Loading MS2L utility..." $PRINT CRLF "LBUF" $DEFADR ;push 0 if no LBUF VARIABLE LBUF LBUF 3 PUT ;default to buffer 3 if orig lib.ipl used DEFINE TEMP IFZ ;if no dup "TEMP" $DEFADR 4 SUB #0 PUT ;delete self "Defaulting to buffer " $PRINT LBUF GET PNUM CRLF ELSE ;dup detected "Using existing LBUF variable" $PRINT CRLF "LBUF" $DEFADR 4 SUB #0 PUT ENDIF END TEMP ;do it, will delete self ; "MSSCAN" $DEFADR ;push 0 if MSSCAN doesn't exist ;------- scarfed and modded from msscan.ipl ;support for multiple-file streams 11/6/04 ;"string" MSSCAN - searches for "string" in MS input stream, ;up until ascii 128 character. If found, pushes a 1 and leaves ;MS positioned to next character after target, otherwise pushes 0. OCTAL DEFINE MSSCAN #0 ;success/fail flag #0 ;mode - 0=looking for 1st occ, 1=matching subsequent $DUP ;match string, when empty match is made $HEAD ;start by looking for first char DO ;until done MSBIN ;get one byte from MS input DUP 200 SUB IFZ ;if ascii 128 then DROP ;the ms in char DROP ;the char being matched DROP ;the mode ;leave 0 on stack #1 ;we're done ELSE ;not an ascii 128, try to match... OVER SUB IFNZ ;(drop char) if no match then OVER IFZ ;if mode 0 #0 ;just keep going ELSE ;if partial match gone bad DROP DROP ;match char and mode #0 ;back to mode 0 $DROP $DUP $HEAD ;start it again #0 ;keep going ENDIF ELSE ;finally a match! DROP DROP ;the match char and mode $LEN ;of emptying match string IFZ ;if successful match DROP #1 ;change to success #1 ;and exit ELSE #1 ;mode 1, match successive chars $HEAD ;next char to match #0 ;keep going ENDIF ENDIF ENDIF UNTIL ;done $DROP $DROP ;strings END DEFINE TEMP IFZ ;if no dup "TEMP" $DEFADR 4 SUB #0 PUT ;delete self "MSSCAN loaded" $PRINT CRLF ELSE ;dup detected "Using existing MSSCAN" $PRINT CRLF "MSSCAN" $DEFADR 4 SUB #0 PUT ENDIF END TEMP ;do it, will delete self ; DEFINE MS2L CWA LBUF GET ADD GET #1 AND IFZ $DROP "No library" $PRINT DROP ELSE MS_SAVE LBUF GET >FILE LBUF GET FSA LBUF GET ADD GET DEC SEEK ";;;FILE:" MS$OUT MS$OUT ":" MS$OUT MSCRLF #1 SWAP +DO MSBIN MSBOUT +LOOP FPA LBUF GET ADD GET ;push current pointer in case no action 200 MSBOUT ;terminate temporarily LBUF GET