[net.sources] Get/set switch char for PC/MS-DOS

movshon@acf8.UUCP (Tony Movshon) (03/02/86)

The following program lets you check or set the DOS "switch" character.
This restores the ability (lost in DOS 3.x) to use the SWITCHAR option
in CONFIG.SYS. The default "switch" character is "/"; if any other
character is used instead (e.g. "-" a la Un*x), then "/" may be used
as a path-separator (again, a la Un*x). This is not an officially-
supported feature of DOS; some system programs and many application
programs may not act as if the switch character is changed. But if
you get bent out of shape by having to do running "\"-for-"/"
substitutions when you are running DOS, then this baby is for you.
It runs under any version of PC or MS-DOS between 2.00 and 3.10. It
may not work on later versions. Caveat emptor.

This is, of course, a shell archive; follow the instructions and
feed it to /bin/sh or unshar.

				Tony Movshon
				Psychology/NYU

uucp: {seismo|ihnp4|allegra}!cmcl2!xp!tony
arpa: xp!tony@nyu

#!/bin/sh
# This is a shell archive, meaning:
# 1. Remove everything above the #!/bin/sh line.
# 2. Save the resulting text in a file.
# 3. Execute the file with /bin/sh (not csh) to create the files:
#	swchar.asm
# This archive created: Sat Mar  1 16:28:43 1986
export PATH; PATH=/bin:$PATH
if test -f 'swchar.asm'
then
	echo shar: over-writing existing file "'swchar.asm'"
fi
cat << \SHAR_EOF > 'swchar.asm'
	name	swchar
	page	55,132
	title	'SWCHAR --- display or change switch character'
;
; Copyright 1984 by Michael D. Parker (mike@LOGICON)
; This program may be freely reproduced and modified for
; noncommercial use.
;
; ---------- Explanation

; This program that will either report or set the SWITCHAR from the DOS
; command level. Use for version of DOS 2.00 and LATER.

; Command line calling sequence
;
;	swchar		      (to report current switchar)
;
;	   or
;
;	swchar x      (to change switchar to 'x')
;

; This program uses the SWITCHAR function of the DOS function request
; interrupt.  This DOS function, 37H is listed by IBM as "used
; internally by DOS".  It is passed either 1 or 2 parameters,
; depending on usage.

; To get the current SWITCHAR, put 37H in the AH register, 00H in the
; AL register, and generate an INT 21H. The current SWTICHAR will be
; returned in the DL register.

; To change the current SWITCHAR, put 37H in the AH register, 01H in
; the AL register, the new SWITCHAR in the DL register and generate an
; INT 21H.

; first the program equ statements

cr	equ	0dh		;ASCII carriage return
lf	equ	0ah		;ASCII line feed
eom	equ	'$'             ;end of message flag
				;Program Segment Prefix:
command equ	80h		;command line buffer
doscal	equ	21h		;code for dos interrupt for processing
swread	equ	3700h		;DOS call for reading switchar
swset	equ	3701h		;DOS call for setting switchar
outstr	equ	9h		;DOS call for output string

;
; CODE segment starts here
;
cseg	segment para public 'CODE'
	assume	cs:cseg,ds:data,es:data,ss:stack
;
; first check to see if proper version of DOS to execute this item
; for
;
swchar	proc	far		;entry point from PC-DOS
	push	ds		;save DS:0000 for final
	xor	ax,ax		;return to PC-DOS
	push	ax
;
; now check for parameters on the command line
;
	mov	ax,data 	;make our data segment addressable
	mov	es,ax		;via the ES register
	mov	si,offset command
	lodsb			;check string length byte,
	or	al,al		;any char present?
	jz	swc200		;no,then get current switchar
;
; examine command line, and stop if non-blank character found
; or end of line (cr)
;
swc150: 			;scan for start of char
	lodsb			;get next char
	cmp	al,cr		;if carriage return,char is missing
	je	swc200		;so jump to get current switchar
	cmp	al,' '          ;if blank, keep looking
	je	swc150
;
; a new character for the switchar
;
	mov	es:chrx,al	;save the character
	mov	ax,es		;now set DS=ES for remainder of program
	mov	ds,ax
	mov	dl,ds:chrx	;get the character for new switchar
	mov	ax,swset	; change the SWITCHAR
	int	doscal		;perform DOS call
	jmp	swc250		;tell the abuser what the char is now
;
; find the current switchar and print it out
;
				;let ES:DI = addr of name field
swc200:
	mov	ax,es		;now set DS=ES for remainder
	mov	ds,ax		;of the program.
swc250:
	mov	ax,swread	; (yes)-read SWITCHAR
	int	doscal		;call DOS to read switchar
	mov	byte ptr curch,dl  ; prepare report string
	mov	ah,outstr	; print report string
	mov	dx,offset report
	int	doscal		;make DOS call
	ret			;all done-- then return to DOS
swchar	endp

cseg	ends
;
; DATA segment starts here
;

data	segment para public 'DATA'

report	db	'SWITCHAR is '  ;Tell the user what current char is
curch	db	'X'             ;space for current switchar
	db	cr,lf,eom	;message terminator

chrx	db	0		;temp storage

data	ends

;
; STACK Segment starts here
;
stack	segment para stack 'STACK'
	db	64 dup (?)	;just something to keep things buzy
stack	ends
	end	swchar

SHAR_EOF
if test 3458 -ne "`wc -c 'swchar.asm'`"
then
	echo shar: error transmitting "'swchar.asm'" '(should have been 3458 characters)'
fi
#	End of shell archive
exit 0