### Define a new Module for Installation Source: https://core.tcl-lang.org/tcllib/dir?ci=trunk&name=modules/ftp/docs/trunk/embedded/md/tcllib/files/devdoc/tcllib_devguide Defines a new module to be installed by the Tcllib installer. It specifies the module's name and actions for installing code, documentation, and examples. The actions are predefined types that dictate how files are handled. ```APIDOC Module name code-action doc-action example-action name: The name of the module (e.g., "modules/name") code-action: Action for installing packages and their index. _tcl: Copy all .tcl files. _tcr: Copy .tcl files including subdirectories. _tci: Copy .tcl files and tclIndex.tcl. _msg: Copy .tcl files and msgs subdirectory. _doc: Copy .tcl files and mpformats subdirectory. _tex: Copy .tcl files and .tex files. doc-action: Action for installing package documentation. _null: No documentation. _man: Process .man files to nroff/HTML. example-action: Action for installing examples. _null: No examples. _exa: Copy "examples/name" recursively. ``` -------------------------------- ### Run Tcllib HTTPD Example Server Source: https://core.tcl-lang.org/tcllib/dir?ci=trunk&name=modules/ftp/docs/trunk/embedded/md/tcllib/files/modules/httpd/httpd These shell commands provide instructions on how to navigate to the Tcllib sandbox directory and execute the provided `httpd.tcl` example script, which demonstrates a complete HTTPD server setup. ```Shell cd ~/tcl/sandbox/tcllib tclsh examples/httpd.tcl ``` -------------------------------- ### installer.tcl Script Command-Line Options Reference Source: https://core.tcl-lang.org/tcllib/dir?ci=trunk&name=modules/ftp/docs/trunk/embedded/md/tcllib/files/devdoc/tcllib_installer Detailed reference for all command-line options supported by the `installer.tcl` script, governing installation paths, included components, and operational modes (GUI/CLI). ```APIDOC installer.tcl Options: -help: Show the list of options explained here on the standard output channel and exit. +excluded: Include deprecated packages in the installation. -no-gui: Force command line operation of the installer. -no-wait: In CLI mode, skip confirmation query and immediately jump to installation. -app-path : Declare the destination path for applications. -example-path : Declare the destination path for examples. -html-path : Declare the destination path for HTML documentation. -nroff-path : Declare the destination path for nroff manpages. -pkg-path : Declare the destination path for packages. -dry-run: Run the installer without modifying the destination directories. -simulate: Run the installer without modifying the destination directories. -apps: Activate the installation of applications (default). -no-apps: Deactivate the installation of applications. -examples: Activate the installation of examples (default). -no-examples: Deactivate the installation of examples. -pkgs: Activate the installation of packages (default). -no-pkgs: Deactivate the installation of packages. -html: Activate the installation of HTML documentation (default on Windows). -no-html: Deactivate the installation of HTML documentation. -nroff: Activate the installation of nroff manpages (default on Unix). -no-nroff: Deactivate the installation of nroff manpages. ``` -------------------------------- ### Snit: install Command API and Usage Source: https://core.tcl-lang.org/tcllib/dir?ci=trunk&name=modules/ftp/docs/trunk/embedded/md/tcllib/files/modules/snit/snit Documents the `install` command in Snit, used to create and install a new object as a component. It details the command's signature, purpose, and provides comparative Tcl examples showing its equivalence to direct object creation and assignment for `snit::type` components. ```APIDOC install compName using objType objName args... - compName: The name of the component to install. - objType: The type of the object to create. - objName: The name for the new object. - args: Additional arguments passed to the 'objType' command. Purpose: Creates a new object of 'objType' named 'objName' and installs it as 'compName'. Notes: 'compName' must be declared with `component` or referenced in `delegate`. For `snit::widget` or `snit::widgetadaptor`, delegated options receive default values from Tk option database. Cannot be used for type components. ``` ```tcl install myComp using myObjType $self.myComp args... set myComp [myObjType $self.myComp args...] ``` -------------------------------- ### Direct Tcllib Installation Script Execution Source: https://core.tcl-lang.org/tcllib/dir?ci=trunk&name=modules/ftp/docs/trunk/embedded/md/tcllib/files/devdoc/tcllib_installer Illustrates direct command-line execution of Tcllib's installation scripts, `sak.tcl` and `installer.tcl`. This approach is particularly relevant for Windows environments or when bypassing `make` wrappers, and includes how to access help. ```Tcl ./sak.tcl critcl ``` ```Tcl ./sak.tcl critcl ./installer.tcl ``` ```Tcl ./installer.tcl -help ``` -------------------------------- ### Tcllib Installation via Make Commands Source: https://core.tcl-lang.org/tcllib/dir?ci=trunk&name=modules/ftp/docs/trunk/embedded/md/tcllib/files/devdoc/tcllib_installer Commands used for installing Tcllib components through the `make` utility, including `make install-binaries` and the standard `configure ; make install` sequence for Unix-like systems. ```Shell make install-binaries ``` ```Shell configure ; make install ``` -------------------------------- ### Create Snit Component using install Command Source: https://core.tcl-lang.org/tcllib/dir?ci=trunk&name=modules/ftp/docs/trunk/embedded/md/tcllib/files/modules/snit/snit This example shows an alternative way to create and install a component using the 'install' command within a Snit type's constructor. It achieves the same result as direct assignment but is particularly useful for 'snit::widget' and 'snit::widgetadaptor' types for proper option initialization. ```tcl snit::type dog { component mytail constructor {args} { install mytail using tail %AUTO% -partof $self $self configurelist $args } method wag {} { $mytail wag } } ``` -------------------------------- ### Standard Tcllib Installation on Unix-like Systems Source: https://core.tcl-lang.org/tcllib/dir?ci=trunk&name=modules/ftp/docs/trunk/embedded/md/tcllib/files/devdoc/tcllib_installer This snippet provides the standard non-interactive installation commands for Tcllib on Unix-like environments. It automatically determines installation paths for packages, applications, and manpages, and includes the Tcllibc binary package which requires Critcl. ```Shell ./configure make install # or just make ``` -------------------------------- ### Comprehensive Procedure Tracing Example in Tcl Source: https://core.tcl-lang.org/tcllib/dir?ci=trunk&name=modules/ftp/docs/trunk/embedded/md/tcllib/files/modules/log/logger A complete Tcl example demonstrating the setup and usage of procedure tracing. It includes defining a trace callback, initializing a logger, registering the callback, defining procedures to be traced, adding them to the trace list, enabling tracing, and executing the traced code. ```Tcl proc tracecmd { dict } { puts $dict } set log [::logger::init example] ${log}::logproc trace tracecmd proc foo { args } { puts "In foo" bar 1 return "foo_result" } proc bar { x } { puts "In bar" return "bar_result" } ${log}::trace add foo bar ${log}::trace on foo ``` -------------------------------- ### Defining Simple Examples with `example` Command in Tcllib Doctools Source: https://core.tcl-lang.org/tcllib/dir?ci=trunk&name=modules/ftp/docs/trunk/embedded/md/tcllib/files/modules/doctools/doctools_lang_intro Illustrates how to use the `example` command in Tcllib doctools to embed a simple, single-argument text example. The content provided to the `example` command must be plain text and must not contain any markup. ```Tcl [example { ... [list_begin enumerated] ... }] ``` -------------------------------- ### Defining Multi-line Examples with `example_begin`/`example_end` in Tcllib Doctools Source: https://core.tcl-lang.org/tcllib/dir?ci=trunk&name=modules/ftp/docs/trunk/embedded/md/tcllib/files/modules/doctools/doctools_lang_intro Shows the usage of the `example_begin` and `example_end` commands for defining multi-line examples that can include regular text markup. This pair of commands encloses a block of text, allowing for more complex example structures, though text structure commands are not permitted within these blocks. ```Tcl [example_begin] ... [list_begin enumerated] ... [example_end] ``` -------------------------------- ### Example of Console Appender Usage in Tcl Source: https://core.tcl-lang.org/tcllib/dir?ci=trunk&name=modules/ftp/docs/trunk/embedded/md/tcllib/files/modules/log/loggerUtils Illustrates initializing a logger, applying a console appender to it, and then logging an error message to see the formatted output. This snippet shows a basic setup for logging to the console. ```Tcl set log [logger::init testLog] logger::utils::applyAppender -appender console -serviceCmd $log ${log}::error "this is an error" ``` -------------------------------- ### Tcl Command: example_begin Source: https://core.tcl-lang.org/tcllib/dir?ci=trunk&name=modules/ftp/docs/trunk/embedded/md/tcllib/files/modules/doctools/doctools_lang_cmdref Initiates an example block. All text following this command until the next 'example_end' command is considered part of the example, with line breaks, spaces, and tabs preserved literally. Examples cannot be nested. ```APIDOC example_begin Text structure. This commands starts an example. All text until the next **example_end** belongs to the example. Line breaks, spaces, and tabs have to be preserved literally. Examples cannot be nested. ``` -------------------------------- ### Example of Auto-Applying Console Appender in Tcl Source: https://core.tcl-lang.org/tcllib/dir?ci=trunk&name=modules/ftp/docs/trunk/embedded/md/tcllib/files/modules/log/loggerUtils Shows how to configure `logger::utils::applyAppender` globally for auto-application, then initialize a logger to automatically get the configured appender. This simplifies appender setup for new logger instances. ```Tcl logger::utils::applyAppender -appender console set log [logger::init applyAppender-3] ${log}::error "this is an error" ``` -------------------------------- ### FA Method: Get Unreachable States Source: https://core.tcl-lang.org/tcllib/dir?ci=trunk&name=modules/ftp/docs/trunk/embedded/md/tcllib/files/modules/grammar_fa/fa Documents the `unreachable_states` method for Finite Automata, which returns the set of states that are not reachable from any start state by any number of transitions. An example Tcl expression is provided to illustrate its calculation. ```APIDOC * faName **unreachable_states** Returns the set of states which are not reachable from any start state by any number of transitions. This is ``` ```Tcl [faName states] - [faName reachable_states] ``` -------------------------------- ### Exclude a Module from Installation Source: https://core.tcl-lang.org/tcllib/dir?ci=trunk&name=modules/ftp/docs/trunk/embedded/md/tcllib/files/devdoc/tcllib_devguide Signals to the installer that a specified module should not be installed. This command is typically used to mark deprecated modules within Tcllib. ```APIDOC Exclude name name: The name of the module to exclude. ``` -------------------------------- ### Snit Component Initialization (Recommended `install` Method) Source: https://core.tcl-lang.org/tcllib/dir?ci=trunk&name=modules/ftp/docs/trunk/embedded/md/tcllib/files/modules/snit/snitfaq Demonstrates the recommended way to initialize a Snit component using the `install` command. This method allows Snit to query the option database for delegated options and properly configure the component, ensuring explicit options override database values. ```Tcl snit::widget mywidget { delegate option -background to myComp constructor {args} { install myComp using text $win.text -foreground black } } ``` -------------------------------- ### Snit Component Initialization (Recommended Method with install) Source: https://core.tcl-lang.org/tcllib/dir?ci=trunk&name=modules/ftp/docs/trunk/embedded/md/tcllib/files/modules/snit/snit Demonstrates the recommended way to initialize a Snit component using the `install` command. This method allows Snit to query the option database for delegated options and properly configure the component, ensuring correct initialization and option handling. ```Tcl snit::widget mywidget { delegate option -background to myComp constructor {args} { install myComp using text $win.text -foreground black } } ``` -------------------------------- ### Run Tcllib Graphical Installer on Unix Source: https://core.tcl-lang.org/tcllib/dir?ci=trunk&name=modules/ftp/docs/trunk/embedded/md/tcllib/files/devdoc/tcllib_installer This command invokes the graphical installer for Tcllib on Unix-like systems. Note that this installer handles only Tcl packages, applications, and documentation, but does not manage the binary Tcllibc. ```Shell ./installer.tcl ``` -------------------------------- ### Define a new Application for Installation Source: https://core.tcl-lang.org/tcllib/dir?ci=trunk&name=modules/ftp/docs/trunk/embedded/md/tcllib/files/devdoc/tcllib_devguide Defines a new application to be installed by the Tcllib installer. The application's files are expected to be found in the 'apps' directory under the specified name. ```APIDOC Application name name: The name of the application (e.g., "apps/name") ``` -------------------------------- ### Using `install` for Snit Component Creation Source: https://core.tcl-lang.org/tcllib/dir?ci=trunk&name=modules/ftp/docs/trunk/embedded/md/tcllib/files/modules/snit/snitfaq This Tcl snippet demonstrates the `install` command within a Snit type's constructor. It provides a cleaner and more robust way to create and assign owned components compared to direct `set` commands, especially beneficial for `snit::widget` and `snit::widgetadaptor` types due to its integration with the Tk option database. ```Tcl snit::type dog { component mytail constructor {args} { # set mytail [tail %AUTO% -partof $self] install mytail using tail %AUTO% -partof $self $self configurelist $args } } ``` -------------------------------- ### Selective Tcllib Component Installation on Unix Source: https://core.tcl-lang.org/tcllib/dir?ci=trunk&name=modules/ftp/docs/trunk/embedded/md/tcllib/files/devdoc/tcllib_installer These commands allow for selectively installing different parts of the Tcllib project on Unix-like systems. Options include installing binaries (Tcllibc, requiring Critcl), Tcl packages, applications, or documentation separately. ```Shell make install-binaries # Tcllibc. Requires an installation of Critcl. make install-tcl # Tcl packages and applications. make install-libraries # Tcl packages alone. make install-applications # Applications alone. make install-doc # Nroff manpages. ``` -------------------------------- ### Create Doctools Definition List Example Source: https://core.tcl-lang.org/tcllib/dir?ci=trunk&name=modules/ftp/docs/trunk/embedded/md/tcllib/files/modules/doctools/doctools_lang_intro Illustrates the structure of a definition list using `doctools` commands. This example shows how to begin a list with `list_begin definitions`, define terms with `def`, and include command references with `cmd` within the list items, concluding with `list_end`. ```Tcl [**list_begin** definitions] [**def** [const arg]] ([cmd arg_def]) This opens an argument (declaration) list. It is a specialized form of a definition list where the term is an argument name, with its type and i/o-mode. [**def** [const itemized]] ([cmd item]) This opens a general itemized list. [**def** [const tkoption]] ([cmd tkoption_def]) This opens a widget option (declaration) list. It is a specialized form of a definition list where the term is the name of a configuration option for a widget, with its name and class in the option database. [**list_end**] ``` -------------------------------- ### grammar::me::cpu Class Constructor API Source: https://core.tcl-lang.org/tcllib/dir?ci=trunk&name=modules/ftp/docs/trunk/embedded/md/tcllib/files/modules/grammar_me/me_cpu Documents the `::grammar::me::cpu` command, which serves as the constructor for new ME virtual machine objects. It creates a new instance named `meName` and requires `matchcode` to define the parsing instructions. This command establishes the primary entry point for interacting with the ME machine. ```APIDOC Class: ::grammar::me::cpu Constructor: ::grammar::me::cpu meName matchcode meName (string): The name of the new ME machine object (global Tcl command). matchcode (string): The match instructions the machine has to execute while parsing the input stream. (Refer to grammar::me::cpu::core for structure.) ``` -------------------------------- ### Invoke Tcllib Installer on Windows via Command Line Source: https://core.tcl-lang.org/tcllib/dir?ci=trunk&name=modules/ftp/docs/trunk/embedded/md/tcllib/files/devdoc/tcllib_installer This command demonstrates how to run the Tcllib installer script from a DOS window on Windows, particularly when Tk is not available or .tcl files are not associated. This installer only handles Tcl packages, applications, and documentation, not the binary Tcllibc. ```Shell ./installer.tcl ``` -------------------------------- ### Tcllib grammar::me::tcl API Reference Source: https://core.tcl-lang.org/tcllib/dir?ci=trunk&name=modules/ftp/docs/trunk/embedded/md/tcllib/files/modules/grammar_me/me_tcl Detailed documentation for the `::grammar::me::tcl` ensemble command and its subcommands, covering initialization, state querying, and token/AST manipulation for the ME virtual machine. ```APIDOC ::grammar::me::tcl (Ensemble Command) Description: Provides access to commands for ME virtual machine initialization and information retrieval. Methods: cmd (...) Description: Ensemble command providing access to the commands listed in this section. See the methods themselves for detailed specifications. init (nextcmd: command_prefix, tokmap?: dict) -> string Description: (Re)initializes the machine. Must be invoked before any other command of this package. Parameters: nextcmd: A command prefix representing the input stream of characters. Invoked by the machine when a new character is required. The instruction for handling this is 'ict_advance'. The callback must return either an empty list (signal for end of input stream) or a 4-element list [token, lexeme_attribute, line_number, column_index]. tokmap (optional): A dictionary mapping tokens to integer numbers. If present, these numbers impose an order used by 'ict_match_tokrange'. If not specified, lexicographic order of token names is used. Returns: The empty string. lc (location: int) -> list[int, int] Description: Converts the location of a token (offset in input stream) into its associated line number and column index. Parameters: location: The offset in the input stream. Returns: A 2-element list [line_number, column_index]. Notes: - Cannot convert locations not yet reached by the machine (e.g., if 7 tokens read, can convert offsets 0-6, but nothing beyond). - State used for conversion is cleared after a call to 'init', making further conversions impossible until the machine reads tokens again. tok (from: int, to?: int) -> list[list[any, any, int, int]] Description: Returns a Tcl list containing the part of the input stream between the specified locations (inclusive). Parameters: from: The starting location (offset) in the input stream. to (optional): The ending location (offset) in the input stream. Defaults to 'from' if not specified. Returns: A Tcl list where each element is a 4-element list [token, associated_lexeme, line_number, column_index]. Notes: Places the same restrictions on its location arguments as ::grammar::me::tcl::lc. tokens () -> int Description: Returns the number of tokens currently known to the ME virtual machine. Returns: An integer representing the count of known tokens. sv () -> AST Description: Returns the current semantic value (SV) stored in the machine. This is an abstract syntax tree as specified in grammar::me_ast, section AST VALUES. Returns: An abstract syntax tree. ast () -> AST Description: Returns the abstract syntax tree currently at the top of the AST stack of the ME virtual machine. This is an abstract syntax tree as specified in grammar::me_ast, section AST VALUES. Returns: An abstract syntax tree. astall () -> list[AST] Description: Returns the whole stack of abstract syntax trees currently known to the ME virtual machine. Returns: A list of abstract syntax trees. The top of the stack resides at the end of the list. ctok () -> any Description: Returns the current token considered by the ME virtual machine. Returns: The current token. nc () -> dict[str, any] Description: Returns the contents of the nonterminal cache. Returns: A dictionary mapping from "symbol,location" to match information. next () -> command_prefix Description: Returns the next token callback as specified during initialization of the ME virtual machine. Returns: The command prefix used for the next token callback. ord () -> dict Description: Returns a dictionary containing the tokmap specified during initialization of the ME virtual machine. Returns: The tokmap dictionary. Variables: ::grammar::me::tcl::ok: any Description: Contains the current match status OK. Provided as a variable instead of a command. ``` -------------------------------- ### Tcl Command: example_end Source: https://core.tcl-lang.org/tcllib/dir?ci=trunk&name=modules/ftp/docs/trunk/embedded/md/tcllib/files/modules/doctools/doctools_lang_cmdref Closes an example block that was previously started by the 'example_begin' command. This command signifies the end of the literal example content. ```APIDOC example_end Text structure. This command closes the example started by the last **example_begin**. ``` -------------------------------- ### Build and Install Tcllib with Accelerators on Unix Source: https://core.tcl-lang.org/tcllib/dir?ci=trunk&name=modules/ftp/docs/trunk/embedded/md/tcllib/files/devdoc/tcllib_installer These commands are used to build and install Tcllib along with its C-based accelerators in a Unix-like environment. This process requires the Critcl dependency and is designed to boost the performance of packages utilizing these accelerators. ```Shell ./configure make # or make install ``` -------------------------------- ### docidx Markup: Document Structure with Initial Configuration Commands Source: https://core.tcl-lang.org/tcllib/dir?ci=trunk&name=modules/ftp/docs/trunk/embedded/md/tcllib/files/modules/doctools/docidx_lang_intro This snippet demonstrates the allowed markup before the `index_begin` command, specifically showing how `include` and `vset` can be used to set or import configuration settings relevant to the table of contents at the document's start. ```docidx Markup [include FILE] [vset VAR VALUE] [index_begin GROUPTITLE TITLE] ... [index_end] ``` -------------------------------- ### Create Tcl Objects with Options at Instantiation Source: https://core.tcl-lang.org/tcllib/dir?ci=trunk&name=modules/ftp/docs/trunk/embedded/md/tcllib/files/modules/snit/snitfaq Demonstrates how to create new instances of a Tcl object (e.g., 'dog') and set initial option values during the creation process. Shows examples for 'spot' with multiple options and 'fido' with a single option. ```Tcl % dog spot -breed beagle -color "mottled" -akc 1 -shots 1 ::spot % dog fido -shots 1 ::fido % ``` -------------------------------- ### Get Start States Source: https://core.tcl-lang.org/tcllib/dir?ci=trunk&name=modules/ftp/docs/trunk/embedded/md/tcllib/files/modules/grammar_fa/fa Returns the set of all states that are currently marked as *start* states (also known as *initial* states) within the automaton `faName`. ```APIDOC faName startstates ``` -------------------------------- ### transfer::connect Object API Synopsis Source: https://core.tcl-lang.org/tcllib/dir?ci=trunk&name=modules/ftp/docs/trunk/embedded/md/tcllib/files/modules/transfer/connect This section outlines the primary commands and methods available for `transfer::connect` objects, including object creation, method invocation, destruction, and connection initiation. ```APIDOC transfer::connect objectName ?options...? objectName method ?arg arg ...? objectName destroy objectName connect command ``` -------------------------------- ### grammar::me::cpu::core Tcl Package API Reference Source: https://core.tcl-lang.org/tcllib/dir?ci=trunk&name=modules/ftp/docs/trunk/embedded/md/tcllib/files/modules/grammar_me/me_cpucore Detailed API reference for the `grammar::me::cpu::core` Tcl package, outlining available commands for ME virtual machine state manipulation and querying. ```APIDOC grammar::me::cpu::core: disasm(asm: string) description: Disassembles the provided assembly code. parameters: asm: The assembly code string to be disassembled. asm(asm: string) description: Assembles the provided assembly code. parameters: asm: The assembly code string to be assembled. new(asm: string) description: Initializes a new ME virtual machine state. parameters: asm: The initial assembly for the new state. lc(state: string, location: string) description: Manages the location counter of the ME state. parameters: state: The ME virtual machine state. location: The new location counter value. tok(state: string, from?: string, to?: string) description: Retrieves tokens from the ME state within an optional range. parameters: state: The ME virtual machine state. from: (Optional) Starting token index. to: (Optional) Ending token index. pc(state: string) description: Returns the program counter of the ME state. parameters: state: The ME virtual machine state. iseof(state: string) description: Checks if the ME state has reached the end of its input. parameters: state: The ME virtual machine state. at(state: string) description: Returns the current position within the ME state. parameters: state: The ME virtual machine state. cc(state: string) description: Retrieves the condition code of the ME state. parameters: state: The ME virtual machine state. sv(state: string) description: Returns the saved value from the ME state. parameters: state: The ME virtual machine state. ok(state: string) description: Indicates if the ME state is in a successful condition. parameters: state: The ME virtual machine state. error(state: string) description: Retrieves any error information from the ME state. parameters: state: The ME virtual machine state. lstk(state: string) description: Returns the location stack of the ME state. parameters: state: The ME virtual machine state. astk(state: string) description: Returns the argument stack of the ME state. parameters: state: The ME virtual machine state. mstk(state: string) description: Returns the match stack of the ME state. parameters: state: The ME virtual machine state. estk(state: string) description: Returns the error stack of the ME state. parameters: state: The ME virtual machine state. rstk(state: string) description: Returns the return stack of the ME state. parameters: state: The ME virtual machine state. nc(state: string) description: Retrieves the next character from the ME state's input. parameters: state: The ME virtual machine state. ast(state: string) description: Returns the abstract syntax tree associated with the ME state. parameters: state: The ME virtual machine state. halted(state: string) description: Checks if the ME virtual machine state is halted. parameters: state: The ME virtual machine state. code(state: string) description: Retrieves the executable code from the ME state. parameters: state: The ME virtual machine state. eof(statevar: string) description: Signals the end-of-file condition for the ME state. parameters: statevar: The ME virtual machine state variable. put(statevar: string, tok: string, lex: string, line: string, col: string) description: Inserts a new token with its lexical details into the ME state. parameters: statevar: The ME virtual machine state variable. tok: The token type. lex: The lexeme. line: The line number. col: The column number. run(statevar: string, n?: number) description: Executes the ME virtual machine for a specified number of steps or until completion. parameters: statevar: The ME virtual machine state variable. n: (Optional) The number of steps to run. ``` -------------------------------- ### Docidx Markup Tcl Command Syntax Examples Source: https://core.tcl-lang.org/tcllib/dir?ci=trunk&name=modules/ftp/docs/trunk/embedded/md/tcllib/files/modules/doctools/docidx_lang_intro Illustrates the basic syntax for docidx markup commands, showing how Tcl's rules for word quotation, nested commands, and continuation lines apply within the `[` and `]` delimiters. ```Tcl ... [key {markup language}] ... ... [manpage thefile \ {file description}] ... ``` -------------------------------- ### Tcl struct::tree Initialization Examples Source: https://core.tcl-lang.org/tcllib/dir?ci=trunk&name=modules/ftp/docs/trunk/embedded/md/tcllib/files/modules/struct/struct_tree Illustrates equivalent methods for initializing a `::struct::tree` object using either direct assignment or deserialization, demonstrating the syntactic sugar provided by the command. ```Tcl ::struct::tree mytree = b ``` ```Tcl ::struct::tree mytree mytree = b ``` ```Tcl ::struct::tree mytree deserialize $b ``` ```Tcl ::struct::tree mytree mytree deserialize $b ``` -------------------------------- ### Example Tcl AST Serialization Source: https://core.tcl-lang.org/tcllib/dir?ci=trunk&name=modules/ftp/docs/trunk/embedded/md/tcllib/files/modules/pt/pt_parser_api Illustrates the serialized Abstract Syntax Tree (AST) for the input '120+5' in the specified Tcl list format. This example demonstrates the hierarchical structure of nodes, including symbol names, start and end token offsets, and nested child nodes. ```Tcl set ast {Expression 0 4 {Factor 0 4 {Term 0 2 {Number 0 2 {Digit 0 0} {Digit 1 1} {Digit 2 2} } } {AddOp 3 3} {Term 4 4 {Number 4 4 {Digit 4 4} } } } } ``` -------------------------------- ### Tcl Huddle Module Usage Examples Source: https://core.tcl-lang.org/tcllib/dir?ci=trunk&name=modules/ftp/docs/trunk/embedded/md/tcllib/files/modules/yaml/huddle Provides a series of Tcl commands demonstrating the practical usage of the 'huddle' module. It shows how to create huddle objects as dictionaries and lists, nest them, strip them to normal Tcl notation, and retrieve sub-nodes using `huddle get` and `huddle gets`. ```tcl # create as a dict % set bb [huddle create a b c d] HUDDLE {D {a {s b} c {s d}}} # create as a list % set cc [huddle list e f g h] HUDDLE {L {{s e} {s f} {s g} {s h}}} % set bbcc [huddle create bb $bb cc $cc] HUDDLE {D {bb {D {a {s b} c {s d}}} cc {L {{s e} {s f} {s g} {s h}}}}} % set folding [huddle list $bbcc p [huddle list q r] s] HUDDLE {L {{D {bb {D {a {s b} c {s d}}} cc {L {{s e} {s f} {s g} {s h}}}}} {s p} {L {{s q} {s r}}} {s s}}} # normal Tcl's notation % huddle strip $folding {bb {a b c d} cc {e f g h}} p {q r} s # get a sub node % huddle get $folding 0 bb HUDDLE {D {a {s b} c {s d}}} % huddle gets $folding 0 bb a b c d ``` -------------------------------- ### tcl::chan::facade Command and Channel Options API Reference Source: https://core.tcl-lang.org/tcllib/dir?ci=trunk&name=modules/ftp/docs/trunk/embedded/md/tcllib/files/modules/virtchannel_base/facade Detailed API documentation for the `::tcl::chan::facade` command, which creates a facade channel, describing its parameters and return value. It also outlines the additional configuration options available for the facade channel itself, specifying their purpose and writability. ```APIDOC ::tcl::chan::facade chan Description: This command creates the facade channel around the provided channel *chan*, and returns its handle. Parameters: chan: The channel to wrap with the facade. Returns: The handle of the newly created facade channel. Channel Configuration Options: -self: The TclOO object handling the facade. (Read-only) -fd: The handle of the subordinate, i.e. wrapped channel. (Read-only) -used: The last time the wrapped channel was read from or written to by the facade, as per clock milliseconds. A value of 0 indicates that the subordinate channel was not accessed at all, yet. (Read-only) -created: The time the facade was created, as per clock milliseconds. (Read-only) -user: A free-form value identifying the user of the facade and its wrapped channel. (Writable) ``` -------------------------------- ### Tcl Example: Fetching Data from Yahoo Boss API Source: https://core.tcl-lang.org/tcllib/dir?ci=trunk&name=modules/ftp/docs/trunk/embedded/md/tcllib/files/modules/rest/rest Demonstrates how to make a GET request to the Yahoo Boss API using `rest::get` in Tcl. The example shows how to set an application ID, construct the URL, and process the returned JSON response using `rest::format_json`. ```Tcl set appid APPID set search tcl set res [rest::get http://boss.yahooapis.com/ysearch/web/v1/$search [list appid $appid]] set res [rest::format_json $res] ``` -------------------------------- ### Example: Defining and Using a Class Option Source: https://core.tcl-lang.org/tcllib/dir?ci=trunk&name=modules/ftp/docs/trunk/embedded/md/tcllib/files/modules/tool/tool Demonstrates how to define a `color` option for a class using `tool::define option`, including a `post-command` and `default` value, and then how to create an object and configure the option. ```Tcl tool::class create myclass { option color { post-command: {puts [list %self%'s %field% is now %value%]} default: green } } myclass create foo foo configure color purple ``` -------------------------------- ### docidx Markup: Flexible Placement of Configuration Commands Source: https://core.tcl-lang.org/tcllib/dir?ci=trunk&name=modules/ftp/docs/trunk/embedded/md/tcllib/files/modules/doctools/docidx_lang_intro This example illustrates that `include` and `vset` commands are not restricted to the document's beginning. They can be placed anywhere a markup command is allowed, even within an `index_begin` and `index_end` block, offering greater flexibility in structuring content. ```docidx Markup [index_begin GROUPTITLE TITLE] [include FILE] [vset VAR VALUE] ... [index_end] ``` -------------------------------- ### Get Arc Source Node Source: https://core.tcl-lang.org/tcllib/dir?ci=trunk&name=modules/ftp/docs/trunk/embedded/md/tcllib/files/modules/struct/graph1 Returns the name of the node from which the specified `arc` originates. This identifies the starting point of the directed arc. ```APIDOC graphName arc source arc ``` -------------------------------- ### Initialize Tcl Multiplexer Instance Port Source: https://core.tcl-lang.org/tcllib/dir?ci=trunk&name=modules/ftp/docs/trunk/embedded/md/tcllib/files/modules/multiplexer/multiplexer Shows how to initialize a previously created multiplexer instance to start listening for incoming connections on a specific port using the instance's `::Init` method. ```Tcl ${mp}::Init 35100 ``` -------------------------------- ### Example: Using TreeQL Object query Method in Tcl Source: https://core.tcl-lang.org/tcllib/dir?ci=trunk&name=modules/ftp/docs/trunk/embedded/md/tcllib/files/modules/treeql/treeql This Tcl example demonstrates a common usage pattern for the TreeQL 'query' method. It shows how to chain operators like 'root', 'children', and 'get data' to navigate a tree structure, modify the node set, and extract specific attribute values. ```Tcl # q is the query object. q query root children get data # The above query # - Resets the node set to the root node - root # - Adds the children of root to the set - children # - Replaces the node set with the - get data # values for the attribute 'data', # for all nodes in the set which # have such an attribute. # - And returns this information. # Below we can see the same query, but rewritten # to show the structure as it is seen by the query # interpreter. q query \ root \ children \ get data ``` -------------------------------- ### Basic Usage of math::machineparameters Object Source: https://core.tcl-lang.org/tcllib/dir?ci=trunk&name=modules/ftp/docs/trunk/embedded/md/tcllib/files/modules/math/machineparameters This example demonstrates the fundamental steps to use the `math::machineparameters` package: creating an object, computing machine parameters, printing a report, and destroying the object. ```Tcl set pp [machineparameters create %AUTO%] $pp compute $pp print $pp destroy ``` -------------------------------- ### Example Tcl AST Serialization for '120+5' Source: https://core.tcl-lang.org/tcllib/dir?ci=trunk&name=modules/ftp/docs/trunk/embedded/md/tcllib/files/modules/pt/pt_astree A Tcl list representation of an Abstract Syntax Tree (AST) for the input string '120+5'. This example demonstrates how the AST is structured hierarchically, with each node containing its nonterminal symbol, start and end token offsets, and nested child nodes. ```Tcl set ast {Expression 0 4 {Factor 0 4 {Term 0 2 {Number 0 2 {Digit 0 0} {Digit 1 1} {Digit 2 2} } } {AddOp 3 3} {Term 4 4 {Number 4 4 {Digit 4 4} } } } } ``` -------------------------------- ### APIDOC: math::machineparameters create Method Source: https://core.tcl-lang.org/tcllib/dir?ci=trunk&name=modules/ftp/docs/trunk/embedded/md/tcllib/files/modules/math/machineparameters Detailed documentation for the `machineparameters create` command, explaining its purpose of instantiating a new object and detailing the available `-verbose` option for debugging. ```APIDOC machineparameters create objectname ?options...? The command creates a new machineparameters object and returns the fully qualified name of the object command as its result. + -verbose verbose Set this option to 1 to enable verbose logging. This option is mainly for debug purposes. The default value of verbose is 0. ``` -------------------------------- ### Examples of Invalid PEG Names Source: https://core.tcl-lang.org/tcllib/dir?ci=trunk&name=modules/ftp/docs/trunk/embedded/md/tcllib/files/modules/pt/pt_peg_language Illustrates text strings that do not conform to the PEG naming conventions, highlighting common errors such as starting with a digit or special character. ```PEG 12 .bogus 0wrong @location ``` -------------------------------- ### Bench Language Benchmark with Pre and Post Processing Source: https://core.tcl-lang.org/tcllib/dir?ci=trunk&name=modules/ftp/docs/trunk/embedded/md/tcllib/files/modules/bench/bench_lang_intro This example illustrates how to include initialization ('-pre') and cleanup ('-post') code within a 'bench' language benchmark. It's drawn from Tcllib's AES package, showing how to set up a key schedule before encryption and finalize it afterward, ensuring resources are properly managed for the benchmark's body. ```Tcl bench -desc "AES-${len} ECB encryption core" -pre { set key [aes::Init ecb $k $i] } -body { aes::Encrypt $key $p } -post { aes::Final $key } ``` -------------------------------- ### FA Method: Get Reachable States Source: https://core.tcl-lang.org/tcllib/dir?ci=trunk&name=modules/ftp/docs/trunk/embedded/md/tcllib/files/modules/grammar_fa/fa Documents the `reachable_states` method for Finite Automata, which returns the set of states that are reachable from a start state by one or more transitions. ```APIDOC * faName **reachable_states** Returns the set of states which are reachable from a start state by one or more transitions. ``` -------------------------------- ### Snit Widget Adaptor Hull Installation with Options Source: https://core.tcl-lang.org/tcllib/dir?ci=trunk&name=modules/ftp/docs/trunk/embedded/md/tcllib/files/modules/snit/snitfaq Shows how to correctly install a hull for a `snit::widgetadaptor` using the `installhull` command within the constructor. This method specifies the hull widget type (e.g., `text`) and initial options (e.g., `-foreground white`), allowing Snit to manage its creation. ```Tcl snit::widgetadaptor mywidget { # ... constructor {args} { # ... installhull using text -foreground white # ... } # ... } ``` -------------------------------- ### Example: Secure Connection with Tcllib Transfer Object Source: https://core.tcl-lang.org/tcllib/dir?ci=trunk&name=modules/ftp/docs/trunk/embedded/md/tcllib/files/modules/transfer/connect Demonstrates how to establish a secure connection using a Tcllib transfer object by configuring the -socketcmd option to use tls::socket. ```Tcl # Load and initialize tls package require tls tls::init -cafile /path/to/ca/cert -keyfile ... # Create a connector with secure socket setup, transfer::connect C -socketcmd tls::socket ... ``` -------------------------------- ### Solving a Linear Program with Tcl's Math Optimize Module Source: https://core.tcl-lang.org/tcllib/dir?ci=trunk&name=modules/ftp/docs/trunk/embedded/md/tcllib/files/modules/math/optimize Demonstrates how to use the `::math::optimize::solveLinearProgram` procedure to find the solution for a linear programming problem. The example provides the coefficients for the objective function and the constraints, then executes the solver to obtain the optimal solution. ```Tcl set solution [::math::optimize::solveLinearProgram { 3.0 2.0 } { { 1.0 1.0 1.0 } { 2.0 5.0 10.0 } } ] ``` -------------------------------- ### Tcllib: Get Help for sak.tcl Validate Command Source: https://core.tcl-lang.org/tcllib/dir?ci=trunk&name=modules/ftp/docs/trunk/embedded/md/tcllib/files/devdoc/tcllib_devguide Command to display the documentation and available subcommands for the 'validate' functionality within the 'sak.tcl' utility, useful for developers checking package consistency. ```Tcl sak.tcl help validate ``` -------------------------------- ### math::machineparameters Object API Synopsis Source: https://core.tcl-lang.org/tcllib/dir?ci=trunk&name=modules/ftp/docs/trunk/embedded/md/tcllib/files/modules/math/machineparameters Overview of the methods available on a `math::machineparameters` object, including creation, configuration, computation, and retrieval of parameters. ```APIDOC machineparameters create objectname ?options...? objectname configure ?options...? objectname cget opt objectname destroy objectname compute objectname get key objectname tostring objectname print ``` -------------------------------- ### Tcl TreeQL Get Node Type Attribute Source: https://core.tcl-lang.org/tcllib/dir?ci=trunk&name=modules/ftp/docs/trunk/embedded/md/tcllib/files/modules/treeql/treeql Example Tcl code demonstrating how to retrieve the '@type' attribute of a node. This is an equivalent operation to using the 'nodetype' accessor for typed node support. ```Tcl get @type ``` -------------------------------- ### Retrieve Specific Machine Parameter (Epsilon) in Tcl Source: https://core.tcl-lang.org/tcllib/dir?ci=trunk&name=modules/ftp/docs/trunk/embedded/md/tcllib/files/modules/math/machineparameters This example illustrates how to create a `machineparameters` object, compute the machine properties, and then retrieve a specific parameter, such as the machine epsilon, using the `get` method. ```Tcl set pp [machineparameters create %AUTO%] $pp compute set eps [$pp get -epsilon] $pp destroy ```