Technical article 104729

Visual Tcl programs don't accept the "-display" option.

OpenServer 5.0.0OpenServer 5.0.2OpenServer 5.0.4OpenServer 5.0.5OpenServer 5.0.6

Written · Last revised

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.0
Error: 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 here
VtMainLoop

From the Xinuos technical article database, record 104729. Reproduced with permission. The original is at www.sco.com/ta/104729, which is reachable but blocked from search engines. Xinuos marks this article against a retired product line. That refers to the product’s lifecycle, not to whether the advice still works — plenty of it still applies to running systems.

Next step

Need this fixed rather than explained?

Tell us the release, what the system runs and what it is doing. We will reply by email with what we would do next.

  • You deal with the people who do the work
  • No obligation, and no upgrade required before we will help
  • We tell you plainly if something is not worth doing

Send an enquiry

We reply by email. If a server is down, say so in the first line. You can also write to help@scoexpert.com.