Okay, here is what it will need to look like:
Put the connid.pkg file in your root tclprocs directory or your master site tclprocs directory and put the pkgIndex.tcl file in that same directory. When you want to use the connid package just put in “package require connid” prior to using them and you should have access to them.
As always, there is a caveat. Before you put the pkgIndex.tcl file in place look to see if there is already one there. If there is then you will want to add the package ifneeded command to that file instead of replacing the file.
Have fun!
connid.pkg
package provide connid [lindex {Revision: 1.0 } 1]
######################################################################
# Name: connid
# Purpose: Write, read, and delete connids from connid.dat file
# UPoC type: none (namepsace)
# Note a namespace is used to make these procs “private” and
# prevent them from appearing in Cloverleaf dropdown lists
# in the IDE.
#
# Procedures:
#
# connid::write
# args: connid = connid to store
# clist = list of data associated with connid
# (ip, port, type, format, valid)
# returns: nothing
#
# connid::read
# args: connid = connid to read
# returns: list of information associated with connid
#
# connid::delete
# args: connid = connid to delete
# returns: nothing
#
namespace eval connid {
variable fname
set fname connid.dat
proc write { connid clist } {
variable fname
# If the file exists we need to update it
# If the file does not exist simply create it
set kl “”
if { [file exists $fname] } {
set fd [open $fname r]
flock -read $fd
set kl [gets $fd]
close $fd
}
set fd [open $fname w]
flock -write $fd
keylset kl $connid $clist
puts $fd $kl
close $fd
}
proc delete { connid } {
variable fname
# Delete the specified connid
if [file exists $fname] {
set fd [open $fname r]
set kl [gets $fd]
close $fd
set fd [open $fname w]
flock -write $fd
catch { keyldel kl $connid }
puts $fd $kl
close $fd
}
}
proc read { connid } {
variable fname
set fd [open $fname r]
flock -read $fd
set kl [gets $fd]
close $fd
if [catch { keylget kl $connid } cinfo] {
logit 0 “No data found for connid $connid!”
set cinfo “”
}
return $cinfo
}
}; # End of connid namespace
pkgIndex.tcl
# Tcl package index file, version 1.1
# This file is generated by the “pkg_mkIndex” command
# and sourced either when an application starts up or
# by a “package unknown” script. It invokes the
# “package ifneeded” command to set up package-related
# information so that packages will be loaded automatically
# in response to “package require” commands. When this
# script is sourced, the variable $dir must contain the
# full path name of this file’s directory.
package ifneeded connid 1.0 [ list source [file join $dir connid.pkg] ]