Version 1 of MetaKit Tips and Tricks

Updated 2006-10-09 18:07:11

A page for code snippets for MetaKit


CMcC found layout format annoying in its terseness, so wrote a simple wrapper to allow comments:

    proc layout {string} {
        set result ""
        foreach line [split $string \n] {
            set line [string trim [lindex [split $line \#] 0]]
            if {$line eq ""} continue
            foreach {name t} [split $line :] break
            if {$t eq ""} {
                set t "S"
            }
            #puts stderr "Layout: $line -> $name:$t"
            append result "$name:$t" \n
        }
        return $result
    }

Example:

    set trouble_layout [layout {
        user        # user with trouble
        mid        # message id
        error:I        # error code
        text        # error text
    }]

    ::mk::view layout $db.trouble $trouble_layout

How do I get a 'distinct' item result set?

Partnumber 0001 0001 0001 0003 0004 0006 0006

and you want to retrieve the unique values only -- such as:

Partnumber 0001 0002 0003 0004 0006

 # code here