"Loading MKWORD and ENDWORD" $PRINT CRLF ; for HP-IPL/OS 0.57 1/3/04 ; This is something I've always done, define a dummy definition to serve ; as the main name for a word, then define a whole bunch of subroutines ; with the top-level code last, then wrap the 1st def around the last so ; it appears as a single word in WORDS, all the subroutines are permanently ; hidden. MARKCON/SETCON can do something like this but is designed mainly ; for user programs. When you don't need multiple contexts, you don't mind ; if the code is non-EXPLAINable, and you just want an entire program ; (subs and all) to appear as one word, this is more convenient. ; ; Immediate/IPL Usage: ; "TEST" MKWORD ; DEFINE SUB1 ; "SUB1 " $PRINT END ; DEFINE SUB2 ; "SUB2 " $PRINT END ; DEFINE MAIN ; SUB1 SUB2 SUB1 END ; ENDWORD ; ; Wraps up all subs and main code body into TEST which is the only ; visible word left in the dictionary, subs and code are hidden. ; ; ? TEST ; SUB1 SUB2 SUB1 ; ? EXPLAIN TEST ; OCTAL DEFINE TEST ;ENSEC=026665 ; MAIN END ; ? WORDS ; ........... TEST ; EOD=026733 FREE=025044 ; ? ; ;------------------------------------ ; ; "NAME" MKWORD defines a 1-word definition containing a place-holder ; word (CONSOLE), name left on X for $END to process. ; OCTAL DEFINE MKWORD $DUP ADDHEADER$ @ENSEC ADDCODE "CONSOLE" $DEFADR ADDCODE @RTSEC ADDCODE FIXLINKS END ;------------------------------------ ; ; [X] ENDWORD wraps NAME (still on X) around last definition and ; patches NAME to run it, ending the compound word. ; OCTAL DEFINE ENDWORD @USR GET DO DUP 3 ADD GET GET IFZ #1 ELSE 3 ADD GET #0 ENDIF UNTIL 4 ADD DUP DEC GET $DUP $DEFADR DEC SWAP PUT $DEFADR INC SWAP PUT END ;------------------------------------ "Done." $PRINT CONSOLE