[net.micro.pc] Changing the MSDOS option character

svirsky@ttidcb.UUCP (William Svirsky) (09/25/85)

>Alternatively, try opening "c:/usr/text/things.txt".  MSDOS itself understands
>'/' as a directory seperator just as well as '\\'.  Too bad microsoft opted to
>use '/' as the option introducer character for command line parsing.  On the
>other hand, Thank goodness microsoft left the back door open and allows me to
>change the option character to '-'.  At least in MSDOS 2.XX.

How do you change the option character to '-'?  If you can do this is it also
possible to change the '\\' directory separator to '/'?  Thanks.

Bill Svirsky

bet@ecsvax.UUCP (Bennett E. Todd III) (09/25/85)

In article <458@ttidcb.UUCP> svirsky@ttidcb.UUCP (William Svirsky) writes:
>How do you change the option character to '-'?  If you can do this is it also
>possible to change the '\\' directory separator to '/'?  Thanks.

It's easy to change the switch character ("switchar" in MS-DOS parlance)
to anything you like; '-' is particularly handy, for conformance with
UNIX. As long as the switchar isn't '/' DOS will take either '\' or '/'
as the pathname separator. Here's a quick little program to display or
set the switchar. It's written in DeSmet C using inline assembler for
the DOS function call; it should be easy to use the assembler code with
other compilers and the MS-DOS assembler.
---------- switchar.c -- tabs set every 4 columns ---
/*
 * switchar [c]
 * With no arguments, displays the switch character
 * With an argument 'c', sets the switch character to 'c'
 */

main(argc, argv)
int argc;
char **argv;
{
	if (argc == 1)
		printf("switchar=%c\n", getswitchar());
	else
		setswitchar(argv[1][0]);
}

getswitchar()
{
#asm
	mov		ax,3700h
	int		21h
	mov		al,dl
	xor		ah,ah
#
}

setswitchar(c)
char c; /* BP+4 */
{
#asm
	mov		ax,3701h
	mov		dx,[bp+4]
	int		21h
#
}
------------- end of switchar.c -------------
-Bennett
-- 

"Hypocrisy is the vaseline of social intercourse." (Who said that?)

Bennett Todd -- Duke Computation Center, Durham, NC 27706-7756; (919) 684-3695
UUCP: ...{decvax,seismo,philabs,ihnp4,akgua}!mcnc!ecsvax!duccpc!bet

lauren@vortex.UUCP (Lauren Weinstein) (09/29/85)

The MSDOS "option character" (switchar) can be changed in a manner that
has been described numerous times in this group.  I won't go into
it again here.  But note that the MSDOS filename-oriented system
calls ALREADY accept both '\' and '/' in pathnames, regardless of
switchar settings.  So unless a compiler is braindamaged, you should
already be able to use syntax like:

fopen("c:/foo/bar" ... 

without difficulty.

--Lauren--

nather@utastro.UUCP (Ed Nather) (10/02/85)

> So unless a compiler is braindamaged, you should
> already be able to use syntax like:
> 
> fopen("c:/foo/bar" ... 
> 
> without difficulty.
> 
> --Lauren--

By this definition, the Microsoft C v3.0 compiler is braindamaged,
if the pathname string has been obtained by wildcard expansion on the
command line.

And they wrote both Xenix and MS-DOS.

Is there no hope?

-- 
Ed Nather
Astronomy Dept, U of Texas @ Austin
{allegra,ihnp4}!{noao,ut-sally}!utastro!nather
nather@astro.UTEXAS.EDU