Get the value of a configuration option specified via <A HREF="#item_SetArguments"><CODE>SetArguments</CODE></A>.
(<A HREF="#item_cget"><CODE>cget</CODE></A> first invokes <A HREF="#item_SetArguments"><CODE>SetArguments</CODE></A> if it has not already been invoked.)
<PRE>
Tk::CmdLine::cget([$option])</PRE>
<P>The valid options are: <STRONG>-class</STRONG>, <STRONG>-name</STRONG>, <STRONG>-screen</STRONG> and <STRONG>-title</STRONG>.
If no option is specified, <STRONG>-class</STRONG> is implied.</P>
<P>A typical use of <A HREF="#item_cget"><CODE>cget</CODE></A> might be to obtain the application class in order
to define the name of a resource file to be loaded in via <A HREF="#item_LoadResources"><CODE>LoadResources</CODE></A>.</P>
<PRE>
my $class = Tk::CmdLine::cget(); # process command line and return class</PRE>
<P>A single resource may be specified using a string of the form
'<<EM>pattern</EM>>:<<EM>value</EM>>'. Multiple resources may be specified
by passing an array reference whose elements are either strings of the above
form, and/or anonymous arrays of the form [ <<EM>pattern</EM>>,
<<EM>value</EM>> ]. The optional second argument specifies the priority,
as defined in <A HREF="../../../site/lib/Tk/option.html">option</A>, to be associated with the resources
(default: <EM>userDefault</EM>).</P>
<P>Note that <A HREF="#item_SetResources"><CODE>SetResources</CODE></A> first invokes <A HREF="#item_SetArguments"><CODE>SetArguments</CODE></A> if it has not already
<P>[ <STRONG>-symbol</STRONG> => $symbol ] specifies the name of an environment variable
that, if set, defines a colon-separated list of one or more directories and/or
file patterns. $<A HREF="#item_XUSERFILESEARCHPATH"><CODE>XUSERFILESEARCHPATH</CODE></A> is a special case.
If $<A HREF="#item_XUSERFILESEARCHPATH"><CODE>XUSERFILESEARCHPATH</CODE></A> is not set, $<A HREF="#item_XAPPLRESDIR"><CODE>XAPPLRESDIR</CODE></A> is checked instead.
If $<A HREF="#item_XAPPLRESDIR"><CODE>XAPPLRESDIR</CODE></A> is not set, $<A HREF="#item_HOME"><CODE>HOME</CODE></A> is checked instead.</P>
<P>An item is identified as a file pattern if it contains one or more /%[A-Za-z]/
patterns. Only patterns <STRONG>%L</STRONG>, <STRONG>%T</STRONG> and <STRONG>%N</STRONG> are currently recognized. All
others are replaced with the null string. Pattern <STRONG>%L</STRONG> is translated into
$<A HREF="#item_LANG"><CODE>LANG</CODE></A>. Pattern <STRONG>%T</STRONG> is translated into <EM>app-defaults</EM>. Pattern <STRONG>%N</STRONG> is
translated into the application class name.</P>
<P>Each file pattern, after substitutions are applied, is assumed to define a
and <<STRONG>DIRECTORY</STRONG>>/<<STRONG>CLASS</STRONG>> are defined, in that order.</P>
<P>[ <STRONG>-file</STRONG> => $fileSpec ] specifies a resource file to be loaded in.
The file is silently skipped if if does not exist, or if it is not readable.</P>
<P>[ <STRONG>-priority</STRONG> => $priority ] specifies the priority, as defined in
<A HREF="../../../site/lib/Tk/option.html">option</A>, to be associated with the resources
(default: <EM>userDefault</EM>).</P>
<P>[ <STRONG>-echo</STRONG> => $fileHandle ] may be used to specify that a line should be
printed to the corresponding FileHandle (default: \*STDOUT) everytime a file
is examined / loaded.</P>
<P>If no <STRONG>-symbol</STRONG> or <STRONG>-file</STRONG> options are specified, <A HREF="#item_LoadResources"><CODE>LoadResources</CODE></A>
processes symbol $<A HREF="#item_XFILESEARCHPATH"><CODE>XFILESEARCHPATH</CODE></A> with priority <EM>startupFile</EM> and
$<A HREF="#item_XUSERFILESEARCHPATH"><CODE>XUSERFILESEARCHPATH</CODE></A> with priority <EM>userDefault</EM>.
(Note that $<A HREF="#item_XFILESEARCHPATH"><CODE>XFILESEARCHPATH</CODE></A> and $<A HREF="#item_XUSERFILESEARCHPATH"><CODE>XUSERFILESEARCHPATH</CODE></A> are supposed to
contain only patterns. $<A HREF="#item_XAPPLRESDIR"><CODE>XAPPLRESDIR</CODE></A> and $<A HREF="#item_HOME"><CODE>HOME</CODE></A> are supposed to be a single
directory. <A HREF="#item_LoadResources"><CODE>LoadResources</CODE></A> does not check/care whether this is the case.)</P>
<P>For each set of FileSpecs, <A HREF="#item_LoadResources"><CODE>LoadResources</CODE></A> examines each FileSpec to
determine if the file exists and is readable. The first file that meets this
criteria is read in and <A HREF="#item_SetResources"><CODE>SetResources</CODE></A> is invoked.</P>
<P>Note that <A HREF="#item_LoadResources"><CODE>LoadResources</CODE></A> first invokes <A HREF="#item_SetArguments"><CODE>SetArguments</CODE></A> if it has not already
been invoked.</P>
<P></P></DL>
<P>
<HR>
<H1><A NAME="notes">NOTES</A></H1>
<P>This module is an object-oriented module whose methods can be invoked as object
methods, class methods or regular functions. This is accomplished via an
internally-maintained object reference which is created as necessary, and which
always points to the last object used. <A HREF="#item_SetArguments"><CODE>SetArguments</CODE></A>, <A HREF="#item_SetResources"><CODE>SetResources</CODE></A> and
<A HREF="#item_LoadResources"><CODE>LoadResources</CODE></A> return the object reference.</P>
<P>
<HR>
<H1><A NAME="examples">EXAMPLES</A></H1>
<OL>
<LI>
@ARGV is processed by Tk::CmdLine at MainWindow creation.
<PRE>
use Tk;</PRE>
<PRE>
# <Process @ARGV - ignoring all X11-specific options></PRE>
<PRE>
my $mw = MainWindow->new();</PRE>
<PRE>
MainLoop();</PRE>
<P></P>
<LI>
@ARGV is processed by Tk::CmdLine before MainWindow creation.
An @ARGV of (--geometry=100x100 -opt1 a b c -bg red)
is equal to (-opt1 a b c) after <A HREF="#item_SetArguments"><CODE>SetArguments</CODE></A> is invoked.
<PRE>
use Tk;</PRE>
<PRE>
Tk::CmdLine::SetArguments(); # Tk::CmdLine->SetArguments() works too</PRE>
<PRE>
# <Process @ARGV - not worrying about X11-specific options></PRE>
<PRE>
my $mw = MainWindow->new();</PRE>
<PRE>
MainLoop();</PRE>
<P></P>
<LI>
Just like 2) except that default arguments are loaded first.
<PRE>
use Tk;</PRE>
<PRE>
Tk::CmdLine::SetArguments(qw(-name test -iconic));
Tk::CmdLine::SetArguments();</PRE>
<PRE>
# <Process @ARGV - not worrying about X11-specific options></PRE>
<PRE>
my $mw = MainWindow->new();</PRE>
<PRE>
MainLoop();</PRE>
<P></P>
<LI>
@ARGV is processed by Tk::CmdLine before MainWindow creation.
Standard resource files are loaded in before MainWindow creation.
<PRE>
use Tk;</PRE>
<PRE>
Tk::CmdLine::SetArguments();</PRE>
<PRE>
# <Process @ARGV - not worrying about X11-specific options></PRE>
<PRE>
Tk::CmdLine::LoadResources();</PRE>
<PRE>
my $mw = MainWindow->new();</PRE>
<PRE>
MainLoop();</PRE>
<P></P>
<LI>
@ARGV is processed by Tk::CmdLine before MainWindow creation.
Standard resource files are loaded in before MainWindow creation
using non-default priorities.
<PRE>
use Tk;</PRE>
<PRE>
Tk::CmdLine::SetArguments();</PRE>
<PRE>
# <Process @ARGV - not worrying about X11-specific options></PRE>
1999.03.04 Ben Pavon <<A HREF="mailto:ben.pavon@hsc.hac.com">ben.pavon@hsc.hac.com</A>>
<P>Rewritten as an object-oriented module.</P>
<P>Allow one to process command line options in a specified array (@ARGV by default).
Eliminate restrictions on the format and location of the options within the array
(previously the X11 options could not be specified in POSIX format and had to be
at the beginning of the array).</P>
<P>Added the <A HREF="#item_SetResources"><CODE>SetResources</CODE></A> and <A HREF="#item_LoadResources"><CODE>LoadResources</CODE></A> functions to allow the definition