\ MACROS.SEQ Keyboard macros for F-PC by Tom Zimmer anew macros comment: Keyboard macros for F-PC. To DEFINE a macro; Press Alt-M \ starts defining, waits for next key Press Alt-1 \ tells it which macro to make, can be \ Alt-1 through Alt-5, waits for first \ key of macro Start entering keys. \ keys are passed on to program and saved too Press Alt-M \ Ends definition of the new macro Thats all there is to MAKING macros. To PERFORM a macro; Press Alt-1 \ Macro processor passes back all keys \ one for each call to key until empty Thats all there is to DOING macros. To REPEAT a macro; Press Alt-R \ We will be repeating a macro key Enter a # between 0-999 \ The number of times to repeat the macro Press Alt-1 \ the macro to repeat. comment; only forth also hidden also definitions 248 constant macbase \ Alt-1 10 constant #macros \ Through Alt-0 \ 187 constant macbase \ F1 \ 10 constant #macros \ Through F10 128 constant macsiz 0 constant macseg : ms: ( n1 --- seg n1 ) macseg swap ; : macreset ( --- ) \ Clear macros segment pointer. defers initstuff 0 =: macseg ; ' macreset is initstuff : macinit ( --- ) macseg if exit then #macros macsiz * u16/ alloc if 2drop exit then nip =: macseg macseg 0 #macros macsiz * 0 lfill ; variable curmac variable doingmac variable makingmac : .makemac ( --- ) #out @ #line @ >r >r 25 07 .box" Making a MACRO." 08 10 .box" Press Alt-1 to Alt-9 to specify the macro you are making." 17 13 .box" Enter the keys of your macro, then;" 13 16 .box" Press Alt-M again to finish building a macro." r> r> at ; : .repmac ( --- ) 25 07 .box" Repeating a MACRO." 01 10 .box" Enter a # between 000 and 999 for the number of times to repeat the macro." 30 13 .box" " 17 16 .box" Enter the macro key Alt-1 to Alt-9" 32 14 at ; : setmac ( n1 --- ) \ set the current macro pointer. macsiz * curmac ! ; : ?domac ( --- ) \ Are we doing a macro, if so return a key. doingmac @ if curmac @ ms: c@l curmac @ 1+ ms: c@l 0= if doingmac off then curmac incr r> r> 2drop then ; : ?domac1 ( c1 --- c2 ) \ If a macro key, start macro and return \ the first macro key if its good. dup macbase dup #macros 1- + BETWEEN if doingmac on macbase - setmac curmac @ ms: c@l curmac incr ?dup 0= if doingmac off curmac @ 1- macsiz / macbase + then then ; variable mactimes \ number of times to perform a macro variable repkey \ macro key we are repeating : ?repmac ( --- ) mactimes @ if mactimes decr repkey @ ?domac1 r> r> 2drop then ; : ?repmac1 ( c1 --- c1 ) dup 147 = makingmac @ 0= and \ Alt-R = repeating if drop savescr #out @ #line @ >r >r .repmac 0 begin defers key dup ascii 0 ascii 9 between while dup emit ascii 0 - swap 10 * + 999 min repeat restscr r> r> at swap 1- 0 max 999 min mactimes ! dup repkey ! then ; : ?addmac ( c1 --- c1 ) \ conditionally add a key to current macro. makingmac @ if dup curmac @ ms: c!l curmac incr 0 curmac @ ms: !l then ; : ?start/stopmac ( --- c1 ) \ Conditionally start of stop making a macro. begin defers key dup 178 = makingmac @ 0= and \ Alt-M = Make macro if drop savescr .makemac defers key restscr \ Alt-1 to Alt-5 dup macbase dup #macros 1- + BETWEEN 0= \ macro key number if exit then macbase - setmac 0 curmac @ ms: !l makingmac on defers key then dup 178 = makingmac @ and \ Alt-M and making while drop makingmac off repeat ; : mackey ( --- c1 ) \ This definition looks more like PASCAL macinit macseg 0= if defers key else ?domac ?repmac ?start/stopmac ?addmac ?repmac1 ?domac1 then ; \ Alt-1 = 248, to Alt-5 = 252 ' mackey is key only forth also definitions