[net.lang.forth] Yet another switch.com

toma@tekgvs.UUCP (07/03/86)

The recently posted switch.com (a program to change the switch
character) failed to run on my system (boy is this a common
problem!).  The C program source compiled fine, but produced a
rediculously large, 6000 byte, executable file considering this
is a tiny program.  So here is another version, both in source 
(Forth for my Cforth compiler) and as a 319 byte COM file:

\ DOS utility which changes the switch character
\ execute "SWITCH" to see the current value,
\ or "SWITCH c" to set the character to "c".

100 MSDOS	\ This line, the "IN/OUT" lines, and the last two
		\ lines are compiler directives

HEX

80 CONSTANT COMMAND-LINE	\ Address of command line buffer

2 1 IN/OUT
CODE DOSINT  ( DL-value AX-value -- DL-value )
	BL DL MOV	\ set up registers, AX is already OK!
	21 INT
	DL AL MOV	\ return result
	AH AH XOR
	RET

0 1 IN/OUT
: GET-IT ( -- character )
	0 3700 DOSINT
;

2 0 IN/OUT
: CHANGE-IT ( oldChar newChar -- )
	." Changing option switch character from " SWAP EMIT
	."  to " DUP EMIT CR
	3701 DOSINT DROP
;

1 0 IN/OUT
: DISPLAY-IT ( currentChar -- )
	." Current switch character is " EMIT CR 
;

0 0 IN/OUT
: QUIT  ( go back to DOS in an expedient manner )
	0 0 BDOS 
;

: MAIN
	GET-IT
	COMMAND-LINE COUNT 0 ?DO	\ look for argument character
		COUNT DUP BL <> IF NIP CHANGE-IT QUIT  
				   ELSE DROP THEN  
		LOOP
        DROP	\ unneeded address pointer
	DISPLAY-IT
;


INCLUDE FORTHLIB
END


---------Cut Here and uudecode------------
begin 644 switch.com
MZ0@`/P(`````"@"\FO_'!@4!F/^]_O^)+@<!_.B/`,T@B-K-(8C0,.3#,=NX
M`#?I[_]34.BW`"9#:&%N9VEN9R!O<'1I;VX@<W=I=&-H(&-H87)A8W1E<B!F
M<F]M(%A;DU/HN@#HA@`$('1O(%A0Z*T`Z)X`N`$W6^BE_\-0Z&T`'$-U<G)E
M;G0@<W=I=&-H(&-H87)A8W1E<B!I<R!8Z'T`Z6X`,=LQP.A[`%##Z'G_NX``
M4(H',.1#,<GH<0!U`^DD`(H',.1#4XG#/2``=!!8DUM1Z%K_65'HR/]9Z0``
M0?]&`%MQW$5%6.F/_UN*!S#D0U-0`<-86E.)T^D``(G!XPZ*!S#D0U-1Z!$`
M65OB\L.X#0#H!@"X"@#I``"[`@"3Z`$`PXC$B=K-(3#DP[H`@"G"`<I-38E6
$`#G!P\.X
`
end