root/trunk/sam3/sam3.c

Revision 14, 2.8 kB (checked in by jvw, 2 years ago)

HEX/ASCII (sector) editor control added

Line 
1#define SAM_D "Popup-window sample for JvW-Fsys TXW OpenWatcom build environment."
2
3#define SAM_C "(c) 2005: Jan van Wijk"
4
5#define SAM_V "1.00 21-09-2005" // Initial version
6
7#include <txlib.h>                              // TX library interface
8#if   defined (WIN32)
9   #define SAM_N "SAM3 winNT"
10#elif defined (DOS32)
11   #define SAM_N "SAM3 Dos32"
12#elif defined (LINUX)
13   #define SAM_N "SAM3 Linux"
14#else
15   #define SAM_N "SAM3  OS/2"
16#endif
17
18
19#define SAM_MANDATORY_PARAMS     1              // # of mandatory params to EXE
20
21char *usagetext[] =
22{
23   " mandatory-params   [optional-params]",
24   "",
25   "  Switch character for EXE switches is '-' or '/'. All single letter",
26   "  switches are case-sensitive, long switchnames like 'query' are not.",
27   "",
28#if defined (DUMP)
29   " -123[t][s][l][r][dxx] = trace level 123, [t]stamp; [s]creen; No [l]ogging;"
30   "                                          [r]e-open [d]elay xx ms per line",
31#endif
32   "",
33   " -?            = help on executable commandline switches (this text)",
34   " -7            = Use 7-bit ASCII only (no 'graphic' characters)",
35   " -a            = switch off usage of ANSI escape characters for color",
36   " -l:logfile    = start logging immediately to 'logfile.log'",
37   "",
38   NULL
39};
40
41
42int main (int argc, char *argv[]);
43
44/*****************************************************************************/
45/* Main function of the program, handle commandline-arguments                */
46/*****************************************************************************/
47int main (int argc, char *argv[])
48{
49   ULONG               rc = NO_ERROR;           // function return
50   TXLN                text;
51
52   TxINITmain( "SAMTRACE", "SAM", FALSE, 0);
53
54   if (TxaExeSwitch('l'))                       // start logfile now ?
55   {
56      TxAppendToLogFile( TxaExeSwitchStr( 'l', NULL, "sam"), TRUE);
57   }
58   if ((TxaExeSwitch('?')) ||                   // switch help requested
59       (TxaExeArgc() <= SAM_MANDATORY_PARAMS))  // or not enough params
60   {
61      TxPrint( "\n%s %s %s\n%s\n\nUsage: %s",
62                  SAM_N, SAM_V, SAM_C, SAM_D, TxaExeArgv(0));
63      TxShowTxt( usagetext);
64   }
65   else
66   {
67      if (txwInitializeDesktop( NULL, NULL) != 0)
68      {
69
70         sprintf( text, "Hello from SAMPLE-3, parameter = '%s'", TxaExeArgv(1));
71
72         TxMessage( TRUE, 0, text);             // present message in a popup
73
74         txwTerminateDesktop();
75      }
76      else
77      {
78         TxPrint("Failed to intialize desktop\n");
79      }
80   }
81   TxEXITmain(rc);                              // TX Exit code, incl tracing
82}                                               // end 'main'
83/*---------------------------------------------------------------------------*/
Note: See TracBrowser for help on using the browser.