home *** CD-ROM | disk | FTP | other *** search
/ ftp.barnyard.co.uk / 2015.02.ftp.barnyard.co.uk.tar / ftp.barnyard.co.uk / cpm / walnut-creek-CDROM / BEEHIVE / OS / CONIX2.LBR / CHAPTER6.DQC / CHAPTER6.DOC
Text File  |  2000-06-30  |  14KB  |  529 lines

  1.  
  2.  
  3.  
  4.  
  5.                   Chapter 6    - Variables
  6.  
  7.  
  8.     Descriptions and  usage     info  of  the    different  variable  types
  9.     (Disk-Based, Hex, Memory), invoking commands by    using variables    as
  10.     aliases,   force-interpreting    of   special   characters   within
  11.     variables,  matching  a     file  pattern for command line    expansion,
  12.     function  keys    using  disk-based  variables,    and   programmable
  13.     character keys for special keyboard definitions.
  14.  
  15.  
  16.                    - CONTENTS -
  17.     __________________________________________________________________
  18.  
  19.  
  20.       6.  Variables..............................................  6-1
  21.  
  22.         6.1     Disk-Based Variables................................  6-1
  23.  
  24.         6.2     Hexadecimal Variables...............................  6-4
  25.  
  26.         6.3     Memory    Variables....................................  6-4
  27.  
  28.         6.4     Filename Expansion..................................  6-5
  29.  
  30.         6.5     Programmable Function Keys..........................  6-6
  31.  
  32.         6.6     Programmable Character    Keys.........................  6-6
  33.  
  34.         6.7     Notes...............................................  6-7
  35.  
  36.  
  37.  
  38.  
  39.  
  40.  
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.                       -    i -
  63.  
  64.  
  65.  
  66.  
  67.  
  68.     ConIX Operating    System                     Variables
  69.  
  70.     6.  Variables
  71.  
  72.     ConIX provides many different types of variables which can be used
  73.     to programmably    include    text on    the command line.  Wherever a
  74.     variable is referenced on the command line, the    characters it
  75.     contains will be substituted in    place of the reference,    as if they
  76.     had been typed by the user.  The only difference is that special
  77.     characters (double quotes, command separators, and variable
  78.     references) which appear within    a variable will    not be recognized
  79.     as being special by the    Command    Line Processor.     We will describe
  80.     a method of getting around this    limitation in a    following section.
  81.  
  82.     Variables are referenced by preceding their name with the dollar-
  83.     sign character,    `$'.  If an invalid variable reference is given,
  84.     the dollar-sign    itself will be included    as an actual character on
  85.     the command line.  If a    variable does not contain any text, no
  86.     characters will    be included on the command line    when it    is
  87.     referenced.  The different types of variables and their    usages
  88.     will be    described in the sections that follow.
  89.  
  90.  
  91.     6.1  Disk-Based    Variables
  92.  
  93.     ConIX provides 52 disk-based variables,    each of    which can be used
  94.     to hold    up to 255 characters.  Because they are    stored on disk (in
  95.     the file A:0/VARS.SET),    their contents will remain even    after a
  96.     reset or a power down.    These variables    are referenced as $a, $b,
  97.     $c, . .    . $z and $A, $B, $C, . . . $Z, for a total of 52
  98.     variables.  The    only difference    between    these two sets is the case
  99.     of the variable    letter.     Care should be    taken to make sure that
  100.     lowercase variables are    properly referenced so they will not be
  101.     mapped to uppercase on the command line.
  102.  
  103.     The contents of    the disk variables may be modified by the SET and
  104.     = (Equals) commands, which are described in detail in the commands
  105.     section.  For the purpose of providing examples    of variable usage,
  106.     we will    describe a simple form of the SET command in the
  107.     paragraphs to follow.
  108.  
  109.     The syntax of the SET command is:
  110.  
  111.         <A:00> set <variable> =    (value)
  112.  
  113.     where variable is a single letter describing the disk variable
  114.     (a-z or    A-Z) and value is a single argument which will be assigned
  115.     as the contents    of the specified variable.  For    example, the
  116.     command    line:
  117.  
  118.         <A:00> set a = "Hello there!"
  119.  
  120.     will set the variable `$A' (remember that `a' got mapped to an
  121.     `A') to    the string ``Hello there!''.  The double quotes    are
  122.     required in order to get the two words into the    single argument
  123.     required by SET.  These    quotes only serve to create an argument,
  124.     and are    not entered into the variable's    value string.  If you
  125.  
  126.  
  127.  
  128.                        6-1
  129.  
  130.  
  131.  
  132.  
  133.  
  134.     Variables                    ConIX Operating System
  135.  
  136.     would want quotes in the value,    they must be preceded by a
  137.     backslash (as was described earlier).
  138.  
  139.     To reference a variable    on the command line, for example, as the
  140.     argument to the    program    ECHO, type:
  141.  
  142.         <A:00> echo $a
  143.         HELLO THERE!
  144.         <A:00>
  145.  
  146.     which is the same as if    you would have typed:
  147.  
  148.         <A:00> echo Hello there!
  149.         HELLO THERE!
  150.         <A:00>
  151.  
  152.     Notice how the contents    of `$A'    were mapped to uppercase, although
  153.     it contains the    upper and lowercase characters that were entered
  154.     by SET.     This operation    can be defeated    by putting quotes around
  155.     the variable, as:
  156.  
  157.         <A:00> echo "$A"
  158.         Hello there!
  159.         <A:00>
  160.  
  161.     The operation of the quotes is the same    with variables as with any
  162.     characters entered directly on the command line.  Notice that the
  163.     variable reference was made as "$A" since we were previously
  164.     relying    upon ConIX to map the `a' character to uppercase.  When    in
  165.     quotes,    "$a" would reference a different variable `$a' since no
  166.     uppercase mapping takes    place.
  167.  
  168.     It is important    to realize that    the variable substitution occurs
  169.     before the specified command or    program    executes.  This    definition
  170.     is most    essential in understanding why:
  171.  
  172.         <A:00> set a = "echo $A"
  173.  
  174.     causes the variable `$A' to contain the    character string
  175.     ``echo Hello there!''.    Since the reference is expanded    before the
  176.     SET command executes, we may set a variable to itself plus another
  177.     variable or string.
  178.  
  179.     If we examine this new `$A' as before, we'd get:
  180.  
  181.         <A:00> echo "$A"
  182.         echo Hello there!
  183.         <A:00>
  184.  
  185.     since the variable itself contains the word ``echo''.  As a next
  186.     step in    understanding variables, you can type:
  187.  
  188.  
  189.  
  190.  
  191.  
  192.  
  193.  
  194.                        6-2
  195.  
  196.  
  197.  
  198.  
  199.  
  200.     ConIX Operating    System                     Variables
  201.  
  202.         <A:00> $a
  203.         HELLO THERE!
  204.         <A:00>
  205.  
  206.     where the entire contents of the variable acts as the command
  207.     line.  This is exactly as if you would have manually typed:
  208.  
  209.         <A:00> echo Hello there!
  210.         HELLO THERE!
  211.         <A:00>
  212.  
  213.     Using variables    in this    way, complex command strings may be
  214.     recalled and executed with only    two keystrokes.     For example, if
  215.     we set `$A' as:
  216.  
  217.         <A:00> set a = "exec dir; era foo.asm; ed foo.asm"
  218.  
  219.     we could run that entire command list as:
  220.  
  221.         <A:00> $a
  222.              .
  223.              .    displays the directory
  224.              .
  225.              .    erases "FOO.ASM"
  226.              .
  227.              .    invokes    an editor on "FOO.ASM"
  228.              .
  229.         <A:00>
  230.  
  231.     The EXEC command was necessary to cause    the interpretation of the
  232.     semicolon character within the variable.  If this command was
  233.     excluded, ConIX    would try to execute a command `DIR;' which does
  234.     not exist.  The    reason is that ConIX does not parse the    contents
  235.     of the variable, and places it onto the    command    line as-is.  The
  236.     EXEC command causes the    command    line to    be reparsed after the
  237.     variable substitution is performed.
  238.  
  239.     Note that if `$A' had been referenced within double quotes as
  240.     "$A", the entire contents of the variable would    be placed into the
  241.     zero'th    argument, namely the command string.  This would produce
  242.     an error since there is    no such    command    as "exec dir; era foo.asm;
  243.     ed foo.asm".  Furthermore, we enclosed the value argument string
  244.     in quotes above    because    SET only takes the first argument as the
  245.     variable's value.  We also do not want ConIX to    interpret any of
  246.     the separation characters within the string.  If we left out the
  247.     quotes by mistake, as with:
  248.  
  249.  
  250.  
  251.  
  252.  
  253.  
  254.  
  255.  
  256.  
  257.  
  258.  
  259.  
  260.                        6-3
  261.  
  262.  
  263.  
  264.  
  265.  
  266.     Variables                    ConIX Operating System
  267.  
  268.         <A:00> set a = exec dir; era foo.asm; ed foo.asm
  269.              .
  270.              .    sets $A    to "EXEC" (DIR is lost)
  271.              .
  272.              .    erases "FOO.ASM"
  273.              .
  274.              .    invokes    an editor on "FOO.ASM"
  275.              .
  276.         <A:00>
  277.  
  278.     we would clearly not get the desired result because ConIX,
  279.     rightfully so, interpreted the semicolons as indicating    the end    of
  280.     a command.
  281.  
  282.  
  283.     6.2  Hexadecimal Variables
  284.  
  285.     The Hexadecimal    Variables are mainly used for passing data from
  286.     internal commands to the command line environment.  There are 16
  287.     such variables,    each of    which can hold a single    byte value from    00
  288.     to FF.    They are referenced as $$0, $$1, $$2, .    . . $$F.  In
  289.     practice, only a few of    these variables    are utilized by    internal
  290.     commands, although they    all may    be set explicitly with the SHX
  291.     command.  The manual description for each command will tell you
  292.     which hex variables, if    any, will be modified by its execution.
  293.  
  294.  
  295.     6.3  Memory Variables
  296.  
  297.     The contents of    the ConIX Memory Variables are stored in system
  298.     memory,    and may    be as large as available memory    permits.  They are
  299.     lightning fast,    and are    used primarily to store    temporary data,    as
  300.     memory itself is temporary by definition.  They    are referenced as:
  301.  
  302.         $@(&address)
  303.  
  304.     where address is the optional 16-bit hexadecimal address at which
  305.     the data is located.  This data    is may be stored by many ConIX
  306.     functions, as described    throughout this    manual.     The data is
  307.     usually    terminated by the value    FF hex,    and the    contents of the
  308.     variable will be substituted onto the command line until that
  309.     point.    For example, the command:
  310.  
  311.         <A:00> echo $@37f0
  312.  
  313.     passes to ECHO the string of characters    stored in memory beginning
  314.     at location 37F0 hex until the FF hex terminator byte.
  315.  
  316.     If no address is given,    $@ references the contents of the default
  317.     memory buffer.    This buffer can    store up to 128    characters, and    is
  318.     located    within the system memory occupied by ConIX.
  319.  
  320.  
  321.  
  322.  
  323.  
  324.  
  325.  
  326.                        6-4
  327.  
  328.  
  329.  
  330.  
  331.  
  332.     ConIX Operating    System                     Variables
  333.  
  334.     6.4  Filename Expansion
  335.  
  336.     Filename Expansion provides the    user with the convenience of
  337.     referencing a common group of filenames    without    having to type
  338.     them individually on the command line.    The syntax of this feature
  339.     is:
  340.  
  341.         *:(:)(/)<pattern>
  342.  
  343.     The sequence `*:' indicates the    start of a filename expansion
  344.     string.     The names of all files    matching the given pattern for
  345.     FILE.EXT will be placed    onto the command line in place of the
  346.     pattern    which may contain the `?' and `*' characters, as
  347.     conforming with    standard CP/M pattern matching.
  348.  
  349.     If the optional    `:' is used, the matched filenames will    be
  350.     preceded with the disk code (A:    - P:) corresponding to the disk    on
  351.     which they were    found.    If the optional    `/' is used, the user area
  352.     will be    included.  Both    may be combined    as `:/'    to include both
  353.     disk and user areas.
  354.  
  355.     To illustrate this feature we will provide some    examples:
  356.  
  357.     Assuming the disk directory contained four files:  FOO.ASM,
  358.     FOO.COM    BAR.ASM, BAR.COM you could type:
  359.  
  360.         <A:00> echo *:*.*
  361.         FOO.ASM    FOO.COM    BAR.ASM    BAR.COM
  362.         <A:00>
  363.  
  364.     where all the files residing in    the current directory are matched
  365.     and their names    substituted onto the command line.  You    may use
  366.     more complex patterns, as:
  367.  
  368.         <A:00> echo *:foo.*
  369.         FOO.ASM    FOO.COM
  370.         <A:00>
  371.  
  372.     which only matches files whose names begin with    `FOO.',    or:
  373.  
  374.         <A:00> echo *:*.asm
  375.         FOO.ASM    BAR.ASM
  376.         <A:00>
  377.  
  378.     which only matches files with names ending in `.ASM'.  Use:
  379.  
  380.         <A:00> echo *::/*.asm
  381.         A:00/FOO.ASM A:00/BAR.ASM
  382.         <A:00>
  383.  
  384.     to include the disk and    user area with the filenames.
  385.  
  386.  
  387.  
  388.  
  389.  
  390.  
  391.  
  392.                        6-5
  393.  
  394.  
  395.  
  396.  
  397.  
  398.     Variables                    ConIX Operating System
  399.  
  400.     6.5  Programmable Function Keys
  401.  
  402.     ConIX takes the    concept    of variables a bit further by allowing you
  403.     to reference any of the    52 Disk-Based Variables    while working
  404.     within a running program.  Their contents can be recalled into the
  405.     actual input of    the program, just like conventional function keys
  406.     found on many fancy terminals.
  407.  
  408.     At any point while running your    program, simply    type a special
  409.     lead-in    control    sequence followed by the single    character
  410.     corresponding to the variable you want to access ($a-z,    $A-Z).
  411.     The contents of    the corresponding variable will    appear on your
  412.     screen as if you would have typed it there manually.  By default,
  413.     the lead-in character is not set, so as    to prevent conflicts with
  414.     special    control    sequences that are being used at a particular
  415.     installation.  We recommend setting the    lead-in    to CTRL-F by using
  416.     the OPT    +/-FK internal command,    as:
  417.  
  418.         <A:00> opt +fk '^f
  419.  
  420.     If CTRL-F is undesirable, any control sequence not already defined
  421.     within ConIX can be used.
  422.  
  423.  
  424.     6.6  Programmable Character Keys
  425.  
  426.     ConIX requires many special characters for use with different
  427.     built-in features.  Because not    all computers have these
  428.     characters available on    their keyboard,    ConIX provides a way for
  429.     you to type every possible ASCII character.
  430.  
  431.     Programmable Character Keys provide a simple and convenient method
  432.     of entering obscure characters,    not only to ConIX, but also to any
  433.     running    program.  You can define up to 24 such keys, each of which
  434.     can produce any    desired    ASCII character.  These    keys may be
  435.     accessed in the    same manner as the regular Programmable    Function
  436.     Keys.  Just type the special lead-in character,    and follow it with
  437.     the single letter which    corresponds to the character you want to
  438.     type.  That character will appear on the screen    just as    if it was
  439.     entered    directly by hitting a dedicated    key on the keyboard.
  440.  
  441.     By default, the    lead-in    is not set so as to prevent possible
  442.     conflicts.  We recommend using CTRL-K, which may be set    via the
  443.     OPT +/-FC internal command as:
  444.  
  445.         <A:00> opt +fc '^k
  446.  
  447.     Some of    the keys have been preset to produce certain characters
  448.     which are usually not found on some older-style    keyboards.  For
  449.     example    `b' is set to produce a    backslash by simply typing <CTRL-
  450.     K>b.  See the OPT internal command in the commands section for a
  451.     listing    of their preset    values and how they may    be redefined or
  452.     modified to include additional characters.
  453.  
  454.  
  455.  
  456.  
  457.  
  458.                        6-6
  459.  
  460.  
  461.  
  462.  
  463.  
  464.     ConIX Operating    System                     Variables
  465.  
  466.     6.7  Notes
  467.  
  468.     Since the dollar-sign is hard-coded as the lead-in for all command
  469.     line variable references, certain oddities can be produced by
  470.     unsuspecting users.  For example, the command:
  471.  
  472.         <A:00> stat file.ext $r/o
  473.  
  474.     will not execute as expected, but rather as:
  475.  
  476.         <A:00> STAT FILE.EXT <variable $R>/O
  477.  
  478.     where the contents of disk-based variable $R will be substituted
  479.     in place of the    reference `$r'.     Preceding the dollar-sign with    a
  480.     backslash will defeat the automatic interpretation of the `$' as
  481.     indicating the start of    a variable reference.
  482.  
  483.  
  484.  
  485.  
  486.  
  487.  
  488.  
  489.  
  490.  
  491.  
  492.  
  493.  
  494.  
  495.  
  496.  
  497.  
  498.  
  499.  
  500.  
  501.  
  502.  
  503.  
  504.  
  505.  
  506.  
  507.  
  508.  
  509.  
  510.  
  511.  
  512.  
  513.  
  514.  
  515.  
  516.  
  517.  
  518.  
  519.  
  520.  
  521.  
  522.  
  523.  
  524.                        6-7
  525.  
  526.  
  527.  
  528.  
  529. DOC 3"CHAPTER1DOC τCHAPTER2DOC  `(CHAPTER3DOC Ç