[comp.sys.ibm.pc] switchar

davidr@hplsla.HP.COM ( David Reed) (12/02/86)

My understanding (and experience):

SWITCHAR  is  indeed  used  to  modify  DOS so as to be  able  to use  another
character instead of the backslash as directory separator, allowing the use of
an alternate  character to preceed  parameters.   For example, since I use the
unix system alot, I have used SWITCHAR  specifying the slash as path separator
and thereby had the hyphen recognized by DOS for parameter options, as in:
                         DIR C:/UTIL/*.COM -P

My copy of SWITCHAR was created by me on my system from typing in what I found
in a magazine.  I remember  there was a comment that the program was utilizing
an  undocumented  DOS  function.  The program  works on my computer with MSDOS
2.11, but will not work with the  computer  I have  running  MSDOS  3.1, and I
suspected  (without doing any checking) that the  undocumeted  function was no
longer available.

-David M. Reed      hplsla!davidr

gritz@homxb.UUCP (R.SHARPLES) (12/09/86)

You can also use the dos ansi.sys capability to redefine the
character transmitted by the keyboard when you hit / or \.  This
can be done by echoing the proper ESC sequence in autoexec.  Since
this is just redefining the keyboard signal, it does not effect programs
that utilitze the original sequence.  I know this works under MSDOS 3.1.
See page G-10 of the MSDOS 3.1 manual.

Russ Sharples
homxb!gritz

nather@ut-sally.UUCP (Ed Nather) (12/09/86)

In article <2690001@hplsla.HP.COM>, davidr@hplsla.HP.COM (      David Reed) writes:
> SWITCHAR  is  indeed  used  to  modify  DOS so as to be  able  to use  another
> character instead of the backslash as directory separator, [...]
> The program  works on my computer with MSDOS
> 2.11, but will not work with the  computer  I have  running  MSDOS  3.1, and I
> suspected  (without doing any checking) that the  undocumeted  function was no
> longer available.

You should have checked.  A call to Dos function 37 returns the current
value of SWITCHAR  (with AX == 0) and the same function call can be used to 
change it (with AX == 1).  It works on DOS 2.x and 3.x, all versions.  

Here is a very short assembly language program that sets SWITCHAR to "\" so
the "/" can be used as a path separator.  The modified DOS works with all
programs EXCEPT MICROSOFT'S LIB utility routine, which insists "\" is the
only legitimate path separator.

-------------------------------------------------------------------------

cseg    segment para public 'code'
        assume cs:cseg,ds:cseg,es:cseg,ss:cseg

org     100h

ent     proc near
        MOV DL,'\'      ; DL was slash, change it to backslash
        MOV AX,3701h    ; AH=CharOper, AL=Set it
        INT 21h         ; DOS Command
        RET
ent     endp
cseg    ends
        end ent

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

madd@bucsb.bu.edu.UUCP (12/10/86)

In article <2234@homxb.UUCP> gritz@homxb.UUCP (R.SHARPLES) writes:
>You can also use the dos ansi.sys capability to redefine the
>character transmitted by the keyboard when you hit / or \.  This
>can be done by echoing the proper ESC sequence in autoexec.  Since
>this is just redefining the keyboard signal, it does not effect programs
>that utilitze the original sequence.  I know this works under MSDOS 3.1.
>See page G-10 of the MSDOS 3.1 manual.

Don't do this!  This works fine, provided you only use the DOS
COMMAND.COM.  If you use any program that skips around the standard
DOS functions, this won't work.  If you (*gasp*) use a program, such
as a wordprocessor, which DOESN'T skip around the DOS functions, it'll
go change all your characters on you, even if you didn't want them to.

For instance, let's say I use WordStar (which I think can be
influenced by ANSI.SYS, though I never tried -- the screen output is
slow enough to be done through DOS, versus writing to the screen
buffer and other neat things).  I start typing:

Ladies/gentlemen of the press:

Now, what gets put in the file would be

Ladies\gentlemen of the press:

which is not what I intended.  Worse, what if you program in a similar
editor:

#include <stdio.h>

main()
{ int i;

  fscanf("%d",i);
  printf("i = %d\n",i);
  i = i/2;
  printf("i = %d\n");
  printf("As a further example, what if you do this: yes/no\n");
}

What get stuffed in the file?  This:

#include <stdio.h>

main()
{ int i;

  fscanf("%d",i);
  printf("i = %d\n",i);
  i = i\2;              /* compile error right here */
  printf("i = %d\n");   /* run-time problem below   */
  printf("As a further example, what if you do this: yes\no\n");
}

The flipping of the / character would really cause problems here, some
of which might not be easy to spot.  The last printf() statement is a
tough one.  It would print:

As a further axample, what if you do this: yes
o

Which is obviously not what was intended.

In conclusion, this idea would work (some of the time) but can have
side-effects that are extremely annoying; I'd stay away from it.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
                   - Jim Frost * The Madd Hacker -
UUCP:  ..!harvard!bu-cs!bucsb!madd | ARPANET: madd@bucsb.bu.edu
CSNET: madd%bucsb@bu-cs            | BITNET:  cscc71c@bostonu
-------------------------------+---+------------------------------------
"Oh beer, oh beer." -- Me      |      [=(BEER) <- Bud the Beer (cheers!)

gritz@homxb.UUCP (12/11/86)

In article <656@bucsb.bu.edu.UUCP>, madd@bucsb.bu.edu.UUCP writes:
> In article <2234@homxb.UUCP> gritz@homxb.UUCP (R.SHARPLES) writes:
> >You can also use the dos ansi.sys capability to redefine the
> >character transmitted by the keyboard when you hit / or \.  This
> >can be done by echoing the proper ESC sequence in autoexec.  Since
> >this is just redefining the keyboard signal, it does not effect programs
> >that utilitze the original sequence.  I know this works under MSDOS 3.1.
> >See page G-10 of the MSDOS 3.1 manual.
> 
> Don't do this!  This works fine, provided you only use the DOS
> COMMAND.COM.  If you use any program that skips around the standard
> DOS functions, this won't work.  If you (*gasp*) use a program, such
> as a wordprocessor, which DOESN'T skip around the DOS functions, it'll
> go change all your characters on you, even if you didn't want them to.
> 
Yes, it will change all your characters on you but it will echo the changed
characters to the screen.  If you use the echo commands above and type:
	"cd /dir1/dir2"
DOS will echo
	"cd \dir1\dir2"
and correctly execute the command.  In the same way, a wordprocessor will
also echo "\" to the screen and place it in the buffer when "/" is typed.
It is just as if you phyiscally moved and rewired the keys.  As long as
you check on the screen what you type you should be alright.  Programs
that read the keyboard directly are not effected of course.

Russ Sharples
homxb!gritz

jeff@gistdev.UUCP (01/23/89)

John C. Dvorak is also known for not researching information thoroughly
before writing a full page on it in PC Magazine.  Most recently he wrote
about the Chang Modification of a PC/AT clone motherboard to make it run
at 40 MHz or something like that.  Apparently, they just altered the real
time clock oscillator so that timing measurements from benchmarks were
wrong. 

I agree that he loves to be controversial and is an eternal IBM basher,
however, IBM did give him several things to pounce on like refusing to pick
up the check.  Even our PR people pay for luncheons.  Talk about CHEAP.  Is
the Micro Channel doing that poorly?

*-----*
Jeff Johnson	Global Information Systems Technology, Inc.
1800 Woodfield Drive	Savoy, IL  61874	(217) 352-1165

INTERNET: jeff%gistdev@uxc.cso.uiuc.edu
UUCP:     {uunet,pur-ee,convex}!uiucuxc!gistdev!jeff

"I said what I said, and my employer did not."

mcdonald@uxe.cso.uiuc.edu (01/23/89)

>I agree that he loves to be controversial and is an eternal IBM basher,
>however, IBM did give him several things to pounce on like refusing to pick
>up the check.  Even our PR people pay for luncheons.  Talk about CHEAP.  Is
>the Micro Channel doing that poorly?

Yes, the MicroChannel is doing poorly - we have to buy clones
instead of Model 80's because nobody makes cards for the MicroChannel.
No big screen displays. No multichannel scalars. Nothing interesting at
all.

Of course, if IBM HAD just picked up the bill, Dvorak would have
said that IBM was trying to bribe him into saying something good
about the Microchannel.