[net.micro.pc] DOS funtion 37H

rosen@mtgzz.UUCP (t.rosenfeld) (10/29/86)

Can anyone tell me what DOS function 37H does? I saw it used in the
SWITCHAR.COM patch, but I don't see it in any of my manuals?

Thanks in advance

-- 
----------------
Thomas Rosenfeld 
		@ AT&T Information Systems Labs, Middletown, NJ
		(201) 957-5867
		
		UUCP:		{harpo,ihnp4,burl,akgua}!mtgzz!rosen

Disclaimer: I don't claim anything.

iav1917@ritcv.UUCP ([alan i. vymetalik]) (10/31/86)

In article <2234@mtgzz.UUCP> rosen@mtgzz.UUCP (t.rosenfeld) writes:
>Can anyone tell me what DOS function 37H does? I saw it used in the
>SWITCHAR.COM patch, but I don't see it in any of my manuals?
>
>Thanks in advance
>Thomas Rosenfeld 
>@ AT&T Information Systems Labs, Middletown, NJ


   Ok net-land, here's another demo of the (in)famous 37h function ...

   The DOS 37h function has circulated around for a while.  I dug this
   out of a program I wrote a while back. I added a quick main program
   to demo the functions.  Should work fine with DOS 2.05 and up.

   The program segments demonstrate the use of MS/PC-DOS function 37h
   which can be used to view or alter the "switch character" (the Un*x-
   like parameter indicator) used by various DOS functions and programs
   that receive data from the command line when invoked.

   Be careful in using the function since many DOS functions and programs
   may become 'confused' or may error when the switch character is not
   what is expected.   There is a reason that it is undocumented ....

   enjoy,

   Alan

   "I can't claim anything...The d*mn*d IRS would find a way to tax it!"
   =================================================
                                   alan i. vymetalik
   uucp:    {allegra,seismo}!rochester!ritcv!iav1917
   =================================================

   ---- SOURCE FOLLOWS ---------------------------------------------


{
    DOS 37h routines.  These routines utilize the 'MsDos' function
    of Turbo to pass data to the DOS functions and 'ParamStr(1)' which
    retrieves the first parameter from the command line when the
    compiled program is executed.  Please note values set in the
    AL register before calling DOS.
}

type

   { required DOS interrupt record - See Turbo Pascal manual }
   DOSRegPack = record
                   case integer of
                      1 : (AX,BX,CX,DX,BP,SI,DI,DS,ES,FLAGS: integer);
                      2 : (AL,AH,BL,BH,CL,CH,DL,DH : byte);
                   end;

var
   regpack  : DOSRegPack;       { used for interrupts to DOS }


{
   -----------------------------------------------------
   Function  - CurrentSwitchCharacter

   Arguments -
       Input : none
      Output : single character, the "switch character"
   -----------------------------------------------------
}

function CurrentSwitchCharacter : char;

begin

   regpack.AH := $37;
   regpack.AL := $00;
   msdos(regpack);

   CurrentSwitchCharacter := chr(regpack.DL)

end;


{
   -----------------------------------------------------
   Procedure  - SetSwitchCharacter

   Arguments  -
       Input  : any single ASCII character
      Output  : none
   -----------------------------------------------------
}

procedure SetSwitchCharacter ( new_switch : char );

begin

   regpack.AH := $37;
   regpack.AL := $01;
   regpack.DX := ord(new_switch);

   msdos(regpack)

end;


begin { main program }

   writeln('The switchar is "',CurrentSwitchCharacter,'"');

   if length(paramstr(1)) <> 1 then
      writeln('Switch character can only be a single character')
   else
      begin
         SetSwitchCharacter(paramstr(1));
         writeln('Switchar is now "',paramstr(1),'"');
      end

end. { main program }