Name

abc::init — Run and initialize ABC, start communication

Synopsis

abc::init [result] [timeout]

DESCRIPTION

The procedure looks in the directory given by the variable abc::dir for executable file named by variable abc::exe. Spawns that program using Expect with the option -s, which prevets ABC from sourcing initialization files. Then the procedures uses the ABC command source to read all the named initializaton files. Their locations and order is defined by a list in the abc::initList variable. Errors caused by nonexistent files are ignored. Failures to parse the file are detected and cause immediate error return. For a more detailed description and for standard file sequences, see abctcl.conf.tcl(5)

The variables abc::dir, abc::exe. and abc::initList are set by commands in the abctcl.conf.tcl file (see abctcl.conf.tcl(5) ) but can be overriden before the first invocation of abc::init.

ARGUMENTS

array result (out)

Optional argument. If omitted, no information is returned. The following items are present:

string errorCode (out)

Error code. See RETURN CODES below. Also put to the errorCode global variable.

string rawOutput (out)

The unprocessed output of ABC, including the final prompt.

int promptNumber (out)

The number included in the final prompt. The ABC prompt has the "abc123> " form. The number indicates successive version of the network stored in ABC.

int cmdTime (out)

Time in milliseconds elapsed by the command.

string abcVersion (out)

The first line returned by ABC, including version and date of compilation.

int spawn_id (out)

Process id as returned by the Expect spawn command.

list of strings sourced (out)

List of files that were sucessfully sourced into ABC.

list of strings failed (out)

List of files that failed to source into ABC.

int timeout (in)

Optional argument. If given, sets the timeout of Expect for this command. Othervise, the value of the timeout global variable applies.

RETURN CODES

The procedure returns an empty string. See abctcl(n) , abc::messages(n) for error reporting and error symbols. The following error symbols can occur:

Error Code: ABC_E_BUSY
Diagnostic: Prompt from the previous command has not been detected yet.
Error Code: ABC_E_EOF
Diagnostic: A premature end-of-file detected. Perhaps the ABC process crashed.
Error Code: ABC_E_TOUT
Diagnostic: Timeout expired before the prompt was detected.
Error Code: ABC_E_DIR
Diagnostic: The path named by abc::dir does not exist or is not a directory.
Error Code: ABC_E_EXF
Diagnostic: The file named by abc::exe does not exist or is not executable.
Error Code: ABC_E_EXEC
Diagnostic: The program failed to spawn.
Error Code: ABC_E_CMD
Diagnostic: Some of the initialization files could not be parsed.

EXAMPLE

This sequence initializes ABC with error reporting and recovery. script:

if { [catch { abc::init res }] } {
    puts $errorCode
    puts ".failed"
    foreach initFile $res(sourced) {
        puts $initFile
    }
    exit
} else {
    foreach initFile $res(sourced) {
        puts -nonewline "$initFile ... "
    }
    puts ".ok"
    puts "greeting:"
    puts $res(abcVersion)
    puts "final prompt number: $res(promptNumber)"
    puts "raw output follows:"
    puts $res(rawOutput)
}

SEE ALSO

abctcl.conf.tcl(5) , abctcl(n) , abc::messages(n) , abc::dome(n)