<!DOCTYPE HTML PUBLIC "-//W3O//DTD W3 HTML 2.0//EN">
<!Converted with LaTeX2HTML 95 (Thu Jan 19 1995) by Nikos Drakos (nikos@cbl.leeds.ac.uk), CBLU, University of Leeds >
<HEAD>
<TITLE> Utilities</TITLE>
</HEAD>
<BODY>
<meta name="description" value=" Utilities">
<meta name="keywords" value="vwebref">
<meta name="resource-type" value="document">
<meta name="distribution" value="global">
<P>
 <BR> <HR><A NAME=tex2html1455 HREF="node11.html"><IMG ALIGN=BOTTOM ALT="next" SRC="../icons/next.gif"></A>   <A NAME=tex2html1453 HREF="vwebref.html"><IMG ALIGN=BOTTOM ALT="up" SRC="../icons/up.gif"></A>   <A NAME=tex2html1447 HREF="node9.html"><IMG ALIGN=BOTTOM ALT="gif" SRC="../icons/prev.gif"></A>   <A NAME=tex2html1457 HREF="node1.html"><IMG ALIGN=BOTTOM ALT="contents" SRC="../icons/contents.gif"></A>      <BR>
<B> Next:</B> <A NAME=tex2html1456 HREF="node11.html"> Tutorial C++ Source</A>
<B>Up:</B> <A NAME=tex2html1454 HREF="vwebref.html">V Reference Manual</A>
<B> Previous:</B> <A NAME=tex2html1448 HREF="node9.html"> Standard V Values</A>
<BR> <HR> <P>
<H1><A NAME=SECTION001000000000000000000> Utilities</A></H1>
<P>
<A NAME=6209>&#160;</A>
<P>
This chapter covers V
  utility classes and functions. Whenever
possible, any corresponding native utility has been used to
implement these classes. For example, you will get the standard
file interface dialog for Windows.
<P>
Since the Athena implementation has no corresponding native
utilities, the V
  utility classes have been implemented for
Athena using standard V
  classes as much as possible. Thus, the
source code for the Athena version of these utilities provides an
excellent example of V
  for study.
<P>
The classes and objects covered in this chapter include:
<P>
<DL ><DT>vDebugDialog
<DD> Utility class to access debugging messages.
	<DT>vFileSelect
<DD> A utility class to select or set a file name.
	<DT>vFontSelect
<DD> A utility class to select or set a font object.
	<DT>vNoticeDialog
<DD> A utility class to display a message.
	<DT>vReplyDialog
<DD> A utility class to get a text reply from the user.
	<DT>vTimer
<DD> A class for getting timer events.
	<DT>vYNReplyDialog
<DD> A utility class to display a message, and get a Yes or No answer.
	<DT>Utility Functions
<DD> Several useful functions.
<P>
 </DL>
<P>

<H1><A NAME=SECTION001010000000000000000> vDebugDialog</A></H1>
<P>
<A NAME=6307>&#160;</A>
<P>
Utility class to access debugging messages.
<P>
<H2><A NAME=SECTION001011000000000000000> Synopsis</A></H2>
<P>
<DL ><DT>Header:
<DD> <tt>
 &lt;v/vdebug.h&gt;</tt>
	<DT>Class name:
<DD> vDebugDialog
 	<DT>Hierarchy:
<DD> vModalDialog -&gt;
  vDebugDialog
<P>
 </DL><H2><A NAME=SECTION001012000000000000000> Description</A></H2>
<P>
V
  provides built in debugging features. Most of the V
  classes
contain debugging messages that are displayed on <tt>
 stderr</tt> or a
special debugging information window. For Unix systems, <tt>
 stderr</tt>
is usually the xterm window used to launch the V
  application.
For other environments, the debugging window is system dependent.
<P>
Several categories of debugging messages have been defined by V
 ,
and display of messages from different categories is controlled
by the <tt>
 vDebugDialog</tt> class.
<P>
V
  provides several macros that can be used to insert debugging
messages into your code. These are of the form <tt>
 SysDebugN</tt> for
system code, and <tt>
 UserDebugN</tt> for your code. Display of
these messages is controlled by the <tt>
 vDEBUG</tt> symbol, and the
settings of the <tt>
 vDebugDialog</tt> class.
<P>
You define an error message using a <tt>
 UserDebug</tt> macro.
Your message is a format string using the conventions of <tt>
 sprintf</tt>.
You can have none to three values by using the corresponding
<tt>
 UserDebug</tt> through <tt>
 UserDebug3</tt> macros. Each macro
takes a debug type, a message, and any required values for the
message format string. For example,
<tt>
 UserDebug(Misc,&quot;myClass: %d<IMG BORDER=0 ALIGN=MIDDLE ALT="" SRC="img15.gif">n&quot;, val)</tt>
will print the message ``myClass: xx'' when it is executed and the
<tt>
 Misc</tt> debug message type is enabled.
<P>
If <tt>
 vDEBUG</tt> is <em>not</em> defined, your debugging messages will
be null macros, and not occupy any code space.  If <tt>
 vDEBUG</tt> is
defined, then your messages will be conditionally displayed depending
on their type.
<P>
By default, V starts with the <tt>
 System</tt> category <tt>
 BadVals</tt>
on, and all three <tt>
 User</tt> categories on. Unix versions of V
 \
support a command line option that allows you to enable each
option using
the <tt>
 -vDebug</tt> command line switch. You include the switch
<tt>
 -vDebug</tt> on the command line, followed by a single argument
value made up of letters corresponding to the various debugging
categories. If <tt>
 -vDebug</tt> is specified, all debugging categories
except those specified in the value are turned off. The value
for each category is listed in its header. For example, using
the switch <tt>
 -vDebug SUCDm</tt> would enable debugging messages
for both <tt>
 System</tt> and <tt>
 User</tt> constructors and destructors,
as well as <tt>
 System</tt> mouse events.
Note that the values are case sensitive.
<P>
<H2><A NAME=SECTION001013000000000000000> Debugging Categories</A></H2>
<P>
Each of the following debug categories can be set or unset using
the <tt>
 vDebugDialog</tt> class. These category names are to be
used as the first argument to the <tt>
 UserDebug</tt> macro.
<P>
<H4><A NAME=SECTION001013010000000000000> System (-vDebug S)</A></H4>
<P>
These are the messages defined using the <tt>
 SysDebug</tt> macro.
These messages can sometimes be useful to determine if you are
using the classes properly. The constructor, destructor, and
command events are often the most useful system debug messages.
Turning this off will disable all system messages.
<P>
<H4><A NAME=SECTION001013020000000000000> User (-vDebug U)</A></H4>
<P>
These are the messages defined using the <tt>
 UserDebug</tt> macros. Turning
this off will disable all user messages, while turning it on enables those
user messages that have been enabled.
<P>
<H4><A NAME=SECTION001013030000000000000> CmdEvents (-vDebug c)</A></H4>
<P>
This category corresponds to command events, which include menu
picks and dialog command actions.
<P>
<H4><A NAME=SECTION001013040000000000000> MouseEvents (-vDebug m)</A></H4>
<P>
This category corresponds to mouse events, such as a button click
or a move.
<P>
<H4><A NAME=SECTION001013050000000000000> WindowEvents (-vDebug w)</A></H4>
<P>
This category corresponds to window events, such as a resize or redraw.
<P>
<H4><A NAME=SECTION001013060000000000000> Build (-vDebug b)</A></H4>
<P>
This category corresponds to actions taken to build a window, such
as adding commands to a dialog.
<P>
<H4><A NAME=SECTION001013070000000000000> Misc (-vDebug o)</A></H4>
<P>
This is a catch all category used for miscellaneous system messages.
The <tt>
 o</tt> vDebug stands for other.
You should probably use a UserAppN category for your miscellaneous messages.
<P>
<H4><A NAME=SECTION001013080000000000000> Text (-vDebug t)</A></H4>
<P>
These messages are primarily used by the <tt>
 vTextCanvasPane</tt> class,
and are useful for debugging text display.
<P>
<H4><A NAME=SECTION001013090000000000000> BadVals (-vDebug v)</A></H4>
<P>
These messages are generated when a bad parameter or illegal value
is detected. These can be most useful.
<P>
<H4><A NAME=SECTION0010130100000000000000> Constructor (-vDebug C)</A></H4>
<P>
These messages are displayed whenever a constructor for an
object is called. These messages can be very useful for tracking
object creation bugs. You should try to have
<tt>
 UserDebug(Constructor,&quot;X::X constructor&quot;)</tt> messages
for all of your constructors, and a corresponding Destructor message.
<P>
<H4><A NAME=SECTION0010130110000000000000> Destructor (-vDebug D)</A></H4>
<P>
Messages from an object destructor.
<P>
<H4><A NAME=SECTION0010130120000000000000> UserApp1, UserApp2, UserApp3 (-vDebug 123)</A></H4>
<P>
These are provided to allow you up to three categories of your
own debugging messages.
<P>
<H2><A NAME=SECTION001014000000000000000> Example</A></H2>
<P>
To use the V
  debugging facilities, it is usually easiest to
add a Debug command to a menu item -- controlled by the <tt>
 vDEBUG</tt>
symbol.  Then add calls to <tt>
 UserDebug</tt> as needed in your code.
This example shows how to define a Debug menu item, and then invoke
the <tt>
 vDebugDialog</tt> to control debugging settings.
<P>
<PRE>#include &lt;v/vdebug.h&gt;

    vMenu FileMenu[] =
      {
        ...
#ifdef vDEBUG
        {&quot;-&quot;, M_Line, notSens,notChk,noKeyLbl,noKey,noSub},
        {&quot;Debug&quot;, M_SetDebug,isSens,notChk,noKeyLbl,noKey,noSub},
#endif
        ...
      };

    ...
    case M_SetDebug:
     {
        vDebugDialog debug(this);    // instantiate
        UserDebug(Misc,&quot;About to show Debug dialog.\n&quot;);
        debug.SetDebug();            // show the dialog
        break;
     }
    ...
</PRE>
<P>

<P>
<H1><A NAME=SECTION001020000000000000000> vFileSelect</A></H1>
<P>
<A NAME=6310>&#160;</A>
<P>
A utility class to select or set a file name.
<P>
<H2><A NAME=SECTION001021000000000000000> Synopsis</A></H2>
<P>
<DL ><DT>Header:
<DD> <tt>
 &lt;v/vfilesel.h&gt;</tt>
        <DT>Class name:
<DD> vFileSelect
        <DT>Hierarchy:
<DD> vModalDialog -&gt;
  vFileSelect
<P>
 </DL><H2><A NAME=SECTION001022000000000000000> Description</A></H2>
<P>
This utility class provides a dialog interface for selecting
filenames. It can be used either to select an input file name,
or verify or change an output file name. This utility does not
open or alter files -- it simply constructs a legal file name for
use in opening a file.
<P>
<H2><A NAME=SECTION001023000000000000000> Methods</A></H2>
<P>

<H3><A NAME=SECTION001023100000000000000> vFileSelect(vBaseWindow* win)</A></H3>
<P>
<A NAME=6313>&#160;</A>
<P>
<H3><A NAME=SECTION001023200000000000000> vFileSelect(vApp* app)</A></H3>
<P>
The <tt>
 vFileSelect</tt> constructor requires a pointer to a
<tt>
 vBaseWindow</tt>, which includes all V
  windows and dialogs,
or a pointer to the <tt>
 vApp</tt> object.
You will usually pass the <tt>
 this</tt> to the constructor.
<P>

<H3><A NAME=SECTION001023300000000000000> int FileSelect(const char* prompt, char* filename, const
int maxLen, char** filterList, int&amp; filterIndex)</A></H3>
<P>
<A NAME=6317>&#160;</A>
<P>
<H3><A NAME=SECTION001023400000000000000> int FileSelectSave(const char* prompt, char* filename, const int
maxLen, char** filterList, int&amp; filterIndex)</A></H3>
<P>
<A NAME=6320>&#160;</A>
<P>
You provide a <tt>
 prompt</tt> for the user, such as ``Open File.'' The
user then uses the dialog to select or set a file name. <tt>
 FileSelect</tt>
returns <tt>
 True</tt> if the user picked the OK button, and <tt>
 False</tt>
if they used the Cancel button.
<P>
The filename will be filled in to the <tt>
 filename</tt> buffer of
maximum length <tt>
 maxLen</tt>. The full path of the file will be
included with the file name.
<P>
You can also provide a list of filter patterns to filter file
extensions. If you don't provide a filter list, the default filter
of ``*'' will be used. Each item in the filter list can include a list
of file extensions separated by blanks. You can provide several
filtering options. The first filter in the list will be the default.
Only leading ``*'' wild cards are supported.
<P>
The <tt>
 filterIndex</tt> reference parameter is used to track which
filter the user selected. After <tt>
 FileSelect</tt> returns, <tt>
 filterIndex</tt>
will be set to the index of the filter list that the user last
selected. For the best interface, you should remember this value for
the next time you call <tt>
 FileSelect</tt> with the same filter list so
that the user selected filter will be preserved.
<P>
You should use <tt>
 FileSelect</tt> to open a new or existing file. If
the user is being asked to save a file (usually after picking a
<em>Save As</em> menu choice), use the <tt>
 FileSelectSave</tt> method. On
some platforms, there will be no difference between these two
methods (X, for example). On other platforms (Windows, for example),
different underlying system provided file dialogs are used. To your
program, there will be no difference in functionality.
<P>
<H2><A NAME=SECTION001024000000000000000> Example</A></H2>
<P>
The following is a simple example of using <tt>
 vFileSelect</tt>.
<P>
<IMG BORDER=0 ALIGN=BOTTOM ALT="" SRC="../fig/filesel.gif">

<P>
<PRE>    static char* filter[] =     // define a filter list
      {
        &quot;*&quot;,                    // all files
        &quot;*.txt&quot;,                // .txt files
        &quot;*.c *.cpp *.h&quot;,        // C sources
        0
      };
    static int filterIndex = 0;    // to track filter picked
    char name[100];

    vFileSelect fsel(this);     // instantiate

    int oans = fsel.FileSelect(&quot;Open file&quot;,name,99,filter,filterIndex);

    vNoticeDialog fsnote(this); // make an instance

    if (oans &amp;&amp; *name)
        (void)fsnote.Notice(name);
    else
        (void)fsnote.Notice(&quot;No file name input.&quot;);
</PRE>
<P>

<P>
<H1><A NAME=SECTION001030000000000000000> vFontSelect</A></H1>
<P>
<A NAME=6526>&#160;</A>
<P>
A utility class to select or set a file name.
<P>
<H2><A NAME=SECTION001031000000000000000> Synopsis</A></H2>
<P>
<DL ><DT>Header:
<DD> <tt>
 &lt;v/vfontsel.h&gt;</tt>
        <DT>Class name:
<DD> vFontSelect
        <DT>Hierarchy:
<DD> vModalDialog -&gt;
  vFontSelect
<P>
 </DL><H2><A NAME=SECTION001032000000000000000> Description</A></H2>
<P>
This class provides the <tt>
 FontSelect</tt> method to set
the font being used. This class provides a platform
independent way to change fonts. Depending on the platform,
the user will be able to select many or most of the fonts
available on the platform. On Windows, for example, the standard
Windows font selection dialog is be used. On X, a relatively
full set of fonts are available.
<P>
<H2><A NAME=SECTION001033000000000000000> Methods</A></H2>
<P>
<H3><A NAME=SECTION001033100000000000000> vFontSelect(vBaseWindow* win)</A></H3>
<P>
<A NAME=6529>&#160;</A>
<P>
<H3><A NAME=SECTION001033200000000000000> vFontSelect(vApp* app)</A></H3>
<P>
The <tt>
 vFontSelect</tt> constructor requires a pointer to a
<tt>
 vBaseWindow</tt>, which includes all V
  windows and dialogs,
or a pointer to the <tt>
 vApp</tt> object.
You will usually pass the <tt>
 this</tt> to the constructor.
<P>
<H3><A NAME=SECTION001033300000000000000> int FontSelect(vFont&amp; font, const char* msg = &quot;Select Font&quot;)</A></H3>
<P>
<A NAME=6533>&#160;</A>
<P>
This method displays a dialog that lets the user select font
characteristics. If possible, the native font selection dialog
will be used (e.g., Windows). The font dialog will display the
current characteristics of the <tt>
 font</tt> object, and change
them upon successful return. A <tt>
 false</tt> return means the user
selected Cancel, while a <tt>
 true</tt> return means the user
finished the selection with an OK.
<P>

<P>
<H1><A NAME=SECTION001040000000000000000> vNoticeDialog</A></H1>
<P>
<A NAME=6536>&#160;</A>
<P>
A utility class to display a message.
<P>
<H2><A NAME=SECTION001041000000000000000> Synopsis</A></H2>
<P>
<DL ><DT>Header:
<DD> <tt>
 &lt;v/vnotice.h&gt;</tt>
        <DT>Class name:
<DD> vNoticeDialog
        <DT>Hierarchy:
<DD> vModalDialog -&gt;
  vNoticeDialog
<P>
 </DL><H2><A NAME=SECTION001042000000000000000> Description</A></H2>
<P>
This simple utility class can be used to display a simple
message to the user. The utility displays the message, and then
waits for the user to enter to press OK.
<P>
<H2><A NAME=SECTION001043000000000000000> New Methods</A></H2>
<P>

<H3><A NAME=SECTION001043100000000000000> vNoticeDialog(vBaseWindow* win)</A></H3>
<P>
<A NAME=6539>&#160;</A>
<P>
<H3><A NAME=SECTION001043200000000000000> vNoticeDialog(vApp* app)</A></H3>
<P>
The <tt>
 vNoticeDialog</tt> constructor requires a pointer to a
<tt>
 vBaseWindow</tt>, which includes all V
  windows and dialogs,
or a pointer to the <tt>
 vApp</tt> object.
You will usually pass the <tt>
 this</tt> to the constructor.
<P>

<H3><A NAME=SECTION001043300000000000000> void Notice(const char* prompt)</A></H3>
<P>
<A NAME=6543>&#160;</A>
<P>
You provide a <tt>
 prompt</tt> for the user. If the message
contains '<b>backslash</b>n' newlines, it will be shown on multiple
lines.
<P>
<H2><A NAME=SECTION001044000000000000000> Example</A></H2>
<P>
The following is a simple example of using <tt>
 vNoticeDialog</tt>.
<P>
<IMG BORDER=0 ALIGN=BOTTOM ALT="" SRC="../fig/notice.gif">

<P>
<PRE>    #include &lt;v/vnotice.h&gt;
    ...
    vNoticeDialog note(this);   // instantiate a notice

    (void)note.Notice(&quot;This is a notice.&quot;);
</PRE>
<P>

<P>
<H1><A NAME=SECTION001050000000000000000> vReplyDialog</A></H1>
<P>
<A NAME=6606>&#160;</A>
<P>
A utility class to get a text reply from the user.
<P>
<H2><A NAME=SECTION001051000000000000000> Synopsis</A></H2>
<P>
<DL ><DT>Header:
<DD> <tt>
 &lt;v/vreply.h&gt;</tt>
        <DT>Class name:
<DD> vReplyDialog
        <DT>Hierarchy:
<DD> vModalDialog -&gt;
  vReplyDialog
<P>
 </DL><H2><A NAME=SECTION001052000000000000000> Description</A></H2>
<P>
This simple utility class can be used to obtain a text reply from
the user. The utility displays a message, and then waits for the
user to enter a reply into the reply field. The user completes the
operation by pressing OK or Cancel.
<P>
<H2><A NAME=SECTION001053000000000000000> New Methods</A></H2>
<P>

<H3><A NAME=SECTION001053100000000000000> vReplyDialog(vBaseWindow* win)</A></H3>
<P>
<A NAME=6609>&#160;</A>
<P>
<H3><A NAME=SECTION001053200000000000000> vReplyDialog(vApp* app)</A></H3>
<P>
The <tt>
 vReplyDialog</tt> constructor requires a pointer to a
<tt>
 vBaseWindow</tt>, which includes all V
  windows and dialogs,
or a pointer to the <tt>
 vApp</tt> object.
You will usually pass the <tt>
 this</tt> to the constructor.
<P>

<H3><A NAME=SECTION001053300000000000000> int Reply(const char* prompt, char* reply, const int maxLen)</A></H3>
<P>
<A NAME=6613>&#160;</A>
<P>
You provide a <tt>
 prompt</tt> for the user. The text the user enters
will be returned to the buffer <tt>
 reply</tt> of maximum length <tt>
 maxLen</tt>.
<tt>
 Reply</tt> will return the value <tt>
 M_OK</tt> or <tt>
 M_Cancel</tt>.
<P>
<H2><A NAME=SECTION001054000000000000000> Example</A></H2>
<P>
The following is a simple example of using <tt>
 vReplyDialog</tt>.
<P>
<IMG BORDER=0 ALIGN=BOTTOM ALT="" SRC="../fig/reply.gif">

<P>
<PRE>    #include &lt;v/vreply.h&gt;
    ...
    vReplyDialog rp(this);      // instantiate
    char r[100];                // a buffer for reply

    (void)rp.Reply(&quot;Please enter some text.&quot;,r,99);

    vNoticeDialog note(this);   // instantiate a notice

    if (*r)
        (void)note.Notice(r);
    else
        (void)note.Notice(&quot;No text input.&quot;);
</PRE>
<P>

<P>
<H1><A NAME=SECTION001060000000000000000> vTimer</A></H1>
<P>
<A NAME=6709>&#160;</A>
<P>
<A NAME=6641>&#160;</A>
<P>
A class for getting timer events.
<P>
<H2><A NAME=SECTION001061000000000000000> Synopsis</A></H2>
<P>
<DL ><DT>Header:
<DD> <tt>
 &lt;v/vtimer.h&gt;</tt>
	<DT>Class name:
<DD> vTimer
 	<DT>Hierarchy:
<DD> vTimer
<P>
 </DL><H2><A NAME=SECTION001062000000000000000> Description</A></H2>
<P>
This is a utility class that allows you to get events driven
by the system timer. The accuracy and resolution of timers on
various systems varies, so this should be used only to get
events on a more or less regular basis. Use the C library <tt>
 time</tt>
routines to get real clock time.
<P>
<H2><A NAME=SECTION001063000000000000000> New Methods</A></H2>
<P>

<H3><A NAME=SECTION001063100000000000000> vTimer</A></H3>
<P>
<A NAME=6712>&#160;</A>
<P>
This constructs a timer object. The timer doesn't run until
you start it with <tt>
 TimerSet</tt>. To make a timer useful, you
can override the constructor to add a pointer to a window, and
then use that pointer from within your <tt>
 TimerTick</tt> method
to do something in that window: <tt>
 myTimer(vWindow* useWindow)</tt>.
<P>

<H3><A NAME=SECTION001063200000000000000> int TimerSet(long interval)</A></H3>
<P>
<A NAME=6715>&#160;</A>
<P>
This starts the timer going. The timer will call your overridden
<tt>
 TimerTick</tt> method approximately every <tt>
 interval</tt>
milliseconds until you stop the timer. Most systems don't support
an unlimited number of timers, and <tt>
 TimerSet</tt> will return 0
if it couldn't get a system timer.
<P>

<H3><A NAME=SECTION001063300000000000000> void TimerStop()</A></H3>
<P>
<A NAME=6718>&#160;</A>
<P>
Calling this stops the timer, but does not destruct it.
<P>

<H3><A NAME=SECTION001063400000000000000> void TimerTick()</A></H3>
<P>
<A NAME=6721>&#160;</A>
<P>
This method is called by the system every interval milliseconds
(more or less). The way to use the timer is to derive your own
class, and override the <tt>
 TimerTick</tt> method.  Your method
will be called according to the interval set for the timer. Note
that you can't count on the accuracy of the timer interval.
<P>

<H1><A NAME=SECTION001070000000000000000> vYNReplyDialog</A></H1>
<P>
<A NAME=6724>&#160;</A>
<P>
A utility class to display a message, and get a Yes or No answer.
<P>
<H2><A NAME=SECTION001071000000000000000> Synopsis</A></H2>
<P>
<DL ><DT>Header:
<DD> <tt>
 &lt;v/vynreply.h&gt;</tt>
        <DT>Class name:
<DD> vYNReplyDialog
        <DT>Hierarchy:
<DD> vModalDialog -&gt;
  vYNReplyDialog
<P>
 </DL><H2><A NAME=SECTION001072000000000000000> Description</A></H2>
<P>
This simple utility class can be used to display a simple
message to the user. The utility displays the message, and then
waits for the user to enter to press Yes, No, or Cancel.
<P>
<H2><A NAME=SECTION001073000000000000000> New Methods</A></H2>
<P>

<H3><A NAME=SECTION001073100000000000000> vYNReplyDialog(vBaseWindow* win)</A></H3>
<P>
<A NAME=6727>&#160;</A>
<P>
<H3><A NAME=SECTION001073200000000000000> vYNReplyDialog(vApp* app)</A></H3>
<P>
The <tt>
 vYNReplyDialog</tt> constructor requires a pointer to a
<tt>
 vBaseWindow</tt>, which includes all V
  windows and dialogs,
or a pointer to the <tt>
 vApp</tt> object.
You will usually pass the <tt>
 this</tt> to the constructor.
<P>

<H3><A NAME=SECTION001073300000000000000> int AskYN(const char* prompt)</A></H3>
<P>
<A NAME=6731>&#160;</A>
<P>
You provide a <tt>
 prompt</tt> for the user. The user will then press
the Yes, No, or Cancel buttons. <tt>
 AskYN</tt> returns a 1 if
the user selected Yes, a 0 if they selected No, and a -1 if
they selected Cancel.
<P>
<H2><A NAME=SECTION001074000000000000000> Example</A></H2>
<P>
The following is a simple example of using <tt>
 vYNReplyDialog</tt>.
<P>
<IMG BORDER=0 ALIGN=BOTTOM ALT="" SRC="../fig/ynreply.gif">

<P>
<PRE>    #include &lt;v/vynreply.h&gt;
    ...
    vYNReplyDialog ynd(this);   // instantiate a notice

    int ans = ynd.AskYN(&quot;Exit. Are you sure?);
    if (ans == 1)
      exit(0);
</PRE>
<P>

<H1><A NAME=SECTION001080000000000000000> Utility Functions</A></H1>
<P>
<A NAME=6760>&#160;</A>
<P>
Several useful utility functions.
<P>
<H2><A NAME=SECTION001081000000000000000> Synopsis</A></H2>
<P>
<DL ><DT>Header:
<DD> <tt>
 &lt;v/vutil.h&gt;</tt>
<P>
 </DL><H2><A NAME=SECTION001082000000000000000> Description</A></H2>
<P>
V
  provides several utility functions that can often help with
software portability (and can just be useful). These are free
subprograms -- not a member of any specific class.
<P>
<H3><A NAME=SECTION001082100000000000000> void ByteToStr(unsigned char b, char* str)</A></H3>
<P>
<A NAME=6856>&#160;</A>
<P>
This will convert the unsigned char in <tt>
 b</tt> to a <em>Hex</em> character
string in <tt>
 str</tt>. You need to make <tt>
 str</tt> big enough to
hold the string.
<P>
<H3><A NAME=SECTION001082200000000000000> void IntToStr(int intg, char* str)</A></H3>
<P>
<A NAME=6859>&#160;</A>
<P>
This will convert the integer in <tt>
 intg</tt> to a character
string in <tt>
 str</tt>. You need to make <tt>
 str</tt> big enough
to hold the string.
<P>
<H3><A NAME=SECTION001082300000000000000> void LongToStr(long intg, char* str)</A></H3>
<P>
<A NAME=6862>&#160;</A>
<P>
This will convert the long integer in <tt>
 intg</tt> to a character
string in <tt>
 str</tt>. You need to make <tt>
 str</tt> big enough
to hold the string.
<P>
<H3><A NAME=SECTION001082400000000000000> long StrToLong(char* str)</A></H3>
<P>
<A NAME=6865>&#160;</A>
<P>
This will convert the character string in <tt>
 str</tt> into a long
integer. You can cast to get ints.
<P>
<H3><A NAME=SECTION001082500000000000000> void vGetLocalTime(char* tm)</A></H3>
<P>
<A NAME=6868>&#160;</A>
<P>
<A NAME=6787>&#160;</A>
<P>
This will return a string representation of the current local time
to the string <tt>
 tm</tt>. The format will be ``HH:MM:SS AM''. If you
need a different format, you will need to use the C functions
<tt>
 time</tt>, <tt>
 localtime</tt>, and <tt>
 strftime</tt> directly.
<P>
<H3><A NAME=SECTION001082600000000000000> void vGetLocalDate(char* dt)</A></H3>
<P>
<A NAME=6871>&#160;</A>
<P>
<A NAME=6794>&#160;</A>
<P>
This will return a string representation of the current local
date to the string <tt>
 dt</tt>. The format will be ``MM/DD/YY''.
If you need a different format, you will need to use the C
functions <tt>
 time</tt>, <tt>
 localtime</tt>, and <tt>
 strftime</tt>
directly.
<P>

<H1><A NAME=SECTION001090000000000000000> Utility Programs</A></H1>
<P>
<A NAME=6800>&#160;</A>
<A NAME=6801>&#160;</A> <A NAME=6802>&#160;</A>
<P>
<H2><A NAME=SECTION001091000000000000000> bmp2vbm</A></H2>
<P>
The utility <tt>
 bmp2vbm</tt> converts a Window or OS/2 <tt>
 .bmp</tt>
format bitmap file into a <tt>
 .vbm</tt> V
  icon bitmap format file.
The <tt>
 .vbm</tt> file is then used with a <tt>
 vIcon</tt> object
definition. The <tt>
 bmp2vbm</tt> utility will not convert all
<tt>
 .bmp</tt> files. Specifically, it can't handle old format
<tt>
 .bmp</tt> files, nor can it handle compressed <tt>
 .bmp</tt> files.
<P>
Windows has many tools to generate <tt>
 .bmp</tt> files. For X,
the widely available tool <tt>
 xv</tt> can generate <tt>
 .bmp</tt>
files from various source formats.
<P>
<tt>
 Bmp2vbm</tt> is a command line tool - run it from a Unix prompt,
or from an <tt>
 MSDOS</tt> box on Windows. The command line format is:
<tt>
 bmp2vbm inputname outputname iconname</tt>. You should specify only
the base file names: <tt>
 bmp2vbm</tt> will automatically supply
the <tt>
 .bmp</tt> and <tt>
 .vbm</tt> extension. The <tt>
 iconname</tt>
specifies the name used to generate the date (e.g., <tt>
 iconname_bits</tt>).
<P>

<H1><A NAME=SECTION0010100000000000000000> More Goodies</A></H1>
<P>
<A NAME=6825>&#160;</A>
<A NAME=6826>&#160;</A>
<P>
The directory <tt>
 v/icons</tt> includes over 30 different monochrome
icons in <tt>
 .vbm</tt> format suitable for building command pane
tool bars. Most of these icons were derived from various
Windows sources, and I would encourage their use for the
standard functions they define. Some of these include
creating a new file (new.vbm), opening an existing file (open.vbm),
cut, copy, and paste (*.vbm), printing (print.vbm), and so on.
<P>
There is a demo program in the <tt>
 v/icons</tt> directory that
can be compiled and used to see what all the icons look like.
All the icons are 16 by 16 bits, and
will match standard buttons in height on Windows. The height of 
standard buttons on X depends on the default system font.
<P>
As usual, contributions of other V
  icons is more than welcome.
I hope to build up the icons directory to several hundred icons.
<P>

<P>
<BR> <HR><A NAME=tex2html1455 HREF="node11.html"><IMG ALIGN=BOTTOM ALT="next" SRC="../icons/next.gif"></A>   <A NAME=tex2html1453 HREF="vwebref.html"><IMG ALIGN=BOTTOM ALT="up" SRC="../icons/up.gif"></A>   <A NAME=tex2html1447 HREF="node9.html"><IMG ALIGN=BOTTOM ALT="gif" SRC="../icons/prev.gif"></A>   <A NAME=tex2html1457 HREF="node1.html"><IMG ALIGN=BOTTOM ALT="contents" SRC="../icons/contents.gif"></A>      <BR>
<B> Next:</B> <A NAME=tex2html1456 HREF="node11.html"> Tutorial C++ Source</A>
<B>Up:</B> <A NAME=tex2html1454 HREF="vwebref.html">V Reference Manual</A>
<B> Previous:</B> <A NAME=tex2html1448 HREF="node9.html"> Standard V Values</A>
<BR> <HR> <P>
<BR> <HR>
<P><ADDRESS>
<I>Bruce Wampler <BR>
Thu Nov 14 09:25:45 MST 1996</I>
</ADDRESS>
</BODY>
