home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 19 / CD_ASCQ_19_010295.iso / vrac / dosvar20.zip / DOSVAR.INF < prev    next >
Text File  |  1995-01-01  |  7KB  |  164 lines

  1.     ===========================================================================
  2.     ===========================================================================
  3.     ============================                  =============================
  4.     ============================                  =============================
  5.     ============================      DOSVAR      =============================
  6.     ============================                  =============================
  7.     ============================                  =============================
  8.     ===========================================================================
  9.     ===========================================================================
  10.  
  11.  
  12.  
  13.  
  14.  
  15.          ---------------------------------------------------------------
  16.          DOSVAR -- A Utility to Manipulate Strings in Batch (.BAT) Files
  17.          ---------------------------------------------------------------
  18.          DOSVAR is a program that will modify variables in a batch file.
  19.          It supports substrings, justification, zero-stripping and other
  20.          useful functions.
  21.          ---------------------------------------------------------------
  22.  
  23.  
  24.  
  25.                           DOSVAR is Copyright (C) 1994
  26.  
  27.  
  28.                                        by
  29.  
  30.  
  31.          Pinnacle Software, C.P. 386 Mount Royal, Quebec, Canada H3P 3C6
  32.          U.S. Office: Box 714, Airport Road, Swanton, Vermont, 05488 USA
  33.  
  34.          Support Line: (514) 345-9578 --- Free Files BBS: (514) 345-8654
  35.  
  36.  
  37.  
  38.          ---------------------------------------------------------------
  39.          This is a *SHAREWARE* product.  That means we would like you to
  40.          pass around unregistered copies to  other people.   If you have
  41.          a modem, please upload it to your favourite BBS, or give a copy
  42.          to a friend whom you think might need a program like this.
  43.          ---------------------------------------------------------------
  44.  
  45.                                                                       
  46.  
  47.  
  48.  
  49.     ===========================================================================
  50.                                Installing DOSVAR
  51.     ===========================================================================
  52.  
  53.  
  54.     If you are simply experimenting with DOSVAR, you can do so in the current
  55.     directory, using the START.BAT program to demonstrate the techniques.  For
  56.     daily use, the DOSVAR.EXE program and the associated files (such as
  57.     START.BAT) should be placed in a DOS PATH directory.  For an explanation of
  58.     the DOS PATH, see your DOS manual.
  59.  
  60.  
  61.     ===========================================================================
  62.                                 How DOSVAR Works
  63.     ===========================================================================
  64.  
  65.  
  66.     DOSVAR creates a batch file named SETVAR.BAT, which does the actual setting
  67.     of the variable.  To use DOSVAR, include it in a batch file, with the
  68.     appropriate parameters, followed by a CALL to the batch file SETVAR.BAT.
  69.     For example:
  70.  
  71.     @ECHO OFF
  72.     DOSVAR /vABCDEFG /nMYVAR /jR /o10 /c$
  73.     CALL SETVAR.BAT
  74.     ECHO Expected result: $$$ABCDEFG
  75.     ECHO Actual result:   %MYVAR%
  76.     SET MYVAR=
  77.  
  78.     The last line of the batch file sets the variable MYVAR to a null value,
  79.     which removes it from the DOS environment space.  Since the DOS environment
  80.     space is quite limited, you should take care to eliminate variables when
  81.     you are finished when them.
  82.  
  83.     In most cases you will not be manipulating a literal string (as in the
  84.     previous example).  Rather, you will be manipulating a DOS environment
  85.     variable or a batch parameter variable, as in these examples:
  86.  
  87.     @ECHO OFF
  88.     REM Demonstration using a DOS environment variable
  89.     DOSVAR /v%COMSPEC% /sL /i2 /nCSD
  90.     CALL SETVAR.BAT
  91.     ECHO The COMSPEC drive is %CSD%
  92.     SET CSD=
  93.  
  94.     @ECHO OFF
  95.     REM Demonstration using a batch parameter variable
  96.     IF NOT (%1) == () GOTO OKAY
  97.     ECHO Please specify a parameter when running this batch file
  98.     GOTO QUIT
  99.     :OKAY
  100.     DOSVAR /v%1 /nXX /jR /o10 /c$
  101.     CALL SETVAR.BAT
  102.     ECHO The right-justified version of %1 is %XX%
  103.     SET XX=
  104.     :QUIT
  105.  
  106.     For further details about batch and environment variables, refer to your
  107.     DOS manual's batch programming section.  As regards environment variables,
  108.     refer also to your DOS manual's explanation of the SET command.
  109.  
  110.  
  111.     ===========================================================================
  112.                                      Syntax
  113.     ===========================================================================
  114.  
  115.     
  116.     NOTE:  For a convenient summary of DOSVAR's syntax, type the following
  117.            command at the DOS prompt:  DOSVAR /?
  118.                        
  119.  
  120.     The format of DOSVAR is:
  121.  
  122.     DOSVAR /v<data> [settings]
  123.  
  124.     The /v parameter specifies the data to be manipulated.  This can be a
  125.     literal string (example: /vABCDE), a batch file variable (example: /v%1)
  126.     or a DOS environment variable (example: /V%PATH%).
  127.  
  128.     The optional settings are as follows:
  129.  
  130.     SETTING     DESCRIPTION                       DEFAULT VALUE
  131.     ----------  --------------------------------  ---------------------------
  132.     /n<var>     Name of variable to be SET        X
  133.     /z<Y or N>  Pre-strip leading 0's from input  No, don't pre-strip 0's
  134.     /s<action>  Substring [N]one/[L]eft/[R]ight   None (use entire string)
  135.     /i<length>  Substring length (/sL or /sR)     8
  136.     /j<action>  Justify [N]one/[L]eft/[R]ight     None (do not justify)
  137.     /o<length>  Justify length (/jL or /jR)       8
  138.     /c<char>    Character with which to justify   Space
  139.     /b<path>    Path for SETVAR.BAT               Same as DOSVAR.EXE
  140.  
  141.     The SETVAR.BAT file is usually placed in the same directory as the DOSVAR
  142.     program (DOSVAR.EXE), but you can change its location with the /b para-
  143.     meter.  Here is an example:
  144.  
  145.     DOSVAR /v%COMSPEC% /sL /i2 /bC:\MYPATH
  146.  
  147.     This would place SETVAR.BAT in the C:\MYPATH directory.
  148.  
  149.     You can also specify \b@ to indicate "current directory", as in this
  150.     example:
  151.  
  152.     DOSVAR /v%COMSPEC% /sL /i2 /b@
  153.  
  154.     This would place SETVAR.BAT in the current logged directory.
  155.  
  156.     You can check on the success or failure of DOSVAR with the IF ERRORLEVEL
  157.     facility of batch files.  DOSVAR returns 0 if it worked, or 255 if it
  158.     failed (or if the help screen was called up).  Because of the way that
  159.     the IF ERRORLEVEL statement works, you should check for a 255 rather than
  160.     a zero, since IF ERRORLEVEL 0 is ALWAYS true.
  161.  
  162.     In practice, DOSVAR should never return an errorlevel of 255.
  163.  
  164.