by Dinesh Thakur Category: Data Structure

Record and record structures : The ::struct::record package provides a mechanism to group variables together as one data structure, similar to a 'C' structure. The members of a record can be variables or other records. However, a record can not contain circular record, i.e. records that contain the same record as a member.

This package was structured so that it is very similar to how Tk objects work. Each record definition creates a record object that encompasses that definition. Subsequently, that record object can create instances of that record. These instances can then be manipulated with the cget and configure methods.

The package only contains one top level command, but several sub commands (see below). It also obeys the namespace in which the record was define, hence the objects returned are fully qualified.

record define recordName recordMembers ? instanceName1

instanceName2 ... ?

Defines a record. recordName is the name of the record, and is also used as an object command. This object command is used to create instances of the record definition. recordMembers are the members of the record that make up the record definition. These are variables and other record. If optional instanceName args are given, then an instance is generated after the definition is created for each instanceName.

record show record

Returns a list of records that have been defined.

record show instances recordName

Returns the instances that have been instantiated by recordName.

record show members recordName

Returns the members that are defined for record recordName. It returns the same

format as how the records were defined.

record show values instanceName

Returns a list of values that are set for the instance instanceName. The output is a list of key/value pairs. If there are nested records, then the values of the nested records will itself be a list.

record exists record recordName

Tests for the existence of a record with the name recordName.

record exists instance instanceName

Tests for the existence of a instance with the name instanceName.

record delete record recordName

Deletes recordName, and all instances of recordName. It will return an error if the

record does not exist.

record delete instance instanceName

Deletes instance with the name of instanceName. It will return an error if the

instance does not exist.

Record Members : Record members can either be variables, or other records, However, the same record can not be nested witin itself (circular). To define a nested record, you need to specify the record keyword, along the with name of the record, and the name of the instance of that nested record. For example, it would look like this :

# this is the nested record

record define mynestedrecord {




# This is the main record

record define myrecord {



{record mynestedrecord mem3}



About Dinesh Thakur

Dinesh ThakurDinesh Thakur holds an B.C.A, MCSE, MCDBA, CCNA, CCNP, A+, SCJP certifications. Dinesh authors the hugely popular blog. Where he writes how-to guides around Computer fundamental , computer software, Computer programming, and web apps. For any type of query or something that you think is missing, please feel free to Contact us.