Problem
I'm trying to use the standard X Toolkit option "-display"
with a Visual Tcl program. The program either ignores the
option or displays a usage message. For example:# /etc/custom -display plutonium:0.0Error: Unknown option "-display".Usage: custom [-s prd|-p parcel] [-aAbdDeEGilLrRtuw [package package ...]]
[-v verify type [package package ...]] [-V verify type]
[-m media] [-f filelist] [-z image directory]
[-h host to administer] [-N source host[:password]]
[-x] Cause
A Visual Tcl program is not an X application, so it doesn't understand the X Toolkit options.
Solution
Set the DISPLAY environment variable before calling the Visual Tcl program.
Alternatively, you can add code the to Visual Tcl program to
explicitly check for the "-display" option. The following
code fragment demonstrates how you could do this.-------------------------------------------------------------------------------#!/bin/vtcl# name: getopt
# A very simple getopt procedure. It can only handle
# command line arguments of the form: -optionname value.
# The procedure returns a keyed list of the pairs (optionname, value).
proc getopt {list} {
while { [llength $list] > 0 } {
set optionname [lvarpop list]
if [string match -* $optionname] {
set optionname [string range $optionname 1 end]
keylset arglist $optionname [lvarpop list]
}
}
return $arglist
}# Main Program
if { ![lempty $argv] } {
set argvlist [getopt $argv]
set fieldkeys [keylkeys argvlist]
if { [lsearch $fieldkeys display] >= 0 } {
set env(DISPLAY) [keylget argvlist display]
}
}# Rest of program code goes hereVtMainLoop