[comp.sys.ibm.pc] Anyone know how to discover the DOS switch character?

warren@ihlpf.ATT.COM (Montgomery) (11/03/87)

I have tried without much success to find a way of discovering from
a program what the current DOS switch character is.  I am working
with a C compiler and assembler that have no MS-DOS library support
other than what I've written for them, so knowing I can call a
library function in someone's support library doesn't help.  I need
to know at the assembly language level how to dig up the
information.

If anyone knows or knows an authoratitive source of this and other
arcane PC information, I'd appreciate a pointer in the right
direction.

-- 

Warren Montgomery ihlpf!warren

psfales@ihlpe.ATT.COM (Pete Fales) (11/06/87)

In article <2678@ihlpf.ATT.COM>, warren@ihlpf.ATT.COM (Montgomery) writes:
> I have tried without much success to find a way of discovering from
> a program what the current DOS switch character is.  I am working
> with a C compiler and assembler that have no MS-DOS library support
> other than what I've written for them, so knowing I can call a
> library function in someone's support library doesn't help.  I need
> to know at the assembly language level how to dig up the
> information.

INT 21H, Function 37H can be used to to this.  This is not supported
officially by Microsoft, but apparently is fairly widely used.  The
information has appeared on Usenet in several forms, including programs
to read and set the switch character.  The following is excerpted from
a list of undocumented DOS functions that was posted a while back:

37   Get/set option marking character (i.e. usually "/").  AL=0
     to return character in DL, 1 to set from DL. In DOS 2, also can get/set
     forced-/DEV flag (if set, /DEV/ must preceed device names; otherwise
     it is optional): AL=2 to return flag in DL, AL=3 to set from DL (0 = set,
     1 = not set).
-- 
Peter Fales		UUCP:	...ihnp4!ihlpe!psfales
			work:	(312) 979-7784
				AT&T Information Systems, IW 1Z-243
				1100 E. Warrenville Rd., IL 60566

vg55611@ihuxy.UUCP (11/12/87)

In article <2678@ihlpf.ATT.COM>, warren@ihlpf.ATT.COM (Montgomery) writes:
> I have tried without much success to find a way of discovering from
> a program what the current DOS switch character is.  I am working
> with a C compiler and assembler that have no MS-DOS library support
> 
> Warren Montgomery ihlpf!warren


Apparently the switchar can be read using INT 21H with AH=37H, AL=00H.
The switchar is returned in DL (I have not tried this).

But, why read the switchar at all ?   Just replace all occurrences of '/'
with '\' in the arg string (or the string of concern) and then the user of
your program can use either.  This is what I do with programs I write.

Venu P. Gopal
ihnp4!ihuxy!vg55611

ittfb@dcatla.UUCP (Thomas F. Blakely) (11/13/87)

In article <2257@ihuxy.ATT.COM> vg55611@ihuxy.ATT.COM (gopal) writes:
>But, why read the switchar at all ?   Just replace all occurrences of '/'
>with '\' in the arg string (or the string of concern) and then the user of
>your program can use either.  This is what I do with programs I write.

This is not a good idea.  You are replacing _potential_ switch characters
with the _path-separator_ character.  Also, it limits you to those two
characters.  Someone may want to use something obscure (like '-' :-).

Using something unique from the path character allows command line
constructs like:

    command/sw1/sw2 arg1/asw1 arg2/asw2

This allows global options (sw1, sw2) and options specific to each argument
(asw1, asw2).  We have a lot of users here used to VMS, and this is real
handy.  If you just replace all '/' with '\', argv[0] looks like:

    /root/bin/command/sw1/sw2

This is a not very clean parse.  Besides, DOS function 37H works, and it's
actually easier to call it than to have to massage the command arguments.

T. Blakely
(404)442-4866
{gatech, sun!sunatl}!dcatla!ittfb

psfales@ihlpe.ATT.COM (Pete Fales) (11/13/87)

In article <2257@ihuxy.ATT.COM>, vg55611@ihuxy.ATT.COM (gopal) writes:
> In article <2678@ihlpf.ATT.COM>, warren@ihlpf.ATT.COM (Montgomery) writes:
> > I have tried without much success to find a way of discovering from
> > a program what the current DOS switch character is.  I am working
> > with a C compiler and assembler that have no MS-DOS library support
> 
> But, why read the switchar at all ?   Just replace all occurrences of '/'
> with '\' in the arg string (or the string of concern) and then the user of
> your program can use either.  This is what I do with programs I write.

I'll speak for Warren (hope  that's OK) since I have run into this problem
before.  Many programs allow the user to invoke a COMMAND.COM "subshell"
to execute DOS commands.  They do this by internally executing 
COMMAND.COM /C which works fine unless you have changed the switch
character.  I am fond enough of '-' as my switch char that I have
gone into several programs with DEBUG to change the /C to -C.
-- 
Peter Fales		UUCP:	...ihnp4!ihlpe!psfales
			work:	(312) 979-7784
				AT&T Information Systems, IW 1Z-243
				1100 E. Warrenville Rd., IL 60566

roth@mrsvr.UUCP (Dean Roth) (11/13/87)

PC/MS DOS file functions do not care if '/' or '\' is used:
either may be used. Only the command interpreter (COMMAND.COM)
wants '\' in file paths.

dennis@rlgvax.UUCP (Dennis.Bednar) (11/13/87)

In article <2257@ihuxy.ATT.COM>, vg55611@ihuxy.ATT.COM (gopal) writes:
> But, why read the switchar at all ?   Just replace all occurrences of '/'
> with '\' in the arg string (or the string of concern) and then the user of
> your program can use either.  This is what I do with programs I write.

Am I missing something?  If I ran the command
	comx /s b:\dir\file.c
then your program (comx) internally does this:
	comx \s b:\dir\file.c
before it does any real processing (based on what you have said).
Now, how can you tell if \s is a switch or a file?  It seems
that you cannot, that is, it would be ambiguous.

-- 
FullName:	Dennis Bednar
UUCP:		{uunet|sundc}!rlgvax!dennis
USMail:		CCI; 11490 Commerce Park Dr.; Reston VA 22091
Telephone:	+1 703 648 3300

paula@bcsaic.UUCP (Paul Allen) (11/17/87)

In article <2678@ihlpf.ATT.COM>, warren@ihlpf.ATT.COM (Montgomery) asked
for help in getting the value of the DOS switch character.

In article <2257@ihuxy.ATT.COM>, vg55611@ihuxy.ATT.COM (gopal) wrote:
>Apparently the switchar can be read using INT 21H with AH=37H, AL=00H.
>The switchar is returned in DL (I have not tried this).
>
>But, why read the switchar at all ?   Just replace all occurrences of '/'
>with '\' in the arg string (or the string of concern) and then the user of
>your program can use either.  This is what I do with programs I write.
>
>Venu P. Gopal
>ihnp4!ihuxy!vg55611

This is fine for pathnames, but you need to know the switch character if
you are going to exec a program that expects switches.  I run with the
switch character set to '-', and I also use Don Kneller's excellent
ndmake program.  My old version of ndmake executes command.com with the
/C switch.  It refused to work on my system until I used debug to change
the '/' into '-'.  If ndmake had checked the switch character and
invoked command.com appropriatly, I wouldn't have had a problem.
Perhaps Don's recent 4.3 version checks the switch character.  I haven't
had time to find out.

By the way, I think it would be nice if *all* programs checked the
switch character, including &%!# MS LINK.  Does anybody know of a
version of DOS that does *not* support changing the switch character?

Paul

-- 
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Paul L. Allen                       | paula@boeing.com
Boeing Advanced Technology Center   | ...!uw-beaver!ssc-vax!bcsaic!paula