home *** CD-ROM | disk | FTP | other *** search
/ ProfitPress Mega CDROM2 …eeware (MSDOS)(1992)(Eng) / ProfitPress-MegaCDROM2.B6I / UTILITY / BATCH / XSET212.ZIP / XSET.DOC < prev    next >
Encoding:
Text File  |  1992-03-04  |  12.3 KB  |  381 lines

  1.     ┌──────────────────────────────────────────────────────────────┐
  2.     │    ENHANCED  SET  INSTRUCTION 2.12  -  (C) 1992 STERN Marc   │
  3.     └──────────────────────────────────────────────────────────────┘
  4.  
  5.  
  6.     All you always wanted to put in an environment variable and
  7.  never dare to ask DOS for...
  8.  
  9.         XSET: The way to easily write efficient batch files.
  10.  
  11.  
  12.     XSET allows you to put EVERYTHING you want in a variable of
  13.  the current environment and use it as if you gave it the value with
  14.  the standard DOS command 'SET'. You will be able to write very efficient
  15.  batch files including string manipulation, calculation,...
  16.  
  17.     XSET is the more powerful environment variable manipulation
  18.  program you never saw. It also has the easiest and most intuitive
  19.  user interface it is possible to write.
  20.                                                             
  21.  
  22.  XSET is fully compatible with MS-DOS 5.0, DR-DOS 6.0, NDOS & 4DOS 4.0 .
  23.  
  24.  
  25.  
  26.  XSET has five major features:
  27.  ════════════════════════════
  28.  
  29.   - XSET permits to catch the output of any command (internal or external)
  30.     or program and put it into an environment variable.
  31.  
  32.   - XSET has several built-in commands to modify the output of a program
  33.     or a string given on the command-line (extract a part of a string,...)
  34.  
  35.   - XSET has a built-in full floating-point calculation functionalitie:
  36.                         ──────────────────────────────────────────────
  37.     You can make incremental loops, input a calculation string and
  38.     output a number,...
  39.  
  40.   - XSET can manage variable contents of more than 128 characters
  41.     (your path can now be as long as you want)
  42.  
  43.   - XSET has some other built-in commands to give you access to some
  44.     system datas (date, time, ...)
  45.  
  46.  
  47.  
  48.   * type XSET with no parameters to have the full description
  49.     of all functionalities (parameters and effects).
  50.  
  51.  
  52.  
  53.  Example of use:
  54.  ══════════════
  55.  
  56.   Rem: in all the examples, the command XSET and the its built-in commands
  57.        are typed in uppercase and the environment variables names are
  58.        in lowercase. This is only for readability; when you type it,
  59.        you may mix lowercases and uppercase as you want.
  60.        The case is only significant for arguments strings you enter on the
  61.        command-line.
  62.        The 'C:>' represents your prompt, do not type it!
  63.  
  64.  
  65.   1)      C:> XSET datvar DATE
  66.   Puts the date into the variable 'datvar'
  67.  
  68.   Type the command SET and you will see all the environment variables:
  69.           ...
  70.           COMSPEC=...
  71.           DATVAR=dd-mm-yy    (where dd,mm,yy are replaced by current
  72.                            day, month and year)
  73.           ...
  74.  
  75.   You can now use the variable 'datvar' in a batch file:
  76.           ECHO the date is %datvar%
  77.  
  78.   2)      C:> XSET name INPUT "Enter your name: "
  79.   Inputs a string from the keyboard (usual answer terminated by <Enter>)
  80.   and puts it into the variable 'name'.
  81.  
  82.   You can now use the variable 'name' in a batch file to enter
  83.   personal environment for each user:
  84.           ECHO Hello %name%, beginning the work
  85.           CD \%name%
  86.  
  87.     
  88.   3)      C:> CD | XSET dirname
  89.   Puts the output of the command 'CD' (i.e. the current directory name)
  90.   into the variable 'dirname'.
  91.  
  92.   You can write a batch file to go to another directory, execute
  93.   a program and come back into the current one
  94.  
  95.     rem ------------------
  96.  
  97.     CD | XSET dirname
  98.     CD \otherdir
  99.     myprog ...
  100.        cd %dirname%
  101.        set dirname=
  102.  
  103.        rem ------------------
  104.  
  105.  
  106.  
  107.   4)  You can write a batch file with automatic loops
  108.  
  109.  
  110.       rem ------------------
  111.  
  112.       set loop=1
  113.  
  114.         :next
  115.               if %loop% == 20 goto end
  116.  
  117.               .......
  118.               anything you want
  119.               .......
  120.  
  121.               XSET loop MATH %loop% + 1
  122.  
  123.               goto next
  124.               
  125.         :end
  126.  
  127.        rem ------------------
  128.  
  129.  
  130.   5)  You can write a batch file where the user may enter
  131.       a calculation and use it as a number
  132.  
  133.  
  134.       rem ------------------
  135.                                           
  136.       XSET calc INPUT "Enter your calculation: "
  137.  
  138.         XSET result MATH %calc%
  139.  
  140.         echo %calc% = %result%
  141.  
  142.        rem ------------------
  143.  
  144.  
  145.  
  146.  
  147.   6)  More complex example of a login procedure
  148.  
  149.           rem ---------------------- LOGIN.BAT --------------------------------
  150.  
  151.           echo off
  152.           cls
  153.  
  154.           rem    Ask login name from keyboard
  155.           rem    ----------------------------
  156.           XSET login INPUT "Enter login name : "
  157.  
  158.           rem    Test if directory corresponding to login name already exist
  159.           rem    -----------------------------------------------------------
  160.           if exist c:\%login%\nul goto LOGIN
  161.  
  162.           rem    Directory does not exist, ask to create it
  163.           rem    ------------------------------------------
  164.           echo:
  165.           echo Login '%login%' does not exist.
  166.           echo Do you want to create it? (Y/N)
  167.  
  168.           rem    Only "yYnN" keys are allowed
  169.           rem    ----------------------------
  170.           XSET ask KEY "yYnN"
  171.           XSET ask UPPER %ask%
  172.           if "%ask%" == "N" goto INPUT
  173.  
  174.           rem    Create directory
  175.           rem    ----------------
  176.           md c:\%login%
  177.  
  178.           :LOGIN
  179.           set ask=
  180.  
  181.           cd \%login%
  182.           if exist autouser.bat autouser.bat
  183.  
  184.           rem -----------------------------------------------------------------
  185.  
  186.   7)  And much more ...
  187.  
  188.  
  189.   Installation:
  190.   ════════════
  191.  
  192.      - XSET.EXE is ready to use; no installation,
  193.        but it is a SHAREWARE version.
  194.  
  195.      - To get a registered version of XSET, print the XSET.REG file,
  196.        fill it and send it to me; you will then receive the password
  197.        mandatory to use the program REGISTER.
  198.        You will receive each new upgrade for free!!!
  199.  
  200.  
  201.   Problems:
  202.   ════════
  203.  
  204.      - If the size of your environment space is not big enough,
  205.        you will receive an error message
  206.  
  207.              'XSET : not enough environment space.'
  208.                                             
  209.        This is not a bug, it is because the environment space
  210.        reserved for the variables is too small.
  211.        You must increase it by modifying the line 'SHELL=...'
  212.        in your CONFIG.SYS. By default, DOS reserves 256 bytes
  213.        environment space; this is generally insufficient.
  214.        Try 640 bytes (or more if you need it) by adding '/e:640'
  215.        at the line 'SHELL=...'
  216.  
  217.        ex:    SHELL=COMMAND.COM /E:640 /P
  218.  
  219.        
  220.        If this problem is encountered in a secondary shell
  221.        (i.e. you run the batch file from a menu that runs
  222.        a secondary shell) here is a way to work around the
  223.        problem (this is a DOS problem that could be avoided
  224.        by the program that runs the secondary shell):
  225.        
  226.        put in your AUTOEXEC.BAT a line such as:
  227.   SET TO_DELETE=something_very_long_to_be_sure_this_takes_very_much_space
  228.   
  229.        and, before using variables in the secondary shell delete this
  230.                                           ---------
  231.        variable with the command:
  232.   SET TO_DELETE=
  233.  
  234.  
  235.  
  236.  
  237.   Additional information:     32.2.427.98.52 (after 19h)
  238.   ══════════════════════   or 32.2.465.01.19
  239.  
  240.                   E-mail:     stern@mble.philips.be
  241.  
  242.  
  243.  
  244.  
  245.              Syntax:     XSET  <dosvar>  COMMAND  [args..]
  246.  
  247. Commands    Arguments    Action and value assigned to <dosvar>
  248. --------    ---------    -------------------------------------
  249.  
  250. INPUT       [prompt]     echo <prompt> and read input from standard input
  251.                          ex:  XSET name INPUT Enter your name:
  252.  
  253. PASSWD      [prompt]     same as INPUT without echoing
  254.  
  255. APPEND      {string}     old value + <string>
  256.                          ex:  XSET path APPEND ;c:\msc600\bin;c:\msc600\binb
  257.                          Rem: this allow you to bypass the 128 characters
  258.                               limit of DOS
  259.  
  260. KEY         string       key pressed (must be in <string> if not empty)
  261.                          ex:  XSET k KEY 123aAbB
  262.                               only keys 123aAbB are allowed
  263.                          ex:  XSET k KEY
  264.                               all are allowed
  265.  
  266. LENGTH      {string}     number of characters in <string>
  267.  
  268. LEFT        n {string}   the leftmost <n> characters of <string>
  269.                          ex: XSET var LEFT 3 abcdef
  270.                              puts 'abc' in variable 'var'
  271.  
  272. MID         m n {string} the <n> characters in <string> starting from the <m>th
  273.  
  274. RIGHT       n {string}   the rightmost <n> characters of <string>
  275.  
  276. UPPER       {string}     uppercase <string>
  277.  
  278. LOWER       {string}     lowercase <string>
  279.                                       
  280. CHANGE      s1 s2 {s3}   change <s1> by <s2> in <s3>
  281.  
  282. SEARCH      str1 {str2}  portion of <str1> matching <str2>
  283.  
  284.         <str2> is a UNIX-like regular expression.
  285.         A regular expression is one or more occurrences of one or more
  286.         characters.
  287.         The following symbols are treated specially:
  288.         
  289.            ^  start of line             $  end of line
  290.            .  any character             \  quote next character
  291.            *  match zero or more time preceding character (or character set)
  292.            +  match one  or more time preceding character (or character set)
  293.            [] set of characters ('^' means non-inclusion, '-' means range)
  294.  
  295.               ex: [aeiou0-9]   match a, e, i, o, u, and 0 thru 9
  296.                   [^ae0-9]     match anything but a, e and 0 thru 9
  297.                   ^a           match any line beginning by 'a'
  298.                   v$           match any line ending    by 'v'
  299.  
  300.         XSET t SEARCH "^T.*K$"        "This line will be OK"
  301.         XSET t SEARCH "^T.*[1-9].*K$" "Warning: This line will not be OK"
  302.         XSET t SEARCH "^T.*K$"        "This line will not be OK!"
  303.         XSET t SEARCH "^T.*K"         "This line will be OK!"
  304.         XSET t SEARCH "T.*K$"         "Warning: This line will be OK"
  305.  
  306.  
  307. COUNT       {string}     the number of words in <string>
  308.  
  309. WORD        n {string}   pick the <n>-th word in <string>
  310.  
  311. LINE        n            read the <n>-th line from standard input
  312.  
  313. MATH        {expr}       result of calculation of expression <expr>
  314.                          valid operators: + - * / ()   on floats
  315.                                           + - * / () %% on integers
  316.                          ex: XSET var MATH 3+(2*5) + %new%
  317.  
  318. MIN      ┌{str1...strn}    minimum or maximum of numbers or strings list
  319. MAX      └{num1...numn}    (one string may not contain <space> or <tab>)
  320.                            ex: XSET var MIN 3.6 4 9.02
  321.                            ex: XSET var MAX 3.6 4 abc 3.9j
  322.  
  323. DATE                     system date (dd-mm-yy)
  324.  
  325. DAY                      day of the month (1-31)
  326.  
  327. MONTH                    month number (1-12)
  328.  
  329. YEAR                     system year (4 digits)
  330.  
  331. DAYOFWEEK                day in the week ( 0 = sunday,... )
  332.  
  333. TIME                     system time (hh:mm:ss - 24h format)
  334.  
  335. HOUR                     system hour (0-24)
  336.  
  337. MINUTE                   system minutes (0-59)
  338.  
  339. SEC                      system seconds (0-59)
  340.  
  341. BYTEFREE    [drive]      number of bytes free on specified (or current) drive
  342.  
  343. DENSITY     [drive]      drive density (360, 720, 1200, 1440 or 0)
  344.  
  345. DIR         [drive]      current directory of <drive> or current drive
  346.  
  347. FPATH       {file}       full pathname of a filename
  348.  
  349. FDRIVE      {file}       drive of a filename
  350.  
  351. FDIR        {file}       drive & directory of a filename
  352.  
  353. FEXT        {file}       extension of a file name (no period included)
  354.  
  355. FNAME       {file}       name of a file without extension
  356.  
  357. FXNAME      {file}       name & extension of a file
  358.  
  359. FSIZE       {file}       size of a file
  360.  
  361. TRUENAME    {file}       full truename of a file
  362.  
  363.  
  364. ERRORLEVEL               errorlevel code of last command
  365.                          Rem: This command is only valid for
  366.                               - MS-DOS 3.20, 3.21, 3.30, 4.0, 4.01 & 5.0
  367.                               - NDOS 6.0
  368.                               Results are unpredictable under other OS
  369.                               or command processor like 4DOS, DR-DOS,
  370.                               PC-DOS,...
  371.                               
  372.  
  373.   [...] are optional arguments.
  374.  
  375.   If arguments {...} are missing, they are read from the standard input.
  376.   Non quoted arguments on command-line will be separated by 1 blank.
  377.  
  378.   Rem:    'XSET var'   is equivalent to  'XSET var INPUT'
  379.                                      or  'XSET var LINE 1'
  380.                    and is more performant.
  381.