home *** CD-ROM | disk | FTP | other *** search
/ Fish 'n' More 2 / fishmore-publicdomainlibraryvol.ii1991xetec.iso / dirs / tcl_447.lzh / TCL / tcl.man < prev    next >
Text File  |  1991-02-02  |  101KB  |  3,231 lines

  1.  
  2.  
  3.      Tcl(tcl)             AMIGA 1.3              Tcl(tcl)
  4.  
  5.  
  6.  
  7.      NAME
  8.       Tcl -    overview of tool command language facilities
  9.  
  10.  
  11.      INTRODUCTION
  12.       Tcl stands for ``tool    command    language'' and is pronounced
  13.       ``tickle.'' It is actually two things:  a language and a
  14.       library.  First, Tcl is a simple textual language, intended
  15.       primarily for    issuing    commands to interactive    programs such
  16.       as text editors, debuggers, illustrators, and    shells.     It
  17.       has a    simple syntax and is also programmable,    so Tcl users
  18.       can write command procedures to provide more powerful
  19.       commands than    those in the built-in set.
  20.  
  21.       Second, Tcl is a library package that    can be embedded    in
  22.       application programs.     The Tcl library consists of a parser
  23.       for the Tcl language,    routines to implement the Tcl built-in
  24.       commands, and    procedures that    allow each application to
  25.       extend Tcl with additional commands specific to that
  26.       application.    The application    program    generates Tcl commands
  27.       and passes them to the Tcl parser for    execution.  Commands
  28.       may be generated by reading characters from an input source,
  29.       or by    associating command strings with elements of the
  30.       application's    user interface,    such as    menu entries, buttons,
  31.       or keystrokes.  When the Tcl library receives    commands it
  32.       parses them into component fields and    executes built-in
  33.       commands directly.  For commands implemented by the
  34.       application, Tcl calls back to the application to execute
  35.       the commands.     In many cases commands    will invoke recursive
  36.       invocations of the Tcl interpreter by    passing    in additional
  37.       strings to execute (procedures, looping commands, and
  38.       conditional commands all work    in this    way).
  39.  
  40.       An application program gains three advantages    by using Tcl
  41.       for its command language.  First, Tcl    provides a standard
  42.       syntax:  once    users know Tcl,    they will be able to issue
  43.       commands easily to any Tcl-based application.     Second, Tcl
  44.       provides programmability.  All a Tcl application needs to do
  45.       is to    implement a few    application-specific low-level
  46.       commands.  Tcl provides many utility commands    plus a general
  47.       programming interface    for building up    complex    command
  48.       procedures.  By using    Tcl, applications need not re-
  49.       implement these features.  Third, Tcl    will eventually
  50.       provide a mechanism for communicating    between    applications:
  51.       it will be possible to send Tcl commands from    one
  52.       application to another.  The common Tcl language framework
  53.       will make it easier for applications to communicate with one
  54.       another.  The    communication features are not implemented in
  55.       the current version of Tcl.
  56.  
  57.       This manual page focusses primarily on the Tcl language.  It
  58.       describes the    language syntax    and the    built-in commands that
  59.  
  60.  
  61.  
  62.      Page 1                         (printed 2/26/90)
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.      Tcl(tcl)             AMIGA 1.3              Tcl(tcl)
  70.  
  71.  
  72.  
  73.       will be available in any application based on    Tcl.  The
  74.       individual library procedures    are described in more detail
  75.       in separate manual pages, one    per procedure.
  76.  
  77.  
  78.      INTERPRETERS
  79.       The central data structure in    Tcl is an interpreter (C type
  80.       ``Tcl_Interp'').  An interpreter consists of a set of
  81.       command bindings, a set of variable values, and a few    other
  82.       miscellaneous    pieces of state.  Each Tcl command is
  83.       interpreted in the context of    a particular interpreter.
  84.       Some Tcl-based applications will maintain multiple
  85.       interpreters simultaneously, each associated with a
  86.       different widget or portion of the application.
  87.       Interpreters are relatively lightweight structures.  They
  88.       can be created and deleted quickly, so application
  89.       programmers should feel free to use multiple interpreters if
  90.       that simplifies the application.  Eventually Tcl will
  91.       provide a mechanism for sending Tcl commands and results
  92.       back and forth between interpreters, even if the
  93.       interpreters are managed by different    processes.
  94.  
  95.  
  96.      DATA TYPES
  97.       Tcl supports only one    type of    data:  strings.     All commands,
  98.       all arguments    to commands, all command results, and all
  99.       variable values are strings.    Where commands require numeric
  100.       arguments or return numeric results, the arguments and
  101.       results are passed as    strings.  Many commands    expect their
  102.       string arguments to have certain formats, but    this
  103.       interpretation is up to the individual commands.  For
  104.       example, arguments often contain Tcl command strings,    which
  105.       may get executed as part of the commands.  The easiest way
  106.       to understand    the Tcl    interpreter is to remember that
  107.       everything is    just an    operation on a string.    In many    cases
  108.       Tcl constructs will look similar to more structured
  109.       constructs from other    languages.  However, the Tcl
  110.       constructs are not structured    at all;     they are just strings
  111.       of characters, and this gives    them a different behavior than
  112.       the structures they may look like.
  113.  
  114.       Although the exact interpretation of a Tcl string depends on
  115.       who is doing the interpretation, there are three common
  116.       forms    that strings take:  commands, expressions, and lists.
  117.       The major sections below discuss these three forms in    more
  118.       detail.
  119.  
  120.  
  121.      BASIC COMMAND SYNTAX
  122.       The Tcl language has syntactic similarities to both the Unix
  123.       shells and Lisp.  However, the interpretation    of commands is
  124.       different in Tcl than    in either of those other two systems.
  125.  
  126.  
  127.  
  128.      Page 2                         (printed 2/26/90)
  129.  
  130.  
  131.  
  132.  
  133.  
  134.  
  135.      Tcl(tcl)             AMIGA 1.3              Tcl(tcl)
  136.  
  137.  
  138.  
  139.       A Tcl    command    string consists    of one or more commands
  140.       separated by newline characters or semi-colons.  Each
  141.       command consists of a    collection of fields separated by
  142.       white    space (spaces or tabs).     The first field must be the
  143.       name of a command, and the additional    fields,    if any,    are
  144.       arguments that will be passed    to that    command.  For example,
  145.       the command
  146.  
  147.       set a    22
  148.  
  149.       has three fields:  the first,    set, is    the name of a Tcl
  150.       command, and the last    two, a and 22, will be passed as
  151.       arguments to the set command.     The command name may refer
  152.       either to a built-in Tcl command, an application-specific
  153.       command bound    in with    the library procedure
  154.       Tcl_CreateCommand, or    a command procedure defined with the
  155.       proc built-in    command.  Arguments are    passed literally as
  156.       text strings.     Individual commands may interpret those
  157.       strings in any fashion they wish.  The set command, for
  158.       example, will    treat its first    argument as the    name of    a
  159.       variable and its second argument as a    string value to    assign
  160.       to that variable.  For other commands    arguments may be
  161.       interpreted as integers, lists, file names, or Tcl commands.
  162.  
  163.       Command names    may be abbreviated as long as the abbreviation
  164.       is unique.  However, it's probably a bad idea    to use
  165.       abbreviations    in command scripts and other forms that    will
  166.       be re-used over time:     changes to the    command    set may    cause
  167.       abbreviations    to become ambiguous, resulting in scripts that
  168.       no longer work.  Abbreviations are intended primarily    for
  169.       commands that    are typed interactively, invoked once, and
  170.       discarded.
  171.  
  172.  
  173.      COMMENTS
  174.       If the first non-blank character in a    command    is #, then
  175.       everything from the #    up through the next newline character
  176.       is treated as    a comment and ignored.
  177.  
  178.  
  179.      GROUPING ARGUMENTS    WITH BRACES
  180.       Normally each    argument field ends at the next    white space,
  181.       but curly braces (``{'' and ``}'') may be used to group
  182.       arguments in different ways.    If an argument field begins
  183.       with a left brace, then the argument isn't terminated    by
  184.       white    space;    instead    it ends    at the matching    right brace.
  185.       Tcl will strip off the outermost layer of braces before
  186.       passing the argument to the command.    This provides a    simple
  187.       mechanism for    including white    space in arguments.  For
  188.       example, the command
  189.  
  190.       set a    {This is a single argument}
  191.  
  192.  
  193.  
  194.      Page 3                         (printed 2/26/90)
  195.  
  196.  
  197.  
  198.  
  199.  
  200.  
  201.      Tcl(tcl)             AMIGA 1.3              Tcl(tcl)
  202.  
  203.  
  204.  
  205.       will pass two    arguments to set:  a and This is a single
  206.       argument.  In    the command
  207.  
  208.       set a    {xyz a {b c d}}
  209.  
  210.       the set command will receive two arguments: a    and xyz    a {b c
  211.       d}.
  212.  
  213.       When braces are in effect, the matching brace    need not be on
  214.       the same line    as the starting    quote or brace;     in this case
  215.       the newline will be included in the argument field along
  216.       with any other characters up to the matching quote or    brace.
  217.       For example, the eval    command    takes one argument, which is a
  218.       command string;  eval    invokes    the Tcl    interpreter to execute
  219.       the command string.  The command
  220.  
  221.       eval {
  222.            set a 22
  223.            set b 33
  224.       }
  225.  
  226.       will assign the value    22 to a    and 33 to b.
  227.  
  228.       When an argument is in braces, then command, variable, and
  229.       backslash substitutions do not occur as described below;
  230.       all Tcl does is to strip off the outer layer of braces and
  231.       pass the contents to the command.
  232.  
  233.       If the first character of a command field isn't a left
  234.       brace, then neither left nor right braces in the field will
  235.       be treated specially (except as part of variable
  236.       substitution;     see below).
  237.  
  238.  
  239.      COMMAND SUBSTITUTION WITH BRACKETS
  240.       If an    open bracket occurs in any of the fields of a command,
  241.       then command substitution occurs.  All of the    text up    to the
  242.       matching close bracket is treated as a Tcl command and
  243.       executed immediately.     Then the result of that command is
  244.       substituted for the bracketed    text.  For example, consider
  245.       the command
  246.  
  247.       set a    [set b]
  248.  
  249.       When the set command has only    a single argument, it is the
  250.       name of a variable and set returns the contents of that
  251.       variable.  In    this case, if variable b has the value foo,
  252.       then the command above is equivalent to the command
  253.  
  254.       set a    foo
  255.  
  256.       Brackets can be used in more complex ways.  For example, if
  257.  
  258.  
  259.  
  260.      Page 4                         (printed 2/26/90)
  261.  
  262.  
  263.  
  264.  
  265.  
  266.  
  267.      Tcl(tcl)             AMIGA 1.3              Tcl(tcl)
  268.  
  269.  
  270.  
  271.       the variable b has the value foo and the variable c has the
  272.       value    gorp, then the command
  273.  
  274.       set a    xyz[set    b].[set    c]
  275.  
  276.       is equivalent    to the command
  277.  
  278.       set a    xyzfoo.gorp
  279.  
  280.       A bracketed command need not be all on one line:  newlines
  281.       within brackets are treated as argument separators, not
  282.       command separators.  If a field is enclosed in braces    then
  283.       the brackets and the characters between them are not
  284.       interpreted specially;  they are passed through to the
  285.       argument verbatim.
  286.  
  287.  
  288.      VARIABLE SUBSTITUTION WITH    $
  289.       The dollar sign ($) may be used as a special shorthand form
  290.       for substituting variables.  If $ appears in an argument
  291.       that isn't enclosed in braces    then variable substitution
  292.       will occur.  The characters after the    $, up to the first
  293.       character that isn't a number, letter, or underscore,    are
  294.       taken    as a variable name and the string value    of that
  295.       variable is substituted for the name.     Or, if    the dollar
  296.       sign is followed by an open curly brace then the variable
  297.       name consists    of all the characters up to the    next close
  298.       curly    brace.    For example, if    variable foo has the value
  299.       test,    then the command
  300.  
  301.       set a    $foo.c
  302.  
  303.       is equivalent    to the command
  304.  
  305.       set a    test.c
  306.  
  307.       and the command
  308.  
  309.       set a    abc${foo}bar
  310.  
  311.       is equivalent    to the command
  312.  
  313.       set a    abctestbar
  314.  
  315.       Variable substitution    does not occur in arguments that are
  316.       enclosed in braces:  the dollar sign and variable name are
  317.       passed through to the    argument verbatim.
  318.  
  319.       The dollar sign abbreviation is simply a shorthand form.  $a
  320.       is completely    equivalent to [set a];    it is provided as a
  321.       convenience to reduce    typing.
  322.  
  323.  
  324.  
  325.  
  326.      Page 5                         (printed 2/26/90)
  327.  
  328.  
  329.  
  330.  
  331.  
  332.  
  333.      Tcl(tcl)             AMIGA 1.3              Tcl(tcl)
  334.  
  335.  
  336.  
  337.      SEPARATING    COMMANDS WITH SEMI-COLONS                |
  338.       Normally, each command occupies one line (the    command    is    |
  339.       terminated by    a newline character).  However,    semi-colon    |
  340.       (``;'') is treated as    a command separator character;        |
  341.       multiple commands may    be placed on one line by separating    |
  342.       them with a semi-colon.
  343.  
  344.  
  345.      BACKSLASH SUBSTITUTION
  346.       Backslashes may be used to insert non-printing characters
  347.       into command fields and also to insert special characters
  348.       like braces and brackets into    fields without them being
  349.       interpreted specially    as described above.  The backslash
  350.       sequences understood by the Tcl interpreter are listed
  351.       below.  In each case,    the backslash sequence is replaced by
  352.       the given character:
  353.  
  354.       \b              Backspace    (octal 10).
  355.  
  356.       \e              Escape (octal 33).
  357.  
  358.       \n              Newline (octal 15).
  359.  
  360.       \t              Tab (octal 11).
  361.  
  362.       \{              Left brace (``{'').
  363.  
  364.       \}              Right brace (``}'').
  365.  
  366.       \[              Open bracket (``['').
  367.  
  368.       \]              Close bracket (``]'').
  369.  
  370.       \<space>          Space (``    ''): doesn't terminate
  371.                   argument.
  372.  
  373.       \;                                     ||
  374.                   Semi-colon: doesn't terminate command.    |
  375.  
  376.       \"                                     ||
  377.                   Double-quote.                |
  378.  
  379.       \<newline>                                 ||
  380.                   Nothing:    this effectively joins two    |
  381.                   lines together into a single line.  This    |
  382.                   backslash    feature    is only    provided when    |
  383.                   parsing Tcl commands;  it    is not        |
  384.                   supported    by the Tcl_Backslash        |
  385.                   procedure.
  386.  
  387.       \\              Backslash    (``\'').
  388.  
  389.  
  390.  
  391.  
  392.      Page 6                         (printed 2/26/90)
  393.  
  394.  
  395.  
  396.  
  397.  
  398.  
  399.      Tcl(tcl)             AMIGA 1.3              Tcl(tcl)
  400.  
  401.  
  402.  
  403.       \Cx              Control-x    (x AND octal 037), for any
  404.                   ASCII x except M (see below).
  405.  
  406.       \Mx              Meta-x (x    OR octal 200), for any ASCII
  407.                   x.
  408.  
  409.       \CMx              Control-meta-x ((x AND octal 037)    OR
  410.                   octal 0200), for any ASCII x.
  411.  
  412.       \ddd              The digits ddd (one, two,    or three of
  413.                   them) give the octal value of the
  414.                   character.
  415.  
  416.       For example, in the command
  417.  
  418.       set a    \{x\[\ yz\141
  419.  
  420.       the second argument to set will be ``{x[ yza''.
  421.  
  422.       If a backslash is followed by    something other    than one of
  423.       the options described    above, then the    backslash is
  424.       transmitted to the argument field without any    special
  425.       processing, and the Tcl scanner continues normal processing
  426.       with the next    character.  For    example, in the    command
  427.  
  428.       set \*a \\\{foo
  429.  
  430.       The first argument to    set will be \*a    and the    second
  431.       argument will    be \{foo.
  432.  
  433.       If an    argument is enclosed in    braces,    then backslash
  434.       sequences inside the argument    are parsed but no substitution
  435.       occurs:  the backslash sequence is passed through to the
  436.       argument as is, without making any special interpretation of
  437.       the characters in the    backslash sequence.  In    particular,
  438.       backslashed braces are not counted in    locating the matching
  439.       right    brace that terminates the argument.  For example, in
  440.       the command
  441.  
  442.       set a    {\{abc}
  443.  
  444.       the second argument to set will be \{abc.
  445.  
  446.       This backslash mechanism is not sufficient to    generate
  447.       absolutely any argument structure;  it only covers the most
  448.       common cases.     To produce particularly complicated arguments
  449.       it will probably be easiest to use the format    command    along
  450.       with command substitution.
  451.  
  452.  
  453.      COMMAND SUMMARY
  454.       [1]  A command is just a string.
  455.  
  456.  
  457.  
  458.      Page 7                         (printed 2/26/90)
  459.  
  460.  
  461.  
  462.  
  463.  
  464.  
  465.      Tcl(tcl)             AMIGA 1.3              Tcl(tcl)
  466.  
  467.  
  468.  
  469.       [2]  Within a    string commands    are separated by newlines or
  470.            semi-colons (unless the newline or semi-colon is    within
  471.            braces or brackets or is    backslashed).
  472.  
  473.       [3]  A command consists of fields.  The first    field is the
  474.            name of the command, and    may be abbreviated.  The other
  475.            fields are strings that are passed to that command as
  476.            arguments.
  477.  
  478.       [4]  Fields are normally separated by    white space.
  479.  
  480.       [5]  Braces defer interpretation of special characters.  If
  481.            a field begins with a left brace, then it consists of
  482.            everything between the left brace and the matching
  483.            right brace. The    braces themselves are not included in
  484.            the argument.  No further processing is done on the
  485.            information between the braces.
  486.  
  487.       [6]  Double-quotes act the same as braces except that    they
  488.            cannot be nested.
  489.  
  490.       [7]  If a field doesn't begin    with a left brace or double-
  491.            quote, then backslash, variable,    and command
  492.            substitution are    done on    the field.  Only a single
  493.            level of    processing is done:  the results of one
  494.            substitution are    not scanned again for further
  495.            substitutions or    any other special treatment.
  496.            Substitution can    occur on any field of a    command,
  497.            including the command name as well as the arguments.
  498.  
  499.       [8]  If the first non-blank character    of a command is    a #,
  500.            everything from the # up    through    the next newline is
  501.            treated as a comment and    ignored.
  502.  
  503.  
  504.      EXPRESSIONS
  505.       The second major interpretation applied to strings in    Tcl is
  506.       as expressions.  Several commands, such as expr, for,    and
  507.       if, treat some of their arguments as expressions and call
  508.       the Tcl expression processor (Tcl_Expr) to evaluate them.  A
  509.       Tcl expression has C-like syntax and evaluates to an integer
  510.       result.  Expressions may contain integer values, variable
  511.       names    in $ notation (the variables' values must be integer
  512.       strings), commands (embedded in brackets) that produce
  513.       integer string results, parentheses for grouping, and
  514.       operators.  Numeric values, whether they are passed directly
  515.       or through variable or command substitution, may be
  516.       specified either in decimal (the normal case), in octal (if
  517.       the first character of the value is 0), or in    hexadecimal
  518.       (if the first    two characters of the value are    0x).  The
  519.       valid    operators are listed below, grouped in decreasing
  520.       order    of precedence:
  521.  
  522.  
  523.  
  524.      Page 8                         (printed 2/26/90)
  525.  
  526.  
  527.  
  528.  
  529.  
  530.  
  531.      Tcl(tcl)             AMIGA 1.3              Tcl(tcl)
  532.  
  533.  
  534.  
  535.       -  ~    !          Unary minus, bit-wise NOT, logical NOT.
  536.  
  537.       *  /    %          Multiply,    divide,    remainder.
  538.  
  539.       +  -              Add and subtract.
  540.  
  541.       <<  >>          Left and right shift.
  542.  
  543.       <  >    <=  >=          Boolean less, greater, less than or
  544.                   equal, and greater than or equal.     Each
  545.                   operator produces    1 if the condition is
  546.                   true, 0 otherwise.
  547.  
  548.       ==  !=          Boolean equal and    not equal.  Each
  549.                   operator produces    a zero/one result.
  550.  
  551.       &              Bit-wise AND.
  552.  
  553.       ^              Bit-wise exclusive OR.
  554.  
  555.       |              Bit-wise OR.
  556.  
  557.       &&              Logical AND.  Produces a 1 result    if
  558.                   both operands are    non-zero, 0 otherwise.
  559.  
  560.       ||              Logical OR.  Produces a 0    result if both
  561.                   operands are zero, 1 otherwise.
  562.  
  563.       See the C manual for more details on the results produced by
  564.       each operator.  All of the binary operators group left-to-
  565.       right    within the same    precedence level.  For example,    the
  566.       expression
  567.  
  568.       (4*2)    < 7
  569.  
  570.       evaluates to 0.  Evaluating the expression string
  571.  
  572.       ($a +    3) < [set b]
  573.  
  574.       will cause the values    of the variables a and b to be
  575.       examined;  the result    will be    1 if b is greater than a by at
  576.       least    3;  otherwise the result will be 0.
  577.  
  578.       In general it    is safest to enclose an    expression in braces
  579.       when entering    it in a    command:  otherwise, if    the expression
  580.       contains any white space then    the Tcl    interpreter will split
  581.       it among several arguments.  For example, the    command
  582.  
  583.       expr $a + $b
  584.  
  585.       results in three arguments being passed to expr:  $a,    +, and
  586.       $b.  In addition, if the expression isn't in braces then the
  587.  
  588.  
  589.  
  590.      Page 9                         (printed 2/26/90)
  591.  
  592.  
  593.  
  594.  
  595.  
  596.  
  597.      Tcl(tcl)             AMIGA 1.3              Tcl(tcl)
  598.  
  599.  
  600.  
  601.       Tcl interpreter will perform variable    and command
  602.       substitution immediately (it will happen in the command
  603.       parser rather    than in    the expression parser).     In many cases
  604.       the expression is being passed to a command that will
  605.       evaluate the expression later    (or even many times if,    for
  606.       example, the expression is to    be used    to decide when to exit
  607.       a loop).  Usually the    desired    goal is    to re-do the variable
  608.       or command substitutions each    time the expression is
  609.       evaluated, rather than once and for all at the beginning.
  610.       For example, the command
  611.  
  612.       for {set i 1}    $i<=10 {set i [expr $i+1]} {...}
  613.  
  614.       is probably intended to iterate over all values of i from 1
  615.       to 10.  After    each iteration of the body of the loop,    for
  616.       will pass its    second argument    to the expression evaluator to
  617.       see whether or not to    continue processing.  Unfortunately,
  618.       in this case the value of i in the second argument will be
  619.       substituted once and for all when the    for command is parsed.
  620.       If i was 0 before the    for command was    invoked    then for's
  621.       second argument will be 0<=10    which will always evaluate to
  622.       1, even though i's value eventually becomes greater than 10.
  623.       In the above case the    loop will never    terminate.  By placing
  624.       the expression in braces, the    substitution of    i's value will
  625.       be delayed;  it will be re-done each time the    expression is
  626.       evaluated, which is probably the desired result.
  627.  
  628.  
  629.      LISTS
  630.       The third major way that strings are interpreted in Tcl is
  631.       as lists.  A list is just a string with a list-like
  632.       structure consisting of fields separated by white space.
  633.       For example, the string
  634.  
  635.       Al Sue Anne John
  636.  
  637.       is a list with four elements or fields.  Lists have the same
  638.       basic    structure as command strings, except that a newline
  639.       character in a list is treated as a field separator just
  640.       like space or    tab.  Conventions for braces and backslashes
  641.       are the same for lists as for    commands.  For example,    the
  642.       string
  643.  
  644.       a b\ c {d e {f g h}}
  645.  
  646.       is a list with three elements:  a, b c, and d    e {f g h}.
  647.       Whenever an element is extracted from    a list,    the same rules
  648.       about    backslashes and    braces are applied as for commands.
  649.       Thus in the example above when the third element is
  650.       extracted from the list, the result is
  651.  
  652.       d e {f g h}
  653.  
  654.  
  655.  
  656.      Page 10                         (printed 2/26/90)
  657.  
  658.  
  659.  
  660.  
  661.  
  662.  
  663.      Tcl(tcl)             AMIGA 1.3              Tcl(tcl)
  664.  
  665.  
  666.  
  667.       (when    the field was extracted, all that happened was to
  668.       strip    off the    outermost layer    of braces).  Command
  669.       substitution is never    made on    a list (at least, not by the
  670.       list-processing commands;  the list can always be passed to
  671.       the Tcl interpreter for evaluation).
  672.  
  673.       The Tcl commands concat, foreach, index, length, list, and
  674.       range    allow you to build lists, extract elements from    them,
  675.       search them, and perform other list-related functions.
  676.  
  677.  
  678.      COMMAND RESULTS
  679.       Each command produces    two results:  a    code and a string.
  680.       The code indicates whether the command completed
  681.       successfully or not, and the string gives additional
  682.       information.    The valid codes    are defined in tcl.h, and are:
  683.  
  684.            TCL_OK           This    is the normal return code, and
  685.                    indicates that the command
  686.                    completed succesfully.  The string
  687.                    gives the command's return value.
  688.  
  689.            TCL_ERROR       Indicates that an error occurred;
  690.                    the string gives a message
  691.                    describing the error.  The variable    |
  692.                    errorInfo will contain additional    |
  693.                    information describing which        |
  694.                    commands and    procedures were    being    |
  695.                    executed when the error occurred.
  696.  
  697.            TCL_RETURN       Indicates that the return command
  698.                    has been invoked, and that the    |
  699.                    current procedure (or top-level    |
  700.                    command or source command) should    |
  701.                    return immediately.    The string    |
  702.                    gives the return value for the    |
  703.                    procedure or    command.
  704.  
  705.            TCL_BREAK       Indicates that the break command
  706.                    has been invoked, so    the innermost
  707.                    loop    should abort immediately.  The
  708.                    string should always    be empty.
  709.  
  710.            TCL_CONTINUE       Indicates that the continue command
  711.                    has been invoked, so    the innermost
  712.                    loop    should go on to    the next
  713.                    iteration.  The string should
  714.                    always be empty.
  715.       Tcl programmers do not normally need to think    about return
  716.       codes, since TCL_OK is almost    always returned.  If anything
  717.       else is returned by a    command, then the Tcl interpreter
  718.       immediately stops processing commands    and returns to its
  719.  
  720.  
  721.  
  722.      Page 11                         (printed 2/26/90)
  723.  
  724.  
  725.  
  726.  
  727.  
  728.  
  729.      Tcl(tcl)             AMIGA 1.3              Tcl(tcl)
  730.  
  731.  
  732.  
  733.       caller.  If there are    several    nested invocations of the Tcl
  734.       interpreter in progress, then    each nested command will
  735.       usually return the error to its caller, until    eventually the
  736.       error    is reported to the top-level application code.    The
  737.       application will then    display    the error message for the
  738.       user.
  739.  
  740.       In a few cases, some commands    will handle certain ``error''
  741.       conditions themselves    and not    return them upwards.  For
  742.       example, the for command checks for the TCL_BREAK code;  if
  743.       it occurs, then for stops executing the body of the loop and
  744.       returns TCL_OK to its    caller.     The for command also handles
  745.       TCL_CONTINUE codes and the procedure interpreter handles
  746.       TCL_RETURN codes.  The catch command allows Tcl programs to
  747.       catch    errors and handle them without aborting    command
  748.       interpretation any further.
  749.  
  750.  
  751.      PROCEDURES
  752.       Tcl allows you to extend the command interface by defining
  753.       procedures.  A Tcl procedure can be invoked just like    any
  754.       other    Tcl command (it    has a name and it receives one or more
  755.       arguments).  The only    difference is that its body isn't a
  756.       piece    of C code linked into the program;  it is a string
  757.       containing one or more other Tcl commands.  See the proc
  758.       command for information on how to define procedures and what
  759.       happens when they are    invoked.
  760.  
  761.  
  762.      VARIABLES
  763.       Tcl allows the definition of variables and the use of    their
  764.       values either    through    $-style    variable substitution, the set
  765.       command, or a    few other mechanisms.  Variables need not be
  766.       declared:  a new variable will automatically be created each
  767.       time a new variable name is used.  Variables may be either
  768.       global or local.  If a variable name is used when a
  769.       procedure isn't being    executed, then it automatically    refers
  770.       to a global variable.     Variable names    used within a
  771.       procedure normally refer to local variables associated with
  772.       that invocation of the procedure.  Local variables are
  773.       deleted whenever a procedure exits.  The global command may
  774.       be used to request that a name refer to a global variable
  775.       for the duration of the current procedure (this is somewhat
  776.       analogous to extern in C).
  777.  
  778.  
  779.      BUILT-IN COMMANDS
  780.       The Tcl library provides the following built-in commands,
  781.       which    will be    available in any application using Tcl.     In
  782.       addition to these built-in commands, there may be additional
  783.       commands defined by each application,    plus commands defined
  784.       as Tcl procedures.  In the command syntax descriptions
  785.  
  786.  
  787.  
  788.      Page 12                         (printed 2/26/90)
  789.  
  790.  
  791.  
  792.  
  793.  
  794.  
  795.      Tcl(tcl)             AMIGA 1.3              Tcl(tcl)
  796.  
  797.  
  798.  
  799.       below, optional arguments are    indicated by enclosing their
  800.       names    in brackets;  apologies    in advance for the confusion
  801.       between this descriptive use of brackets and the use of
  802.       brackets to invoke command substitution.  Words in boldface
  803.       are literals that you    type verbatim to Tcl.  Words in
  804.       italics are meta-symbols;  they act as names to refer    to a
  805.       class    of values that you can type.
  806.  
  807.       break
  808.            This command may    be invoked only    inside the body    of a
  809.            loop command such as for    or foreach.  It    returns    a
  810.            TCL_BREAK code to signal    the innermost containing loop
  811.            command to return immediately.
  812.  
  813.       case string [in] patList body    patList    body ...
  814.            Match string against each of the    patList    arguments in    |
  815.            order.  If one matches, then evaluate the following    |
  816.            body argument by    passing    it recursively to the Tcl    |
  817.            interpreter, and    return the result of that evaluation.    |
  818.            Each patList argument consists of a single pattern or    |
  819.            list of patterns.  Each pattern may contain any of the    |
  820.            wild-cards described under string match.     If a patList    |
  821.            argument    is default, the    corresponding body will    be    |
  822.            evaluated if no patList matches string.    If no patList    |
  823.            argument    matches    string and no default is given,    then    |
  824.            the case    command    returns    an empty string.  For example,    |
  825.  
  826.            case abc    in {a b} {format 1} default {format 2} a* {format 3}|
  827.  
  828.            will return 3,                        |
  829.  
  830.            case a in {a b} {format 1} default {format 2} a*    {format    3}|
  831.  
  832.            will return 1, and                    |
  833.  
  834.            case xyz    {a b} {format 1} default {format 2} a* {format 3}|
  835.  
  836.            will return 2.                        |
  837.  
  838.       catch    command    [varName]
  839.            The catch command may be    used to    prevent    errors from
  840.            aborting    command    interpretation.     Catch calls the Tcl
  841.            interpreter recursively to execute command, and always
  842.            returns a TCL_OK    code, regardless of any    errors that
  843.            might occur while executing command.  The return    value
  844.            from catch is a decimal string giving the code returned
  845.            by the Tcl interpreter after executing command.    This
  846.            will be 0 (TCL_OK) if there were    no errors in command;
  847.            otherwise it will have a    non-zero value corresponding
  848.            to one of the exceptional return    codes (see tcl.h for
  849.            the definitions of code values).     If the    varName
  850.            argument    is given, then it gives    the name of a
  851.  
  852.  
  853.  
  854.      Page 13                         (printed 2/26/90)
  855.  
  856.  
  857.  
  858.  
  859.  
  860.  
  861.      Tcl(tcl)             AMIGA 1.3              Tcl(tcl)
  862.  
  863.  
  864.  
  865.            variable; catch will set    the value of the variable to
  866.            the string returned from    command    (either    a result or an
  867.            error message).
  868.  
  869.       concat arg arg ...
  870.            This command treats each    argument as a list and
  871.            concatenates them into a    single list.  It permits any
  872.            number of arguments.  For example, the command
  873.  
  874.            concat a    b {c d e} {f {g    h}}
  875.  
  876.            will return
  877.  
  878.            a b c d e f {g h}
  879.  
  880.            as its result.
  881.  
  882.       continue
  883.            This command may    be invoked only    inside the body    of a
  884.            loop command such as for    or foreach.  It    returns    a
  885.            TCL_CONTINUE code to signal the innermost containing
  886.            loop command to skip the    remainder of the loop's    body
  887.            but continue with the next iteration of the loop.
  888.  
  889.       error    message
  890.            Returns a TCL_ERROR code, which causes command
  891.            interpretation to be unwound.  Message is a string that
  892.            is returned to the application to indicate what went
  893.            wrong.                            |
  894.  
  895.       eval arg1 arg2 ...                             ||
  896.            Eval takes one or more arguments, which together        |
  897.            comprise    a Tcl command (or collection of    Tcl commands    |
  898.            separated by newlines in    the usual way).     Eval        |
  899.            concatenates all    its arguments in the same fashion as    |
  900.            the concat command, passes the concatenated string to    |
  901.            the Tcl interpreter recursively,    and returns the    result    |
  902.            of that evaluation (or any error    generated by it).
  903.  
  904.       exec command arg1 arg2 ...[< input]
  905.            The exec    command    treats its command argument as the
  906.            name of a program to execute.  It searches the
  907.            directories in the PATH environment variable to find an
  908.            executable file by the name command, then executes the
  909.            file, passing it    an argument list consisting of command
  910.            plus all    of the args.  If an argument < appears
  911.            anywhere    among the arguments to exec, then neither it
  912.            or the following    argument is passed to command.
  913.            Instead,    the following argument (input) consists    of
  914.            input to    the command;  exec will    create a pipe and use
  915.            it to pass input    to command as standard input.  Exec
  916.            also creates a pipe to receive command's    output (both
  917.  
  918.  
  919.  
  920.      Page 14                         (printed 2/26/90)
  921.  
  922.  
  923.  
  924.  
  925.  
  926.  
  927.      Tcl(tcl)             AMIGA 1.3              Tcl(tcl)
  928.  
  929.  
  930.  
  931.            standard    output and standard error).  The information
  932.            received    over this pipe is returned as the result of
  933.            the exec    command.  The exec command also    looks at the
  934.            return status returned by command.  Normally this
  935.            should be zero;    if it is then exec returns normally.
  936.            If command returns a non-zero status, then exec will
  937.            return that code;  it should be one of the ones defined
  938.            in the section ``COMMAND    RESULTS'' above.  If an    out-of
  939.            range code is returned by the command, it will cause
  940.            command unwinding just as if TCL_ERROR had been
  941.            returned; at the    outermost level    of command
  942.            interpretation, the Tcl interpreter will    turn the code
  943.            into TCL_ERROR, with an appropriate error message.
  944.  
  945.       expr arg
  946.            Calls the expression processor to evaluate arg, and
  947.            returns the result as a decimal string.
  948.  
  949.       file name option
  950.            Operate on a file or a file name.  Name is the name of
  951.            a file, and option indicates what to do with the    file
  952.            name.  Any unique abbreviation for option is
  953.            acceptable.  The    valid options are:
  954.  
  955.            file name dirname
  956.             Return all of the characters in name up to but not
  957.             including the last slash character.     If there are
  958.             no slashes in name then return ``.''.  If the last
  959.             slash in name is its first character, then return
  960.             ``/''.
  961.  
  962.            file name executable
  963.             Return 1 if    file name is executable    by the current
  964.             user, 0 otherwise.
  965.  
  966.            file name exists
  967.             Return 1 if    file name exists and the current user
  968.             has    search privileges for the directories leading
  969.             to it, 0 otherwise.
  970.  
  971.            file name extension
  972.             Return all of the characters in name after and
  973.             including the last dot in name.  If    there is no
  974.             dot    in name    then return the    empty string.
  975.  
  976.            file name isdirectory
  977.             Return 1 if    file name is a directory, 0 otherwise.
  978.  
  979.            file name isfile
  980.             Return 1 if    file name is a regular file, 0
  981.             otherwise.
  982.  
  983.  
  984.  
  985.  
  986.      Page 15                         (printed 2/26/90)
  987.  
  988.  
  989.  
  990.  
  991.  
  992.  
  993.      Tcl(tcl)             AMIGA 1.3              Tcl(tcl)
  994.  
  995.  
  996.  
  997.            file name owned
  998.             Return 1 if    file name is owned by the current
  999.             user, 0 otherwise.
  1000.  
  1001.            file name readable
  1002.             Return 1 if    file name is readable by the current
  1003.             user, 0 otherwise.
  1004.  
  1005.            file name rootname
  1006.             Return all of the characters in name up to but not
  1007.             including the last ``.'' character in the name.
  1008.             If name doesn't contain a dot, then    return name.
  1009.  
  1010.            file name tail
  1011.             Return all of the characters in name after the
  1012.             last slash.     If name contains no slashes then
  1013.             return name.
  1014.  
  1015.            file name writable
  1016.             Return 1 if    file name is writable by the current
  1017.             user, 0 otherwise.
  1018.  
  1019.            The file    commands that return 0/1 results are often
  1020.            used in conditional or looping commands,    for example:
  1021.  
  1022.            if {![file foo exists]} then {error {bad    file name}} else {...}
  1023.  
  1024.  
  1025.       for start test next body
  1026.            For is a    looping    command, similar in structure to the C
  1027.            for statement.  The start, next,    and body arguments
  1028.            must be Tcl command strings, and    test is    an expression
  1029.            string.    The for    command    first invokes the Tcl
  1030.            interpreter to execute first.  Then it repeatedly
  1031.            evaluates test as an expression;     if the    result is
  1032.            non-zero    it invokes the Tcl interpreter on body,    then
  1033.            invokes the Tcl interpreter on next, then repeats the
  1034.            loop.  The command terminates when test evaluates to 0.
  1035.            If a continue command is    invoked    within body then any
  1036.            remaining commands in the current execution of body are
  1037.            skipped;    processing continues by    invoking the Tcl
  1038.            interpreter on next, then evaluating test, and so on.
  1039.            If a break command is invoked within body or next, then    |
  1040.            the for command will return immediately.     The operation
  1041.            of break    and continue are similar to the    corresponding
  1042.            statements in C.     For returns an    empty string.
  1043.  
  1044.       foreach varname list body
  1045.            In this command,    varname    is the name of a variable,
  1046.            list is a list of values    to assign to varname, and body
  1047.            is a collection of Tcl commands.     For each field    in
  1048.            list (in    order from left    to right), foreach assigns the
  1049.  
  1050.  
  1051.  
  1052.      Page 16                         (printed 2/26/90)
  1053.  
  1054.  
  1055.  
  1056.  
  1057.  
  1058.  
  1059.      Tcl(tcl)             AMIGA 1.3              Tcl(tcl)
  1060.  
  1061.  
  1062.  
  1063.            contents    of the field to    varname    (as if the index
  1064.            command had been    used to    extract    the field), then calls
  1065.            the Tcl interpreter to execute body.  The break and
  1066.            continue    statements may be invoked inside body, with
  1067.            the same    effect as in the for command.  Foreach an
  1068.            empty string.
  1069.  
  1070.       format formatString arg arg ...
  1071.            This command generates a    formatted string in the    same
  1072.            way as the C sprintf procedure (it uses sprintf in its
  1073.            implementation).     FormatString indicates    how to format
  1074.            the result, using % fields as in    sprintf, and the
  1075.            additional arguments, if    any, provide values to be
  1076.            substituted into    the result.  All of the    sprintf
  1077.            options are valid;  see the sprintf man page for
  1078.            details.     Each arg must match the expected type from
  1079.            the % field in formatString;  the format    command
  1080.            converts    each argument to the correct type (floating,
  1081.            integer,    etc.) before passing it    to sprintf for
  1082.            formatting.  The    only unusual conversion    is for %c;  in
  1083.            this case the argument must be a    decimal    string,    which
  1084.            will then be converted to the corresponding ASCII
  1085.            character value.     Format    does backslash substitution on
  1086.            its formatString    argument, so backslash sequences in
  1087.            formatString will be handled correctly even if the
  1088.            argument    is in braces.  The return value    from format is
  1089.            the formatted string.
  1090.  
  1091.       glob filename
  1092.            This command performs filename globbing,    using csh    |
  1093.            rules.  The returned value from glob is the list    of    |
  1094.            expanded    filenames.
  1095.  
  1096.       global varname varname ...
  1097.            This command is ignored unless a    Tcl procedure is being
  1098.            interpreted.  If    so, then it declares the given
  1099.            varname's to be global variables    rather than local
  1100.            ones.  For the duration of the current procedure    (and
  1101.            only while executing in the current procedure), any
  1102.            reference to any    of the varnames    will be    bound to a
  1103.            global variable instead of a local one.
  1104.  
  1105.       if test [then] trueBody [[else] falseBody]
  1106.            The if command evaluates    test as    an expression (in the
  1107.            same way    that expr evaluates its    argument).  If the
  1108.            result is non-zero then trueBody    is called by passing
  1109.            it to the Tcl interpreter.  Otherwise falseBody is
  1110.            executed    by passing it to the Tcl interpreter.  The
  1111.            then and    else arguments are optional ``noise words'' to
  1112.            make the    command    easier to read.     FalseBody is also
  1113.            optional;  if it    isn't specified    then the command does
  1114.            nothing if test evaluates to zero.  The return value
  1115.  
  1116.  
  1117.  
  1118.      Page 17                         (printed 2/26/90)
  1119.  
  1120.  
  1121.  
  1122.  
  1123.  
  1124.  
  1125.      Tcl(tcl)             AMIGA 1.3              Tcl(tcl)
  1126.  
  1127.  
  1128.  
  1129.            from if is the value of the last    command    executed in
  1130.            trueBody    or falseBody, or the empty string if test
  1131.            evaluates to zero and falseBody isn't specified.
  1132.  
  1133.       index    value index [chars]
  1134.            Extract an element from a list or a character from a
  1135.            string.    If the chars keyword isn't specified, then
  1136.            index treats value as a list and    returns    the index'th
  1137.            field from it.  In extracting the field,    index observes
  1138.            the same    rules concerning braces    and backslashes    as the
  1139.            Tcl command interpreter;     however, variable
  1140.            substitution and    command    substitution do    not occur.  If
  1141.            index is    greater    than or    equal to the number of
  1142.            elements    in value, then the empty string    is returned.
  1143.            If the chars keyword is specified (or any abbreviation
  1144.            of it), then value is treated as    a string and the
  1145.            command returns the index'th character from it (or the
  1146.            empty string if there aren't at least index+1
  1147.            characters in the string).  Index 0 refers to the first
  1148.            element or character of value.
  1149.  
  1150.       info option arg arg ...
  1151.            Provide information about various internals to the Tcl
  1152.            interpreter.  The legal option's    (which may be
  1153.            abbreviated) are:
  1154.  
  1155.            info args procname
  1156.             Returns a list containing the names    of the
  1157.             arguments to procedure procname, in    order.
  1158.             Procname must be the name of a Tcl command
  1159.             procedure.
  1160.  
  1161.            info body procname
  1162.             Returns the    body of    procedure procname.  Procname
  1163.             must be the    name of    a Tcl command procedure.
  1164.  
  1165.            info commands [pattern]
  1166.             If pattern isn't specified,    returns    a list of    |
  1167.             names of all the Tcl commands, including both the    |
  1168.             built-in commands written in C and the command    |
  1169.             procedures defined using the proc command.    If    |
  1170.             pattern is specified, only those names matching    |
  1171.             pattern are    returned.  Matching is determined    |
  1172.             using the same rules as for    string match.
  1173.  
  1174.            info cmdcount
  1175.             Returns a count of the total number    of commands
  1176.             that have been invoked in this interpreter.
  1177.  
  1178.            info default procname arg varname
  1179.             Procname must be the name of a Tcl command
  1180.             procedure and arg must be the name of an argument
  1181.  
  1182.  
  1183.  
  1184.      Page 18                         (printed 2/26/90)
  1185.  
  1186.  
  1187.  
  1188.  
  1189.  
  1190.  
  1191.      Tcl(tcl)             AMIGA 1.3              Tcl(tcl)
  1192.  
  1193.  
  1194.  
  1195.             to that procedure.    If arg doesn't have a default
  1196.             value then the command returns 0.  Otherwise it
  1197.             returns 1 and places the default value of arg into
  1198.             variable varname.
  1199.  
  1200.            info globals [pattern]
  1201.             If pattern isn't specified,    returns    a list of all    |
  1202.             the    names of currently-defined global variables.    |
  1203.             If pattern is specified, only those    names matching    |
  1204.             pattern are    returned.  Matching is determined    |
  1205.             using the same rules as for    string match.        |
  1206.  
  1207.            info level [number]                         ||
  1208.             If number is not specified,    this command returns a    |
  1209.             number giving the stack level of the invoking    |
  1210.             procedure, or 0 if the command is invoked at top-    |
  1211.             level.  If number is specified, then the result is    |
  1212.             a list consisting of the name and arguments    for    |
  1213.             the    procedure call at level    number on the stack.    |
  1214.             If number is positive then it selects a particular    |
  1215.             stack level    (1 refers to the top-most active    |
  1216.             procedure, 2 to the    procedure it called, and so    |
  1217.             on);  otherwise it gives a level relative to the    |
  1218.             current level (0 refers to the current procedure,    |
  1219.             -1 to its caller, and so on).  See the uplevel    |
  1220.             command for    more information on what stack levels    |
  1221.             mean.                        |
  1222.  
  1223.            info locals [pattern]                         ||
  1224.             If pattern isn't specified,    returns    a list of all    |
  1225.             the    names of currently-defined local variables,    |
  1226.             including arguments    to the current procedure, if    |
  1227.             any.  If pattern is    specified, only    those names    |
  1228.             matching pattern are returned.  Matching is        |
  1229.             determined using the same rules as for string    |
  1230.             match.                        |
  1231.  
  1232.            info procs [pattern]                         ||
  1233.             If pattern isn't specified,    returns    a list of all    |
  1234.             the    names of Tcl command procedures.  If pattern    |
  1235.             is specified, only those names matching pattern    |
  1236.             are    returned.  Matching is determined using    the    |
  1237.             same rules as for string match.            |
  1238.  
  1239.            info tclversion                             ||
  1240.             Returns the    version    number for this    version    of Tcl    |
  1241.             in the form    x.y, where changes to x    represent    |
  1242.             major changes with probable    incompatibilities and    |
  1243.             changes to y represent small enhancements and bug    |
  1244.             fixes that retain backward compatibility.
  1245.  
  1246.            info vars
  1247.  
  1248.  
  1249.  
  1250.      Page 19                         (printed 2/26/90)
  1251.  
  1252.  
  1253.  
  1254.  
  1255.  
  1256.  
  1257.      Tcl(tcl)             AMIGA 1.3              Tcl(tcl)
  1258.  
  1259.  
  1260.  
  1261.             Returns a list of all the names of currently-
  1262.             visible variables, including both locals and
  1263.             currently-visible globals.
  1264.  
  1265.       length value [chars]
  1266.            If chars    isn't specified, treats    value as a list    and
  1267.            returns the number of elements in the list.  If chars
  1268.            is specified (or    any abbreviation of it), then length
  1269.            treats value as a string    and returns the    number of
  1270.            characters in it    (not including the terminating null
  1271.            character).
  1272.  
  1273.       list arg1 arg2 ...
  1274.            This command returns a list comprised of    all the    args.
  1275.            Braces and backslashes get added    as necessary, so that
  1276.            the index command may be    used on    the result to re-
  1277.            extract the original arguments, and also    so that    eval
  1278.            may be used to execute the resulting list, with arg1
  1279.            comprising the command's    name and the other args
  1280.            comprising its arguments.  List produces    slightly
  1281.            different results than concat:  concat removes one
  1282.            level of    grouping before    forming    the list, while    list
  1283.            works directly from the original    arguments.  For
  1284.            example,    the command
  1285.  
  1286.            list a b    {c d e}    {f {g h}}
  1287.  
  1288.            will return
  1289.  
  1290.            a b {c d    e} {f {g h}}
  1291.  
  1292.            while concat with the same arguments will return
  1293.  
  1294.            a b c d e f {g h}
  1295.  
  1296.  
  1297.       print    string [file [append]]
  1298.            Print the string    argument.  If no file is specified    |
  1299.            then string is output to    the standard output file.  If    |
  1300.            file is specified, then string is output    to that    file.    |
  1301.            If the append option is given, then string is appended    |
  1302.            to file;     otherwise any existing    contents of file are    |
  1303.            discarded before    string is written to the file.
  1304.  
  1305.       proc name args body
  1306.            The proc    command    creates    a new Tcl command procedure,
  1307.            name, replacing any existing command there may have
  1308.            been by that name.  Whenever the    new command is
  1309.            invoked,    the contents of    body will be executed by the
  1310.            Tcl interpreter.     Args specifies    the formal arguments
  1311.            to the procedure.  It consists of a list, possibly
  1312.            empty, each of whose elements specifies one argument.
  1313.  
  1314.  
  1315.  
  1316.      Page 20                         (printed 2/26/90)
  1317.  
  1318.  
  1319.  
  1320.  
  1321.  
  1322.  
  1323.      Tcl(tcl)             AMIGA 1.3              Tcl(tcl)
  1324.  
  1325.  
  1326.  
  1327.            Each argument specifier is also a list with either one
  1328.            or two fields.  If there    is only    a single field in the
  1329.            specifier, then it is the name of the argument;    if
  1330.            there are two fields, then the first is the argument
  1331.            name and    the second is its default value.  braces and
  1332.            backslashes may be used in the usual way    to specify
  1333.            complex default values.
  1334.  
  1335.            When name is invoked, a local variable will be created
  1336.            for each    of the formal arguments    to the procedure;  its
  1337.            value will be the value of corresponding    argument in
  1338.            the invoking command or the argument's default value.
  1339.            Arguments with default values need not be specified in
  1340.            a procedure invocation.    However, there must be enough
  1341.            actual arguments    for all    the formal arguments that
  1342.            don't have defaults, and    there must not be any extra
  1343.            actual arguments.  There    is one special case to permit
  1344.            procedures with variable    numbers    of arguments.  If the
  1345.            last formal argument has    the name args, then a call to
  1346.            the procedure may contain more actual arguments than
  1347.            the procedure has formals.  In this case, all of    the
  1348.            actual arguments    starting at the    one that would be
  1349.            assigned    to args    are combined into a list (as if    the
  1350.            list command had    been used);  this combined value is
  1351.            assigned    to the local variable args.
  1352.  
  1353.            When body is being executed, variable names normally
  1354.            refer to    local variables, which are created
  1355.            automatically when referenced and deleted when the
  1356.            procedure returns.  One local variable is automatically
  1357.            created for each    of the procedure's arguments.  Global
  1358.            variables can only be accessed by invoking the global
  1359.            command.
  1360.  
  1361.            The proc    command    returns    the null string.  When a
  1362.            procedure is invoked, the procedure's return value is
  1363.            the value specified in a    return command.     If the
  1364.            procedure doesn't execute an explicit return, then its
  1365.            return value is the value of the    last command executed
  1366.            in the procedure's body.     If an error occurs while
  1367.            executing the procedure body, then the procedure-as-a-
  1368.            whole will return that same error.
  1369.  
  1370.       range    value first last [chars]
  1371.            Return a    range of fields    or characters from value.  If
  1372.            the chars keyword isn't specified, then value must be a
  1373.            list and    range will return a new    list consisting    of
  1374.            elements    first through last, inclusive.    The special
  1375.            keyword end may be specified for    last; in this case all
  1376.            the elements of value starting at first are returned.
  1377.            If the chars keyword, or    any abbreviation of it,    is
  1378.            specified, then range treats value as a character
  1379.  
  1380.  
  1381.  
  1382.      Page 21                         (printed 2/26/90)
  1383.  
  1384.  
  1385.  
  1386.  
  1387.  
  1388.  
  1389.      Tcl(tcl)             AMIGA 1.3              Tcl(tcl)
  1390.  
  1391.  
  1392.  
  1393.            string and returns characters first through last    of it,
  1394.            inclusive.  Once    again, the end keyword may be used for
  1395.            last.  In both cases if a last value is specified
  1396.            greater than the    size of    value it is equivalent to
  1397.            specifying end; if last is less than first then an
  1398.            empty string is returned.  Note:    ``range    value first
  1399.            first'' does not    always produce the same    results    as
  1400.            ``index value first'' (although it often    does for
  1401.            simple fields that aren't enclosed in braces);  it
  1402.            does, however, produce exactly the same results as
  1403.            ``list [index value first]''
  1404.  
  1405.       rename oldName newName
  1406.            Rename the command that used to be called oldName so    |
  1407.            that it is now called newName.  If newName is an    empty    |
  1408.            string (e.g. {})    then oldName is    deleted.  The rename    |
  1409.            command returns an empty    string as result.
  1410.  
  1411.       return [value]
  1412.            Return immediately from the current procedure (or top-    |
  1413.            level command or    source command), with value as the
  1414.            return value.  If value is not specified, an empty
  1415.            string will be returned as result.
  1416.  
  1417.       scan string format varname1 varname2 ...
  1418.            This command parses fields from an input    string in the
  1419.            same fashion as the C sscanf procedure.    String gives
  1420.            the input to be parsed and format indicates how to
  1421.            parse it, using % fields    as in sscanf.  All of the
  1422.            sscanf options are valid; see the sscanf    man page for
  1423.            details.     Each varname gives the    name of    a variable;
  1424.            when a field is scanned from string, the    result is
  1425.            converted back into a string and    assigned to the
  1426.            corresponding varname.  The only    unusual    conversion is
  1427.            for %c;    in this    case, the character value is converted
  1428.            to a decimal string, which is then assigned to the
  1429.            corresponding varname.                    |
  1430.  
  1431.       set varname [value]                             ||
  1432.            If value    isn't specified, then return the current value    |
  1433.            of varname.  If value is    specified, then    set the    value
  1434.            of varname to value, creating a new variable if one
  1435.            doesn't already exist.  If no procedure is active, then
  1436.            varname refers to a global variable.  If    a procedure is
  1437.            active, then varname refers to a    parameter or local
  1438.            variable    of the procedure, unless the global command
  1439.            has been    invoked    to declare varname to be global.
  1440.  
  1441.       source fileName
  1442.            Read file fileName and pass the contents    to the Tcl
  1443.            interpreter as a    sequence of commands to    execute    in the
  1444.            normal fashion.    The return value of source is the
  1445.  
  1446.  
  1447.  
  1448.      Page 22                         (printed 2/26/90)
  1449.  
  1450.  
  1451.  
  1452.  
  1453.  
  1454.  
  1455.      Tcl(tcl)             AMIGA 1.3              Tcl(tcl)
  1456.  
  1457.  
  1458.  
  1459.            return value of the last    command    executed from the
  1460.            file.  If an error occurs in executing the contents of
  1461.            the file, then the source command will return that
  1462.            error.  If a return command is invoked from within the    |
  1463.            file, the remainder of the file will be skipped and the    |
  1464.            source command will return normally with    the result    |
  1465.            from the    return command.
  1466.  
  1467.       string option    a b
  1468.            Perform a string    operation on the two operands a    and b,
  1469.            based on    option.     The possible options are:
  1470.  
  1471.            string compare a    b
  1472.             Perform a character-by-character comparison    of
  1473.             strings a and b, in    the same way as    the C strcmp
  1474.             procedure.    Return -1, 0, or 1, depending on
  1475.             whether a is lexicographically less    than, equal
  1476.             to,    or greater than    b.
  1477.  
  1478.            string first a b
  1479.             Search b for a sequence of characters that exactly
  1480.             match the characters in a.    If found, return the
  1481.             index of the first character in the    first such
  1482.             match within b.  If    not found, return -1.
  1483.  
  1484.            string last a b
  1485.             Search b for a sequence of characters that exactly
  1486.             match the characters in a.    If found, return the
  1487.             index of the first character in the    last such
  1488.             match within b.  If    there is no match, then    return
  1489.             -1.
  1490.  
  1491.            string match pattern string                     ||
  1492.             See    if pattern matches string;  return 1 if    it    |
  1493.             does, 0 if it doesn't.  Matching is    done in    a    |
  1494.             fashion similar to that used by the    C-shell.  For    |
  1495.             the    two strings to match, their contents must be    |
  1496.             identical except that the following    special        |
  1497.             sequences may appear in pattern:            |
  1498.  
  1499.             *                                 ||
  1500.                   Matches any sequence of characters in    |
  1501.                   string, including    a null string.        |
  1502.  
  1503.             ?                                 ||
  1504.                   Matches any single character in string.    |
  1505.  
  1506.             [chars]                             ||
  1507.                   Matches any character in the set given    |
  1508.                   by chars.     If a sequence of the form x-y    |
  1509.                   appears in chars,    then any character    |
  1510.                   between x    and y, inclusive, will match.    |
  1511.  
  1512.  
  1513.  
  1514.      Page 23                         (printed 2/26/90)
  1515.  
  1516.  
  1517.  
  1518.  
  1519.  
  1520.  
  1521.      Tcl(tcl)             AMIGA 1.3              Tcl(tcl)
  1522.  
  1523.  
  1524.  
  1525.             \x                                 ||
  1526.                   Matches the single character x.  This    |
  1527.                   provides a way of    avoiding the special    |
  1528.                   interpretation of    the characters *?[]\    |
  1529.                   in pattern.                |
  1530.  
  1531.            Unique abbreviations for    option are acceptable.
  1532.  
  1533.       time command [count]
  1534.            This command will call the Tcl interpreter count    times
  1535.            to execute command (or once if count isn't specified).
  1536.            It will then return a string of the form
  1537.  
  1538.            503 microseconds    per iteration
  1539.  
  1540.            which indicates the average amount of time required per
  1541.            iteration, in microseconds.  Time is measured in
  1542.            elapsed time, not CPU time.
  1543.  
  1544.       uplevel level    command    command    ...
  1545.            All of the command arguments are    concatenated as    if    |
  1546.            they had    been passed to concat and the result is        |
  1547.            evaluated in the    variable context indicated by level.    |
  1548.            Uplevel returns the result of that evaluation.  If    |
  1549.            level is    zero, then top-level context is    used (all    |
  1550.            variable    names refer to global variables).  If level is    |
  1551.            a positive number, then it is treated as    a stack    level:    |
  1552.            1 refers    to the topmost active procedure, 2 to the    |
  1553.            procedure it called, and    so on.    If level is a negative    |
  1554.            number, then it is treated as a level relative to the    |
  1555.            current procedure.  For example,    a level    of -1 refers    |
  1556.            to the procedure    that called the    one invoking the    |
  1557.            uplevel command (which is top-level if the procedure    |
  1558.            invoking    uplevel    is at level 1).     The uplevel command    |
  1559.            causes the invoking procedure to    disappear from the    |
  1560.            procedure calling stack while the command is being    |
  1561.            executed.  For example, suppose procedure x is at level    |
  1562.            3 and invokes the command                |
  1563.  
  1564.            uplevel -1 {set a 43; c}                    |
  1565.  
  1566.            where c is another Tcl procedure.  The set command will    |
  1567.            modify variable a in x's    caller,    and c will execute at    |
  1568.            level 3,    as if called from x's caller.  If it in    turn    |
  1569.            executes    the command                    |
  1570.  
  1571.            uplevel -1 {set a 42}                    |
  1572.  
  1573.            then the    set command will modify    the same variable a in    |
  1574.            x's caller:  the    procedure x does not appear to be on    |
  1575.            the call    stack when c is    executing.  The    command    ``info    |
  1576.            level'' may be used to obtain the level of the current    |
  1577.  
  1578.  
  1579.  
  1580.      Page 24                         (printed 2/26/90)
  1581.  
  1582.  
  1583.  
  1584.  
  1585.  
  1586.  
  1587.      Tcl(tcl)             AMIGA 1.3              Tcl(tcl)
  1588.  
  1589.  
  1590.  
  1591.            procedure.  Uplevel makes it possible to    implement new    |
  1592.            control constructs as Tcl procedures (for example,    |
  1593.            uplevel could be    used to    implement the while construct    |
  1594.            as a Tcl    procedure).
  1595.  
  1596.  
  1597.      BUILT-IN VARIABLES                            |
  1598.       The following    global variables are created and managed    |
  1599.       automatically    by the Tcl library.  These variables should    |
  1600.       normally be treated as read-only by application-specific    |
  1601.       code and by users.                        |
  1602.  
  1603.       errorInfo                                 ||
  1604.            After an    error has occurred, this string    will contain    |
  1605.            two or more lines identifying the Tcl commands and    |
  1606.            procedures that were being executed when    the most    |
  1607.            recent error occurred.
  1608.  
  1609.  
  1610.      AUTHOR
  1611.       John Ousterhout, University of California at Berkeley
  1612.       (ouster@sprite.berkeley.edu)
  1613.  
  1614.  
  1615.  
  1616.  
  1617.  
  1618.  
  1619.  
  1620.  
  1621.  
  1622.  
  1623.  
  1624.  
  1625.  
  1626.  
  1627.  
  1628.  
  1629.  
  1630.  
  1631.  
  1632.  
  1633.  
  1634.  
  1635.  
  1636.  
  1637.  
  1638.  
  1639.  
  1640.  
  1641.  
  1642.  
  1643.  
  1644.  
  1645.  
  1646.      Page 25                         (printed 2/26/90)
  1647.  
  1648.  
  1649.  
  1650.  
  1651.  
  1652.  
  1653.      Tcl_Backslash(tcl)          AMIGA 1.3          Tcl_Backslash(tcl)
  1654.  
  1655.  
  1656.  
  1657.      NAME
  1658.           Tcl_Backslash - parse a backslash sequence
  1659.  
  1660.      SYNOPSIS
  1661.           #include <tcl.h>
  1662.  
  1663.           char
  1664.           Tcl_Backslash(src, countPtr)
  1665.  
  1666.      ARGUMENTS
  1667.           char*src(in)
  1668.           Pointer to a string starting with a backslash.
  1669.  
  1670.           int*countPtr(out)
  1671.           If countPtr isn't NULL, *countPtr gets filled in with number
  1672.           of characters in the backslash sequence, including the
  1673.           backslash character.
  1674.  
  1675.  
  1676.      DESCRIPTION
  1677.           This is a utility procedure used by several of the Tcl
  1678.           commands.  It parses a backslash sequence and returns the
  1679.           single character corresponding to the sequence.
  1680.           Tcl_Backslash modifies *countPtr to contain the number of
  1681.           characters in the backslash sequence.  If src doesn't point
  1682.           to a backslash sequence understood by Tcl, then
  1683.           Tcl_Backslash returns a backslash as its result and
  1684.           *countPtr gets set to 1 (in this case the backslash
  1685.           character should not get any special treatment).
  1686.  
  1687.           See the Tcl manual entry for information on the valid
  1688.           backslash sequences.  All of the sequences described in the
  1689.           Tcl manual entry are supported by Tcl_Backslash except        |
  1690.           backslash-newline, which is not understood.
  1691.  
  1692.  
  1693.      KEYWORDS
  1694.           backslash, parse
  1695.  
  1696.  
  1697.  
  1698.  
  1699.  
  1700.  
  1701.  
  1702.  
  1703.  
  1704.  
  1705.  
  1706.  
  1707.  
  1708.  
  1709.  
  1710.  
  1711.  
  1712.      Page 1                                          (printed 2/26/90)
  1713.  
  1714.  
  1715.  
  1716.  
  1717.  
  1718.  
  1719.      Tcl_CreateCommand(tcl)      AMIGA 1.3      Tcl_CreateCommand(tcl)
  1720.  
  1721.  
  1722.  
  1723.      NAME
  1724.           Tcl_CreateCommand - define an application-specific command
  1725.           binding
  1726.  
  1727.      SYNOPSIS
  1728.           #include <tcl.h>
  1729.  
  1730.           Tcl_CreateCommand(interp, cmdName, proc, clientData, deleteProc)
  1731.  
  1732.      ARGUMENTS
  1733.           Tcl_Interp   *interp           (in)      Interpreter in
  1734.                                                    which to create new
  1735.                                                    command.
  1736.  
  1737.           char         *cmdName          (in)      Name of new
  1738.                                                    command.
  1739.                                                    Tcl_CreateCommand
  1740.                                                    makes a copy of
  1741.                                                    this value for its
  1742.                                                    own use.
  1743.  
  1744.           int          (*proc)()         (in)      Implementation of
  1745.                                                    new command:  proc
  1746.                                                    will be called
  1747.                                                    whenever cmdName is
  1748.                                                    invoked as a
  1749.                                                    command.
  1750.  
  1751.           ClientData   clientData        (in)      Arbitrary one-word
  1752.                                                    value to pass to
  1753.                                                    proc and
  1754.                                                    deleteProc.
  1755.  
  1756.           void         (*deleteProc)()   (in)      Procedure to call
  1757.                                                    before cmdName is
  1758.                                                    deleted from the
  1759.                                                    interpreter; allows
  1760.                                                    for command-
  1761.                                                    specific cleanup.
  1762.                                                    If NULL, then no
  1763.                                                    procedure is called
  1764.                                                    before the command
  1765.                                                    is deleted.
  1766.  
  1767.  
  1768.      DESCRIPTION
  1769.           Tcl_CreateCommand defines a new command in interp and
  1770.           associates it with procedure proc such that whenever cmdName
  1771.           is invoked as a Tcl command (via a call to Tcl_Eval) the Tcl
  1772.           interpreter will call proc to process the command.  If there
  1773.           is already a command cmdName associated with the
  1774.           interpreter, it is deleted.  Proc should have the following
  1775.  
  1776.  
  1777.  
  1778.      Page 1                                          (printed 2/26/90)
  1779.  
  1780.  
  1781.  
  1782.  
  1783.  
  1784.  
  1785.      Tcl_CreateCommand(tcl)      AMIGA 1.3      Tcl_CreateCommand(tcl)
  1786.  
  1787.  
  1788.  
  1789.           structure:
  1790.                int
  1791.                proc(clientData, interp, argc, argv)
  1792.                     ClientData clientData;
  1793.                     Tcl_Interp *interp;
  1794.                     int argc;
  1795.                     char *argv[];
  1796.                {
  1797.                }
  1798.           The clientData and interp parameters are copies of the
  1799.           clientData and interp arguments given to Tcl_CreateCommand.
  1800.           Typically, clientData points to an application-specific data
  1801.           structure that describes what to do when the command
  1802.           procedure is invoked.  Argc and argv describe the arguments
  1803.           to the command, argc giving the number of arguments
  1804.           (including the command name) and argv giving the values of
  1805.           the arguments as strings.  The argv array will contain
  1806.           argc+1 values; the first argc values point to the argument
  1807.           strings, and the last value is NULL.
  1808.  
  1809.           Proc must return an integer code that is either TCL_OK,
  1810.           TCL_ERROR, TCL_RETURN, TCL_BREAK, or TCL_CONTINUE.  See the
  1811.           Tcl overview man page for details on what these codes mean.
  1812.           Most normal commands will only return TCL_OK or TCL_ERROR.
  1813.           In addition, proc must set interp->result to point to a
  1814.           string value; in the case of a TCL_OK return code this gives
  1815.           the result of the command, and in the case of TCL_ERROR it
  1816.           gives an error message.  The Tcl_Return procedure provides
  1817.           an easy interface for setting the return value;  for
  1818.           complete details on how the interp->result field is managed,
  1819.           see the Tcl_Interp man page.  Before invoking a command
  1820.           procedure, Tcl_Eval sets interp->result to point to an empty
  1821.           string, so simple commands can return an empty result by
  1822.           doing nothing at all.
  1823.  
  1824.           The contents of the argv array are copies made by the Tcl
  1825.           interpreter for the use of proc.  Proc may alter any of the
  1826.           strings in argv.  However, the argv array is recycled as
  1827.           soon as proc returns, so proc must not set interp->result to
  1828.           point anywhere within the argv values (call Tcl_Return with
  1829.           status TCL_VOLATILE if you want to return something from the
  1830.           argv array).
  1831.  
  1832.           DeleteProc will be invoked when (if) cmdName is deleted.
  1833.           This can occur through a call to Tcl_DeleteCommand or
  1834.           Tcl_DeleteInterp, or by replacing cmdName in another call to
  1835.           Tcl_CreateCommand.  DeleteProc is invoked before the command
  1836.           is deleted, and gives the application an opportunity to
  1837.           release any structures associated with the command.
  1838.           DeleteProc should have the following form:
  1839.                void
  1840.                deleteProc(clientData)
  1841.  
  1842.  
  1843.  
  1844.      Page 2                                          (printed 2/26/90)
  1845.  
  1846.  
  1847.  
  1848.  
  1849.  
  1850.  
  1851.      Tcl_CreateCommand(tcl)      AMIGA 1.3      Tcl_CreateCommand(tcl)
  1852.  
  1853.  
  1854.  
  1855.                     ClientData clientData;
  1856.                {
  1857.                }
  1858.           The clientData argument will be the same as the clientData
  1859.           argument passed to Tcl_CreateCommand.
  1860.  
  1861.  
  1862.      KEYWORDS
  1863.           bind, command, create, interpreter
  1864.  
  1865.  
  1866.  
  1867.  
  1868.  
  1869.  
  1870.  
  1871.  
  1872.  
  1873.  
  1874.  
  1875.  
  1876.  
  1877.  
  1878.  
  1879.  
  1880.  
  1881.  
  1882.  
  1883.  
  1884.  
  1885.  
  1886.  
  1887.  
  1888.  
  1889.  
  1890.  
  1891.  
  1892.  
  1893.  
  1894.  
  1895.  
  1896.  
  1897.  
  1898.  
  1899.  
  1900.  
  1901.  
  1902.  
  1903.  
  1904.  
  1905.  
  1906.  
  1907.  
  1908.  
  1909.  
  1910.      Page 3                                          (printed 2/26/90)
  1911.  
  1912.  
  1913.  
  1914.  
  1915.  
  1916.  
  1917.      Tcl_CreateInterp(tcl)       AMIGA 1.3       Tcl_CreateInterp(tcl)
  1918.  
  1919.  
  1920.  
  1921.      NAME
  1922.           Tcl_CreateInterp - set up a new Tcl command interpreter
  1923.  
  1924.      SYNOPSIS
  1925.           #include <tcl.h>
  1926.  
  1927.           Tcl_Interp *
  1928.           Tcl_CreateInterp()
  1929.  
  1930.  
  1931.      DESCRIPTION
  1932.           Tcl_CreateInterp creates a new interpreter structure and
  1933.           returns a token for it.  The token is required in calls to
  1934.           most other Tcl procedures, such as Tcl_CreateCommand,
  1935.           Tcl_Eval, and Tcl_DeleteInterp.  Clients are only allowed to
  1936.           access the fields of Tcl_Interp structures related to
  1937.           command return values;  see the Tcl_Interp and
  1938.           Tcl_CreateCommand man pages for details.  The new
  1939.           interpreter is initialized with no defined variables and
  1940.           only the built-in Tcl commands.  To bind in additional
  1941.           commands, call Tcl_CreateCommand.
  1942.  
  1943.  
  1944.      KEYWORDS
  1945.           command, create, interpreter
  1946.  
  1947.  
  1948.  
  1949.  
  1950.  
  1951.  
  1952.  
  1953.  
  1954.  
  1955.  
  1956.  
  1957.  
  1958.  
  1959.  
  1960.  
  1961.  
  1962.  
  1963.  
  1964.  
  1965.  
  1966.  
  1967.  
  1968.  
  1969.  
  1970.  
  1971.  
  1972.  
  1973.  
  1974.  
  1975.  
  1976.      Page 1                                          (printed 2/26/90)
  1977.  
  1978.  
  1979.  
  1980.  
  1981.  
  1982.  
  1983.      Tcl_CreateTrace(tcl)        AMIGA 1.3        Tcl_CreateTrace(tcl)
  1984.  
  1985.  
  1986.  
  1987.      NAME
  1988.           Tcl_CreateTrace - arrange for command execution to be traced
  1989.  
  1990.      SYNOPSIS
  1991.           #include <tcl.h>
  1992.  
  1993.           Tcl_Trace
  1994.           Tcl_CreateTrace(interp, level, proc, clientData)
  1995.  
  1996.      ARGUMENTS
  1997.           Tcl_Interp   *interp          (in)      Interpreter in which
  1998.                                                   to create new
  1999.                                                   command.
  2000.  
  2001.           int          level            (in)      Only commands at or
  2002.                                                   below this nesting
  2003.                                                   level will be
  2004.                                                   traced.  1 means
  2005.                                                   top-level commands
  2006.                                                   only, 2 means top-
  2007.                                                   level commands or
  2008.                                                   those that are
  2009.                                                   invoked as immediate
  2010.                                                   consequences of
  2011.                                                   executing top-level
  2012.                                                   commands (procedure
  2013.                                                   bodies, bracketed
  2014.                                                   commands, etc.) and
  2015.                                                   so on.
  2016.  
  2017.           void         (*proc)()        (in)      Procedure to call
  2018.                                                   for each command
  2019.                                                   that's executed.
  2020.                                                   See below for
  2021.                                                   details on the
  2022.                                                   calling sequence.
  2023.  
  2024.           ClientData   clientData       (in)      Arbitrary one-word
  2025.                                                   value to pass to
  2026.                                                   proc.
  2027.  
  2028.  
  2029.      DESCRIPTION
  2030.           Tcl_CreateTrace arranges for command tracing.  From now on,
  2031.           proc will be invoked before Tcl calls command procedures to
  2032.           process commands in interp.  The return value from
  2033.           Tcl_CreateTrace is a token for the trace, which may be
  2034.           passed to Tcl_DeleteTrace to remove the trace.  There may be
  2035.           many traces in effect simultaneously for the same command
  2036.           interpreter.
  2037.  
  2038.           Proc should have the following structure:
  2039.  
  2040.  
  2041.  
  2042.      Page 1                                          (printed 2/26/90)
  2043.  
  2044.  
  2045.  
  2046.  
  2047.  
  2048.  
  2049.      Tcl_CreateTrace(tcl)        AMIGA 1.3        Tcl_CreateTrace(tcl)
  2050.  
  2051.  
  2052.  
  2053.                void
  2054.                proc(clientData, interp, level, command, cmdProc, cmdClientData, argc, argv)
  2055.                     ClientData clientData;
  2056.                     Tcl_Interp *interp;
  2057.                     int level;
  2058.                     char *command;
  2059.                     int (*cmdProc)();
  2060.                     ClientData cmdClientData;
  2061.                     int argc;
  2062.                     char *argv[];
  2063.                {
  2064.                }
  2065.           The clientData and interp parameters are copies of the
  2066.           corresponding arguments given to Tcl_CreateTrace.
  2067.           ClientData typically points to an application-specific data
  2068.           structure that describes what to do when proc is invoked.
  2069.           Level gives the nesting level of the command (1 for top-
  2070.           level commands passed to Tcl_Eval by the application, 2 for
  2071.           the next-level commands passed to Tcl_Eval as part of
  2072.           parsing or interpreting level-1 commands, and so on).
  2073.           Command points to a string containing the text of the
  2074.           command, before any argument substitution.  CmdProc contains
  2075.           the address of the command procedure that will be called to
  2076.           process the command (i.e. the proc argument of some previous
  2077.           call to Tcl_CreateCommand) and cmdClientData contains the
  2078.           associated client data for cmdProc (the clientData value
  2079.           passed to Tcl_CreateCommand).  Argc and argv give the final
  2080.           argument information that will be passed to cmdProc, after
  2081.           command, variable, and backslash substitution.  Proc must
  2082.           not modify the command or argv strings.
  2083.  
  2084.           Tracing will only occur for commands at nesting level less
  2085.           than or equal to the level parameter (i.e. the level
  2086.           parameter to proc will always be less than or equal to the
  2087.           level parameter to Tcl_CreateTrace).
  2088.  
  2089.           Calls to proc will be made by the Tcl parser immediately
  2090.           before it calls the command procedure for the command
  2091.           (cmdProc).  This occurs after argument parsing and
  2092.           substitution, so tracing for substituted commands occurs
  2093.           before tracing of the commands containing the substitutions.
  2094.           If there is a syntax error in a command, or if there is no
  2095.           command procedure associated with a command name, then no
  2096.           tracing will occur for that command.  If a string passed to
  2097.           Tcl_Eval contains multiple commands (bracketed, or on
  2098.           different lines) then multiple calls to proc will occur, one
  2099.           for each command.  The command string for each of these
  2100.           trace calls will reflect only a single command, not the
  2101.           entire string passed to Tcl_Eval.
  2102.  
  2103.  
  2104.      KEYWORDS
  2105.  
  2106.  
  2107.  
  2108.      Page 2                                          (printed 2/26/90)
  2109.  
  2110.  
  2111.  
  2112.  
  2113.  
  2114.  
  2115.      Tcl_CreateTrace(tcl)        AMIGA 1.3        Tcl_CreateTrace(tcl)
  2116.  
  2117.  
  2118.  
  2119.           command, create, interpreter, trace
  2120.  
  2121.  
  2122.  
  2123.  
  2124.  
  2125.  
  2126.  
  2127.  
  2128.  
  2129.  
  2130.  
  2131.  
  2132.  
  2133.  
  2134.  
  2135.  
  2136.  
  2137.  
  2138.  
  2139.  
  2140.  
  2141.  
  2142.  
  2143.  
  2144.  
  2145.  
  2146.  
  2147.  
  2148.  
  2149.  
  2150.  
  2151.  
  2152.  
  2153.  
  2154.  
  2155.  
  2156.  
  2157.  
  2158.  
  2159.  
  2160.  
  2161.  
  2162.  
  2163.  
  2164.  
  2165.  
  2166.  
  2167.  
  2168.  
  2169.  
  2170.  
  2171.  
  2172.  
  2173.  
  2174.      Page 3                                          (printed 2/26/90)
  2175.  
  2176.  
  2177.  
  2178.  
  2179.  
  2180.  
  2181.      Tcl_DeleteCommand(tcl)      AMIGA 1.3      Tcl_DeleteCommand(tcl)
  2182.  
  2183.  
  2184.  
  2185.      NAME
  2186.           Tcl_DeleteCommand - remove a command from a Tcl interpreter
  2187.  
  2188.      SYNOPSIS
  2189.           #include <tcl.h>
  2190.  
  2191.           Tcl_DeleteCommand(interp, cmdName)
  2192.  
  2193.      ARGUMENTS
  2194.           Tcl_Interp   *interp    (in)      Interpreter in which to
  2195.                                             delete command.
  2196.  
  2197.           char         *cmdName   (in)      Name of command to be
  2198.                                             deleted.
  2199.  
  2200.  
  2201.      DESCRIPTION
  2202.           This procedure deletes a command from a command interpreter.
  2203.           Once the call completes, attempts to invoke cmdName in
  2204.           interp will result in errors.  If cmdName isn't bound as a
  2205.           command in interp then Tcl_DeleteCommand does nothing.
  2206.           There are no restrictions on cmdName:  it may refer to a
  2207.           built-in command, an application-specific command, or a Tcl
  2208.           procedure.
  2209.  
  2210.  
  2211.      KEYWORDS
  2212.           command, delete, interpreter
  2213.  
  2214.  
  2215.  
  2216.  
  2217.  
  2218.  
  2219.  
  2220.  
  2221.  
  2222.  
  2223.  
  2224.  
  2225.  
  2226.  
  2227.  
  2228.  
  2229.  
  2230.  
  2231.  
  2232.  
  2233.  
  2234.  
  2235.  
  2236.  
  2237.  
  2238.  
  2239.  
  2240.      Page 1                                          (printed 2/26/90)
  2241.  
  2242.  
  2243.  
  2244.  
  2245.  
  2246.  
  2247.      Tcl_DeleteInterp(tcl)       AMIGA 1.3       Tcl_DeleteInterp(tcl)
  2248.  
  2249.  
  2250.  
  2251.      NAME
  2252.           Tcl_DeleteInterp - destroy a Tcl command interpreter
  2253.  
  2254.      SYNOPSIS
  2255.           #include <tcl.h>
  2256.  
  2257.           Tcl_DeleteInterp(interp)
  2258.  
  2259.      ARGUMENTS
  2260.           Tcl_Interp   *interp   (in)      Token for interpreter to be
  2261.                                            destroyed.
  2262.  
  2263.  
  2264.      DESCRIPTION
  2265.           This procedure destroys a command interpreter and releases
  2266.           all of the resources associated with it, including
  2267.           variables, procedures, and application-specific command
  2268.           bindings.  After Tcl_DeleteInterp returns the caller should
  2269.           never again use the interp token.
  2270.  
  2271.  
  2272.      KEYWORDS
  2273.           command, delete, interpreter
  2274.  
  2275.  
  2276.  
  2277.  
  2278.  
  2279.  
  2280.  
  2281.  
  2282.  
  2283.  
  2284.  
  2285.  
  2286.  
  2287.  
  2288.  
  2289.  
  2290.  
  2291.  
  2292.  
  2293.  
  2294.  
  2295.  
  2296.  
  2297.  
  2298.  
  2299.  
  2300.  
  2301.  
  2302.  
  2303.  
  2304.  
  2305.  
  2306.      Page 1                                          (printed 2/26/90)
  2307.  
  2308.  
  2309.  
  2310.  
  2311.  
  2312.  
  2313.      Tcl_DeleteTrace(tcl)        AMIGA 1.3        Tcl_DeleteTrace(tcl)
  2314.  
  2315.  
  2316.  
  2317.      NAME
  2318.           Tcl_DeleteTrace - remove a previously-established command
  2319.           trace
  2320.  
  2321.      SYNOPSIS
  2322.           #include <tcl.h>
  2323.  
  2324.           Tcl_DeleteTrace(interp, trace)
  2325.  
  2326.      ARGUMENTS
  2327.           Tcl_Interp   *interp   (in)      Interpreter containing
  2328.                                            trace.
  2329.  
  2330.           Tcl_Trace    trace     (in)      Token for trace to be
  2331.                                            removed (return value from
  2332.                                            previous call to
  2333.                                            Tcl_CreateTrace).
  2334.  
  2335.  
  2336.      DESCRIPTION
  2337.           This procedure removes a trace, so that no future calls will
  2338.           be made to the procedure associated with the trace.  After
  2339.           Tcl_DeleteTrace returns, the caller should never again use
  2340.           the trace token.
  2341.  
  2342.  
  2343.      KEYWORDS
  2344.           delete, interpreter, trace
  2345.  
  2346.  
  2347.  
  2348.  
  2349.  
  2350.  
  2351.  
  2352.  
  2353.  
  2354.  
  2355.  
  2356.  
  2357.  
  2358.  
  2359.  
  2360.  
  2361.  
  2362.  
  2363.  
  2364.  
  2365.  
  2366.  
  2367.  
  2368.  
  2369.  
  2370.  
  2371.  
  2372.      Page 1                                          (printed 2/26/90)
  2373.  
  2374.  
  2375.  
  2376.  
  2377.  
  2378.  
  2379.      Tcl_Eval(tcl)               AMIGA 1.3               Tcl_Eval(tcl)
  2380.  
  2381.  
  2382.  
  2383.      NAME
  2384.           Tcl_Eval - execute a Tcl command string
  2385.  
  2386.      SYNOPSIS
  2387.           #include <tcl.h>
  2388.  
  2389.           int
  2390.           Tcl_Eval(interp, cmd, flags, termPtr)
  2391.  
  2392.      ARGUMENTS
  2393.           Tcl_Interp   *interp      (in)      Interpreter in which to
  2394.                                               execute the command.
  2395.                                               String result will be
  2396.                                               stored in interp-
  2397.                                               >result.
  2398.  
  2399.           char         *cmd         (in)      Command (or sequence of
  2400.                                               commands) to execute.
  2401.  
  2402.           char         flags        (in)      Either TCL_BRACKET_TERM
  2403.                                               or 0.  If 0, then         |
  2404.                                               Tcl_Eval will process     |
  2405.                                               commands from cmd until   |
  2406.                                               it reaches the null       |
  2407.                                               character at the end of   |
  2408.                                               the string;  newlines     |
  2409.                                               will be treated as        |
  2410.                                               command separators.  If   |
  2411.                                               TCL_BRACKET_TERM, then    |
  2412.                                               Tcl_Eval will process     |
  2413.                                               comands from cmd until    |
  2414.                                               either it reaches a null  |
  2415.                                               character or it           |
  2416.                                               encounters a close        |
  2417.                                               bracket that isn't        |
  2418.                                               backslashed or enclosed   |
  2419.                                               in braces, at which       |
  2420.                                               point it will return;     |
  2421.                                               newlines will treated as  |
  2422.                                               white space, not as       |
  2423.                                               command separators.       |
  2424.                                               Under normal conditions,  |
  2425.                                               flags should be 0.
  2426.  
  2427.           char         **termPtr    (out)     If termPtr is non-NULL,   |
  2428.                                               Tcl_Eval fills in         |
  2429.                                               *termPtr with the         |
  2430.                                               address of the character  |
  2431.                                               just after the last one   |
  2432.                                               in the last command       |
  2433.                                               successfully executed     |
  2434.                                               (normally the null        |
  2435.  
  2436.  
  2437.  
  2438.      Page 1                                          (printed 2/26/90)
  2439.  
  2440.  
  2441.  
  2442.  
  2443.  
  2444.  
  2445.      Tcl_Eval(tcl)               AMIGA 1.3               Tcl_Eval(tcl)
  2446.  
  2447.  
  2448.  
  2449.                                               character at the end of   |
  2450.                                               cmd).  If an error        |
  2451.                                               occurs in the first       |
  2452.                                               command in cmd, then      |
  2453.                                               *termPtr will be set to   |
  2454.                                               cmd.
  2455.  
  2456.  
  2457.      DESCRIPTION
  2458.           Tcl_Eval parses commands from cmd and executes them in order
  2459.           until either an error occurs or Tcl_Eval reaches a
  2460.           terminating character (']' or ' ', depending on the value of
  2461.           flags).  The return value from Tcl_Eval is one of the Tcl
  2462.           return codes TCL_OK, TCL_ERROR, TCL_RETURN, TCL_BREAK, or
  2463.           TCL_CONTINUE, and interp->result will point to a string with
  2464.           additional information (result value or error message).
  2465.           This return information corresponds to the last command
  2466.           executed from cmd.
  2467.  
  2468.           During the processing of a command it is legal to make
  2469.           nested calls to Tcl_Eval (this is how conditionals, loops,
  2470.           and procedures are implemented).  If a code other than
  2471.           TCL_OK is returned from a nested Tcl_Eval invocation, then
  2472.           the caller should normally return immediately, passing that
  2473.           same return code back to its caller, and so on until the
  2474.           top-level application is reached.  A few commands, like for,
  2475.           will check for certain return codes, like TCL_BREAK and
  2476.           TCL_CONTINUE, and process them specially without returning.
  2477.  
  2478.           Tcl_Eval keeps track of how many nested Tcl_Eval invocations
  2479.           are in progress for interp.  If a code of TCL_RETURN,
  2480.           TCL_BREAK, or TCL_CONTINUE is about to be returned from the
  2481.           topmost Tcl_Eval invocation for interp, then Tcl_Eval
  2482.           converts the return code to TCL_ERROR and sets interp-
  2483.           >result to point to an error message indicating that the
  2484.           return, break, or continue command was invoked in an
  2485.           inappropriate place.  This means that top-level applications
  2486.           should never see a return code from Tcl_Eval other then
  2487.           TCL_OK or TCL_ERROR.
  2488.  
  2489.  
  2490.      KEYWORDS
  2491.           command, execute, interpreter
  2492.  
  2493.  
  2494.  
  2495.  
  2496.  
  2497.  
  2498.  
  2499.  
  2500.  
  2501.  
  2502.  
  2503.  
  2504.      Page 2                                          (printed 2/26/90)
  2505.  
  2506.  
  2507.  
  2508.  
  2509.  
  2510.  
  2511.      Tcl_Expr(tcl)               AMIGA 1.3               Tcl_Expr(tcl)
  2512.  
  2513.  
  2514.  
  2515.      NAME
  2516.           Tcl_Expr - evaluate an expression
  2517.  
  2518.      SYNOPSIS
  2519.           #include <tcl.h>
  2520.  
  2521.           int
  2522.           Tcl_Expr(interp, string, valuePtr)
  2523.  
  2524.      ARGUMENTS
  2525.           Tcl_Interp   *interp   (in)      Interpreter in whose
  2526.                                            context to evaluate string.
  2527.  
  2528.           char         *string   (in)      Expression to be evaluated.
  2529.  
  2530.           int          *valuePtr (out)     The expression's (integer)
  2531.                                            value will be stored here.
  2532.  
  2533.  
  2534.      DESCRIPTION
  2535.           Tcl_Expr is a utility procedure used by several of the Tcl
  2536.           commands.  Given a string whose contents are an expression
  2537.           of the form accepted by the expr command, this procedure
  2538.           evaluates the expression and returns the integer result in
  2539.           *valuePtr.  Normally Tcl_Expr returns TCL_OK as its result.
  2540.           However, if the expression contains a syntax error then
  2541.           Tcl_Expr returns TCL_ERROR and sets interp->result to point
  2542.           to an error message in the usual fashion.  Tcl_Expr may make
  2543.           nested calls to Tcl_Eval while parsing the expression;  if
  2544.           any of these calls returns an error then Tcl_Expr will
  2545.           return that same error information.  If an error is
  2546.           returned, then *valuePtr will not be modified.
  2547.  
  2548.  
  2549.      KEYWORDS
  2550.           evaluate, expression
  2551.  
  2552.  
  2553.  
  2554.  
  2555.  
  2556.  
  2557.  
  2558.  
  2559.  
  2560.  
  2561.  
  2562.  
  2563.  
  2564.  
  2565.  
  2566.  
  2567.  
  2568.  
  2569.  
  2570.      Page 1                                          (printed 2/26/90)
  2571.  
  2572.  
  2573.  
  2574.  
  2575.  
  2576.  
  2577.      Tcl_GetVar(tcl)             AMIGA 1.3             Tcl_GetVar(tcl)
  2578.  
  2579.  
  2580.  
  2581.      NAME
  2582.           Tcl_GetVar - return the value of a Tcl variable
  2583.  
  2584.      SYNOPSIS
  2585.           #include <tcl.h>
  2586.  
  2587.           char *
  2588.           Tcl_GetVar(interp, varName, global)
  2589.  
  2590.      ARGUMENTS
  2591.           Tcl_Interp   *interp   (in)      Interpreter in which to
  2592.                                            check for variable.
  2593.  
  2594.           char         *varName  (in)      Name of desired variable.
  2595.  
  2596.           int          global    (in)      If non-zero, then insist
  2597.                                            that varName be interpreted
  2598.                                            as a global variable
  2599.                                            regardless of whether a
  2600.                                            procedure invocation is in
  2601.                                            progress.
  2602.  
  2603.  
  2604.      DESCRIPTION
  2605.           Tcl_GetVar is a utility procedure used by several of the Tcl
  2606.           commands.  It returns the value of variable varName in
  2607.           interpreter interp.  If there isn't a Tcl command procedure
  2608.           being interpreted right now, or if global is non-zero, then
  2609.           varName is always treated as the name of a global variable.
  2610.           Otherwise, if a procedure is being interpreted, then varName
  2611.           will be treated as a local variable name, unless it has been
  2612.           declared global using the global command.  If no variable by
  2613.           the name varName exists right now, then the empty string is
  2614.           returned.
  2615.  
  2616.  
  2617.      KEYWORDS
  2618.           interpreter, global, local, variable
  2619.  
  2620.  
  2621.  
  2622.  
  2623.  
  2624.  
  2625.  
  2626.  
  2627.  
  2628.  
  2629.  
  2630.  
  2631.  
  2632.  
  2633.  
  2634.  
  2635.  
  2636.      Page 1                                          (printed 2/26/90)
  2637.  
  2638.  
  2639.  
  2640.  
  2641.  
  2642.  
  2643.      Tcl_Interp(tcl)             AMIGA 1.3             Tcl_Interp(tcl)
  2644.  
  2645.  
  2646.  
  2647.      NAME
  2648.           Tcl_Interp - client-visible fields of interpreter structures
  2649.  
  2650.      SYNOPSIS
  2651.           #include <tcl.h>
  2652.  
  2653.           typedef struct {
  2654.                char *result;
  2655.                int dynamic;
  2656.                int errorLine;
  2657.           } Tcl_Interp;
  2658.  
  2659.  
  2660.      DESCRIPTION
  2661.           The Tcl_CreateInterp procedure returns a pointer to a
  2662.           Tcl_Interp structure.  This pointer is then passed into
  2663.           other Tcl procedures to process commands in the interpreter
  2664.           and perform other operations on the interpreter.
  2665.           Interpreter structures contain many many fields that are
  2666.           used by Tcl, but only three that may be accessed by clients:
  2667.           result and dynamic.  These fields are used by Tcl command
  2668.           procedures to return strings that form part of the result of
  2669.           each command.  When Tcl_Eval returns, the string pointed to
  2670.           be the result field will be used by Tcl_Eval's caller as a
  2671.           return value or error message.
  2672.  
  2673.           The easiest way for command procedures to manipulate the
  2674.           result and dynamic fields is to call Tcl_Return;  Tcl_Return
  2675.           will hide all the details of managing these fields.  The
  2676.           description below is for those procedures that manipulate
  2677.           the fields directly.
  2678.  
  2679.           Whenever a command procedure returns, it must ensure that
  2680.           the result field of its interpreter points to the string
  2681.           being returned by the command.  Normally, these strings are
  2682.           assumed to be statically allocated;  in this case, the
  2683.           dynamic field must be zero.  As an alternative, a command
  2684.           procedure may dynamically allocate its return value and
  2685.           store a pointer to it in interp->result.  In this case, the
  2686.           command procedure must also set interp->dynamic to non-zero.
  2687.           If interp->dynamic is non-zero, then Tcl will free the space
  2688.           pointed to by interp->result before it invokes the next
  2689.           command.  If a client procedure overwrites interp->result
  2690.           field when interp->dynamic is non-zero, then it is
  2691.           responsible for freeing the old interp->result.  Once again,
  2692.           if clients use the Tcl_Result procedure to manage these
  2693.           fields, they need not worry about these issues.
  2694.  
  2695.           As part of processing each command, Tcl_Eval initializes
  2696.           interp->result and interp->dynamic just before calling the
  2697.           command procedure for the command.  The dynamic field will
  2698.           be initialized to zero, and interp->result will point to an
  2699.  
  2700.  
  2701.  
  2702.      Page 1                                          (printed 2/26/90)
  2703.  
  2704.  
  2705.  
  2706.  
  2707.  
  2708.  
  2709.      Tcl_Interp(tcl)             AMIGA 1.3             Tcl_Interp(tcl)
  2710.  
  2711.  
  2712.  
  2713.           empty string.  Commands that do not return any value can
  2714.           simply leave the fields alone.  Furthermore, the empty
  2715.           string pointed to by result is actually part of an array of
  2716.           TCL_RESULT_SIZE characters (approximately 200).  If a
  2717.           command wishes to return a short string, it can simply copy
  2718.           it to the area pointed to by interp->result.  Or, it can use
  2719.           the sprintf procedure to generate a short result string at
  2720.           the location pointed to by interp->result.
  2721.  
  2722.           If a command procedure calls a lower-level procedure that
  2723.           sets interp->result and interp->dynamic (such as a recursive
  2724.           instance of Tcl_Eval), then the command procedure must reset
  2725.           interp->result if it wishes to return a value different than
  2726.           that returned by the lower-level procedure.  As part of
  2727.           resetting interp->result, it must free the space if interp-
  2728.           >dynamic is set.  Once again, the easiest way to make sure
  2729.           this gets done right is to call Tcl_Result.
  2730.  
  2731.           The errorLine field is valid only after Tcl_Eval returns a    |
  2732.           TCL_ERROR return code.  In this situation the errorLine       |
  2733.           field identifies the line number of the command being         |
  2734.           executed when the error occurred.  The line numbers are       |
  2735.           relative to the command being executed:  1 means the first    |
  2736.           line of the command passed to Tcl_Eval, 2 means the second    |
  2737.           line, and so on.  ErrorLine should not normally be modified   |
  2738.           except by Tcl_Eval.
  2739.  
  2740.  
  2741.      KEYWORDS
  2742.           dynamic, interpreter, result
  2743.  
  2744.  
  2745.  
  2746.  
  2747.  
  2748.  
  2749.  
  2750.  
  2751.  
  2752.  
  2753.  
  2754.  
  2755.  
  2756.  
  2757.  
  2758.  
  2759.  
  2760.  
  2761.  
  2762.  
  2763.  
  2764.  
  2765.  
  2766.  
  2767.  
  2768.      Page 2                                          (printed 2/26/90)
  2769.  
  2770.  
  2771.  
  2772.  
  2773.  
  2774.  
  2775.      Tcl_Merge(tcl)              AMIGA 1.3              Tcl_Merge(tcl)
  2776.  
  2777.  
  2778.  
  2779.      NAME
  2780.           Tcl_Merge - generate a Tcl list from a collection of strings
  2781.  
  2782.      SYNOPSIS
  2783.           #include <tcl.h>
  2784.  
  2785.           char *
  2786.           Tcl_Merge(argc, argv)
  2787.  
  2788.      ARGUMENTS
  2789.           int          argc      (in)      Number of strings.
  2790.  
  2791.           char         *argv[]   (in)      Array of strings to combine
  2792.                                            into list.  Must have argc
  2793.                                            entries.
  2794.  
  2795.  
  2796.      DESCRIPTION
  2797.           Tcl_Merge is a utility procedure used by several of the Tcl
  2798.           commands.  Given a collection of strings, it generates a
  2799.           result string that has proper list structure, such that the
  2800.           index Tcl command may be used to extract out the original
  2801.           strings.  In order to do this, Tcl_Merge may have to add
  2802.           braces and/or backslashes.  The result string is dynamically
  2803.           allocated using malloc();  the caller must eventually
  2804.           release the space using free().
  2805.  
  2806.  
  2807.      KEYWORDS
  2808.           list, strings
  2809.  
  2810.  
  2811.  
  2812.  
  2813.  
  2814.  
  2815.  
  2816.  
  2817.  
  2818.  
  2819.  
  2820.  
  2821.  
  2822.  
  2823.  
  2824.  
  2825.  
  2826.  
  2827.  
  2828.  
  2829.  
  2830.  
  2831.  
  2832.  
  2833.  
  2834.      Page 1                                          (printed 2/26/90)
  2835.  
  2836.  
  2837.  
  2838.  
  2839.  
  2840.  
  2841.      Tcl_Return(tcl)             AMIGA 1.3             Tcl_Return(tcl)
  2842.  
  2843.  
  2844.  
  2845.      NAME
  2846.           Tcl_Return - set up a Tcl result string
  2847.  
  2848.      SYNOPSIS
  2849.           #include <tcl.h>
  2850.  
  2851.           Tcl_Return(interp, string, status)
  2852.  
  2853.      ARGUMENTS
  2854.           Tcl_Interp   *interp   (out)     Interpreter for which a
  2855.                                            return value is to be
  2856.                                            established.
  2857.  
  2858.           char         *string   (in)      String value to be
  2859.                                            returned, or NULL.
  2860.  
  2861.           int          status    (in)      Indicates the nature of
  2862.                                            string.  Must be either
  2863.                                            TCL_STATIC, TCL_DYNAMIC, or
  2864.                                            TCL_VOLATILE.
  2865.  
  2866.  
  2867.      DESCRIPTION
  2868.           Tcl_Return is a convenience routine used by several of the
  2869.           Tcl commands.  It arranges for string to be the return
  2870.           string for the current Tcl command in interp.  If status is
  2871.           TCL_STATIC it means that string refers to an area of static
  2872.           storage that is guaranteed to remain untouched until at
  2873.           least the next call to Tcl_Eval.  If status is TCL_DYNAMIC
  2874.           it means that string was allocated with a call to malloc()
  2875.           and is now the property of the Tcl system.  Tcl_Return will
  2876.           arrange for the string's storage to be released by calling
  2877.           free() when it is no longer needed.  The third possibility
  2878.           is for status to be TCL_VOLATILE.  This means that string
  2879.           points to an area of memory that is likely to be overwritten
  2880.           when Tcl_Return returns.  In this case Tcl_Return makes a
  2881.           copy of the string and arranges for the copy to be the
  2882.           return string for the current Tcl command.
  2883.  
  2884.           If string is NULL, then status is ignored and Tcl_Return
  2885.           re-initializes interp's result to point to the pre-allocated
  2886.           result area, with an empty string in the result area.
  2887.  
  2888.           In any of the above cases, if interp holds a dynamically-
  2889.           allocated result at the time of the Tcl_Return call, the old
  2890.           result's storage is released by calling free().
  2891.  
  2892.  
  2893.      KEYWORDS
  2894.           command, result, return value, interpreter
  2895.  
  2896.  
  2897.  
  2898.  
  2899.  
  2900.      Page 1                                          (printed 2/26/90)
  2901.  
  2902.  
  2903.  
  2904.  
  2905.  
  2906.  
  2907.      Tcl_SetVar(tcl)             AMIGA 1.3             Tcl_SetVar(tcl)
  2908.  
  2909.  
  2910.  
  2911.      NAME
  2912.           Tcl_SetVar - change the value of a Tcl variable
  2913.  
  2914.      SYNOPSIS
  2915.           #include <tcl.h>
  2916.  
  2917.           Tcl_SetVar(interp, varName, newValue, global)
  2918.  
  2919.      ARGUMENTS
  2920.           Tcl_Interp   *interp   (in)      Interpreter in which to
  2921.                                            change variable.
  2922.  
  2923.           char         *varName  (in)      Name of variable.
  2924.  
  2925.           char         *newValue (in)      New value for varName
  2926.  
  2927.           int          global    (in)      If non-zero, then insist on
  2928.                                            interpreting varName as a
  2929.                                            global variable, regardless
  2930.                                            of whether a procedure
  2931.                                            invocation is in progress.
  2932.  
  2933.  
  2934.      DESCRIPTION
  2935.           This is a utility procedure used by many of the Tcl
  2936.           commands.  It changes the value of variable varName in
  2937.           interpreter interp, such that future calls to Tcl_GetVar
  2938.           will return newValue as the value of varName.  Tcl_SetVar
  2939.           uses the same rules for selecting a global or local variable
  2940.           as Tcl_GetVar.  If varName doesn't already exist, then a new
  2941.           variable is created.  Tcl_SetVar copies both varName and
  2942.           newValue into its own private storage, so the caller may
  2943.           change the contents of these strings after Tcl_SetVar
  2944.           returns without affecting the variable's value.
  2945.  
  2946.  
  2947.      KEYWORDS
  2948.           interpreter, variable
  2949.  
  2950.  
  2951.  
  2952.  
  2953.  
  2954.  
  2955.  
  2956.  
  2957.  
  2958.  
  2959.  
  2960.  
  2961.  
  2962.  
  2963.  
  2964.  
  2965.  
  2966.      Page 1                                          (printed 2/26/90)
  2967.  
  2968.  
  2969.  
  2970.  
  2971.  
  2972.  
  2973.      Tcl_SplitList(tcl)          AMIGA 1.3          Tcl_SplitList(tcl)
  2974.  
  2975.  
  2976.  
  2977.      NAME
  2978.           Tcl_SplitList - break a Tcl list up into fields
  2979.  
  2980.      SYNOPSIS
  2981.           #include <tcl.h>
  2982.  
  2983.           int
  2984.           Tcl_SplitList(interp, list, argcPtr, argvPtr)
  2985.  
  2986.      ARGUMENTS
  2987.           Tcl_Interp   *interp    (out)     Interpreter to use for
  2988.                                             error reporting.
  2989.  
  2990.           char         *list      (in)      Pointer to a string with
  2991.                                             proper list structure.
  2992.  
  2993.           int          *argcPtr   (out)     Filled in with number of
  2994.                                             elements in list.
  2995.  
  2996.           char         ***argvPtr (out)     *argvPtr will be filled in
  2997.                                             with the address of an
  2998.                                             array of pointers to the
  2999.                                             strings that are the
  3000.                                             extracted elements of
  3001.                                             list.  There will be
  3002.                                             *argcPtr valid entries in
  3003.                                             the array.
  3004.  
  3005.  
  3006.      DESCRIPTION
  3007.           Tcl_SplitList is the inverse of Tcl_Merge.  Given a list, it
  3008.           extracts all of the elements of the list and returns an
  3009.           array of pointers to them using argcPtr and argvPtr.  While
  3010.           extracting the arguments, Tcl_SplitList obeys the usual
  3011.           rules for backslash substitutions and braces.  The area of
  3012.           memory pointed to by *argvPtr is dynamically allocated;  in
  3013.           addition to the array of pointers, it also holds copies of
  3014.           all the list elements.  It is the caller's responsibility to
  3015.           free up all of this storage by calling
  3016.  
  3017.           free((char *) *argvPtr)
  3018.  
  3019.           when the list elements are no longer needed.
  3020.  
  3021.           Tcl_SplitList normally returns TCL_OK, which means the list
  3022.           was successfully parsed.  If there was a syntax error in
  3023.           list, then TCL_ERROR is returned and interp->result will
  3024.           point to an error message describing the problem.
  3025.  
  3026.  
  3027.      KEYWORDS
  3028.           list, split, strings
  3029.  
  3030.  
  3031.  
  3032.      Page 1                                          (printed 2/26/90)
  3033.  
  3034.  
  3035.  
  3036.  
  3037.  
  3038.  
  3039.      Tcl_SplitList(tcl)          AMIGA 1.3          Tcl_SplitList(tcl)
  3040.  
  3041.  
  3042.  
  3043.  
  3044.  
  3045.  
  3046.  
  3047.  
  3048.  
  3049.  
  3050.  
  3051.  
  3052.  
  3053.  
  3054.  
  3055.  
  3056.  
  3057.  
  3058.  
  3059.  
  3060.  
  3061.  
  3062.  
  3063.  
  3064.  
  3065.  
  3066.  
  3067.  
  3068.  
  3069.  
  3070.  
  3071.  
  3072.  
  3073.  
  3074.  
  3075.  
  3076.  
  3077.  
  3078.  
  3079.  
  3080.  
  3081.  
  3082.  
  3083.  
  3084.  
  3085.  
  3086.  
  3087.  
  3088.  
  3089.  
  3090.  
  3091.  
  3092.  
  3093.  
  3094.  
  3095.      Page 2                                          (printed 2/26/90)
  3096.  
  3097.  
  3098.  
  3099.  
  3100.  
  3101.  
  3102.  
  3103.  
  3104.  
  3105.      Tcl_StringMatch(tcl)        AMIGA 1.3        Tcl_StringMatch(tcl)
  3106.  
  3107.  
  3108.  
  3109.      NAME                                                               |
  3110.           Tcl_StringMatch - test whether a string matches a pattern     |
  3111.  
  3112.      SYNOPSIS                                                           |
  3113.           #include <tcl.h>                                              |
  3114.  
  3115.           int                                                           |
  3116.           Tcl_StringMatch(string, pattern)                              |
  3117.  
  3118.      ARGUMENTS                                                          |
  3119.           char         *string    (in)                                       ||
  3120.                                             String to test.             |
  3121.  
  3122.           char         *pattern   (in)                                       ||
  3123.                                             Pattern to match against    |
  3124.                                             string.  May contain        |
  3125.                                             special characters from     |
  3126.                                             the set *?\[].              |
  3127.  
  3128.  
  3129.      DESCRIPTION                                                        |
  3130.           This utility procedure determines whether a string matches a  |
  3131.           given pattern.  If it does, then Tcl_StringMatch returns 1.   |
  3132.           Otherwise Tcl_StringMatch returns 0.  The algorithm used for  |
  3133.           matching is the same algorithm used in the ``string match''   |
  3134.           Tcl command and is similar to the algorithm used by the C-    |
  3135.           shell for file name matching;  see the Tcl manual entry for   |
  3136.           details.                                                      |
  3137.  
  3138.  
  3139.      KEYWORDS                                                           |
  3140.           match, pattern, string
  3141.  
  3142.  
  3143.  
  3144.  
  3145.  
  3146.  
  3147.  
  3148.  
  3149.  
  3150.  
  3151.  
  3152.  
  3153.  
  3154.  
  3155.  
  3156.  
  3157.  
  3158.  
  3159.  
  3160.  
  3161.  
  3162.  
  3163.  
  3164.      Page 1                                          (printed 2/26/90)
  3165.  
  3166.  
  3167.  
  3168.  
  3169.  
  3170.  
  3171.      Tcl_WatchInterp(tcl)        AMIGA 1.3        Tcl_WatchInterp(tcl)
  3172.  
  3173.  
  3174.  
  3175.      NAME                                                               |
  3176.           Tcl_WatchInterp - arrange for callback when interpreter is    |
  3177.           deleted.                                                      |
  3178.  
  3179.      SYNOPSIS                                                           |
  3180.           #include <tcl.h>                                              |
  3181.  
  3182.           Tcl_WatchInterp(interp, proc, clientData)                     |
  3183.  
  3184.      ARGUMENTS                                                          |
  3185.           Tcl_Interp   *interp           (in)                                ||
  3186.                                                    Interpreter whose    |
  3187.                                                    deletion should be   |
  3188.                                                    monitored.           |
  3189.  
  3190.           char         *cmdName          (in)                                ||
  3191.                                                    Name of new          |
  3192.                                                    command.             |
  3193.  
  3194.           void         (*proc)()         (in)                                ||
  3195.                                                    Procedure to invoke  |
  3196.                                                    just before interp   |
  3197.                                                    is deleted.          |
  3198.  
  3199.           ClientData   clientData        (in)                                ||
  3200.                                                    Arbitrary one-word   |
  3201.                                                    value to pass to     |
  3202.                                                    proc.                |
  3203.  
  3204.  
  3205.      DESCRIPTION                                                        |
  3206.           Tcl_WatchInterp arranges for proc to be called by             |
  3207.           Tcl_DeleteInterp if/when interp is deleted at some future     |
  3208.           time.  Proc will be invoked just before the interpreter is    |
  3209.           deleted, but the interpreter will still be valid at the time  |
  3210.           of the call.  Proc should have the following structure:       |
  3211.                void                                                     |
  3212.                proc(clientData, interp)                                 |
  3213.                     ClientData clientData;                              |
  3214.                     Tcl_Interp *interp;                                 |
  3215.                {                                                        |
  3216.                }                                                        |
  3217.           The clientData and interp parameters are copies of the        |
  3218.           clientData and interp arguments given to Tcl_WatchInterp.     |
  3219.           Typically, clientData points to an application-specific data  |
  3220.           structure that proc uses to perform cleanup when an           |
  3221.           interpreter is about to go away.  Proc does not return a      |
  3222.           value.                                                        |
  3223.  
  3224.  
  3225.      KEYWORDS                                                           |
  3226.           callback, delete, interpreter
  3227.  
  3228.  
  3229.  
  3230.      Page 1                                          (printed 2/26/90)
  3231.