Copyright: MSMWSSAM.HLP, documentation for MSM-Workstation 2.0.0 samples, copyright © 1998 Micronetics Design Corporation   Monday, April 06, 1998 15:44:55
Citation: Extract from MSMWSSAM.HLP, documentation for MSM-Workstation 2.0.0 samples, copyright © 1998 Micronetics Design Corporation


Help Contents
Contents

MSM-Workstation Samples


MSM-Workstation Samples

Cancel Sample

Choices Sample

Colors Sample

Document Scrolling Sample

Error-Handling Sample

Front-End Sample

Generic Box Drawing Sample

Letter Slide Sample

List Selection Sample

MDI Sample

Message Box Sample

MSM-Activate Banking Sample

Printer Sample

Socket Sample

Tab Sample

Tic Tac Toe Sample

Two Timers Sample


A number of sample windows and applications are provided with MSM-Workstation to illustrate different Workstation features.

The samples are provided in the Explorer.M database. All samples are pre-loaded and compiled and can be tested directly.  Source files for the samples are provided in the Samples directory.


Using the Samples Without the Explorer Database

Non-Explorer databases may also be used to run samples. This requires importing the samples from host files in the Samples directory.

Windows

The files containing samples are mostly .VEX files containing window definitions.

To import the windows in a file named File.VEX, select Import from the File menu and then load file File.VEX from the Samples\WS directory.

Routines and globals

Occasionally ancillary routines and globals may need to be loaded from host files to support a sample. When using the Explorer database, this has already been done. To load routines or globals from File, perform the following steps:

1.	From the Tools menu, select Routines, then Restore, and then select file File from the Samples\WS directory.

2.	From the Tools menu, select Globals, then Restore, and then select file File from the Samples\WS directory.

Modules

Module import/export is not supported in MSM-Workstation 2.0 and earlier versions.  Modules supporting the samples are present in the Explorer database.  However, for use with non-Explorer databases, some samples require the creation of modules.  Detailed instructions for creating modules are provided in the samples.


Using the System Browser to open a window

Use the System Browser to display a list of windows.  If you can't find the System Browser window, go to the View menu and make sure there is a check mark next to its entry.  Then use the Window menu to find it.

In the left side of the System Browser window, open the Databases branch of the tree and find the Explorer database (or your database).  Under the database, click Windows.  This will display a list of windows in the right side of the System Browser.

To open a window, double-click it.

This procedure can be used to open other types of objects, such as applications, routines, sources, and globals.  Just click a different object type under the branch for your database in the left side of the System Browser.


Cancel Sample

This sample demonstrates how to provide a cancel button on a task that may take a long while to complete. This can also be used to update a progress bar to keep the user informed about the task they have started.

Background

The technique is to break the long task up into short sections, so if you are searching for a record on the database then check maybe 100 records on each call. Use a Timer control to keep calling this search function until either the search is complete or the user presses the cancel button.

The Timer control should be set to keep calling the entry point that does the work as fast as possible.  By using a Timer in this way the application can still respond to events. Any events generated while processing the data (such as a press of the cancel button) will be received by the application ahead of the Timer's next event.

Without such a mechanism the application will be unresponsive while processing the data.  This is bad GUI programming practice, as the user should feel in command at all times.

Components

File	Description
CANCEL.VEX	Export file of the SampleCancel window.
See Also:

To run the sample


MSM-Workstation Samples - Cancel Sample - To run the sample
To run the sample

1.	If you are not using the Explorer database, load file CANCEL.VEX.

2.	Use the System Browser to open window SampleCancel.

3.	Click the Quick Test toolbar button, or press the keyboard shortcut F5.  This will compile the sample if necessary, then run it in test mode.

4.	When done, click the Close button in the upper-right corner of the sample window, and when the Testing window reappears click Close.


Choices Sample

This sample demonstrates the use of checkboxes and radio buttons.

Background

Both CheckBox and RadioButton controls allow you to display and select from a list of options. There is an important difference between the two; items in a RadioButton control are mutually exclusive. You can select only one item in the group.

Similar CheckBox controls frequently are grouped together in a GroupBox control, a mechanism that is used to group items visually on a window. Because of this grouping, you may not immediately realize that there is a functional difference between CheckBox controls and RadioButton controls.

A CheckBox control displays a single item and allows the user to toggle the value between 1 (checked) and 0 (not checked). Although a RadioButton control generally displays two or more options, you can select only one of the options.

In this sample, the items in the RadioButton control are dynamically set based upon the values of the CheckBox controls.  Such dynamically generated RadioButton items are somewhat unusual.

Use of the %%ResetChoice() macro also is demonstrated in this sample. The %%ResetChoice() macro uses an array to populate the RadioButton control. This macro and the %%SetChoice() macro are used to populate controls that can take a list of choices (a list-type control or a radio button set).

Components

File	Description
CHOICES.VEX	Export file of the SampleChoices window.
See Also:

To run the sample


MSM-Workstation Samples - Choices Sample - To run the sample
To run the sample

1.	If you are not using the Explorer database, load file CHOICES.VEX.

2.	Use the System Browser to open window SampleChoices.

3.	Click the Quick Test toolbar button, or press the keyboard shortcut F5.  This will compile the sample if necessary, then run it in test mode.

4.	When done, click the Close button in the upper-right corner of the sample window, and when the Testing window reappears click Close.


Colors Sample

This sample demonstrates the use of scroll controls and describes how to change the color properties of both windows and controls.

Background

The Scroll control provides a visual representation of a numeric range and the ability to move through that range by manipulating a small button called a thumb on the scroll bar. It is important to note that the Scroll control itself does not control anything. When the thumb is moved, a Scroll event occurs. By placing action logic in the Scroll event, the developer enables the Scroll control to manipulate any other control.

For applications that use specific color schemes rather than the generic Windows color scheme (as defined in the Windows Control Panel), the developer must be familiar with the color properties. The ForeColor, BackColor, TForeColor and TBackColor properties for controls (not all controls have TForeColor, TBackColor) and the ForeColor, BackColor, and Color properties for windows all take as a value a string in the form of red,green,blue.  The values of red, green, and blue are integers in the range of 0 to 65535.  The color black is represented as 0,0,0, and white is 65535,65535,65535.

Because most colors cannot be represented as solid colors, the dithering technique is used to blend a primary background color with secondary and tertiary foreground colors. The color properties of text (such as captions of controls) only use solid colors. As illustrated by this sample, the closest solid color to the selected value is used.

To change color values with this sample, either enter a number manually or drag the scroll bar for the color. Note that small steps on the scroll bar (clicking the scroll bar arrows) change the color value by 1K, giving 64 discrete values, and large steps (clicking the scroll bar itself) change by 8K, giving eight discrete values.

If the color values were to be updated dynamically as the user dragged the thumb back and forth, the ptrDrag event would need some action logic.

Components

File	Description
COLORS.VEX	Export file of the SampleColors window.
See Also:

To run the sample


MSM-Workstation Samples - Colors Sample - To run the sample
To run the sample

1.	If you are not using the Explorer database, load file COLORS.VEX.

2.	Use the System Browser to open window SampleColors.

3.	Click the Quick Test toolbar button, or press the keyboard shortcut F5.  This will compile the sample if necessary, then run it in test mode.

4.	When done, click the Close button in the upper-right corner of the sample window, and when the Testing window reappears click Close.

Note  To change color values, either enter a number manually or drag the scroll bar for the color.


Document Scrolling Sample

This sample demonstrates how to use a Document control and the Menu bar.

The window contains a Document control with an enabled vertical scroll bar. The objective is to allow you to scroll through a document.  Two documents are provided for this purpose; you can select either document from the Documents menu.

Background

Many applications rely on the menu bar to provide easy point-and-click access to the functions supported by the application. This has two major benefits: the user is not required to memorize keyboard commands, and the developer is not compelled to provide a gadget for each function.  To change several properties of the Document control, this sample uses the Action Logic that is executed when a menu selection event occurs.

Components

File	Description
DOCSCROL.VEX	Export file of the SampleScrollingDocument window.
DOCSCROL.GBL	Global save file of two sample documents. The global names are SAMGBADD and SAMDECIN.
See Also:

To run the sample


MSM-Workstation Samples - Document Scrolling Sample - To run the sample
To run the sample

1.	If you are not using the Explorer database, load file DOCSCROL.VEX.

2.	Use the System Browser to open window SampleScrollingDocument.

3.	Click the Quick Test toolbar button, or press the keyboard shortcut F5.  This will compile the sample if necessary, then run it in test mode.

4.	When done, click the Close button in the upper-right corner of the sample window, and when the Testing window reappears click Close.


Error-Handling Sample

This sample demonstrates how to trap and report errors.

Background

Error-handling is essential to most applications. This can include graceful handling of anticipated errors as well as reporting and recovery from unexpected errors. MSM-Workstation allows the developer to trap and handle errors in several ways.  This sample demonstrates MSM-Workstation's error-trapping capabilities.

The ANSI/MDC X11.1-1995 M Language Standard defines error-trapping using system variables $ECODE, $ETRAP, and $ESTACK.  This is often referred to as "new-style" error-trapping. MSM-Workstation implements new-style error-trapping and maintains support for "old-style" error-trapping using the $ZERROR and $ZTRAP variables.

This sample illustrates new-style, old-style, and mixed-style error-trapping. Error traps at module, window, and procedure levels are demonstrated.  Buttons are provided to generate an error (divide by zero), which is handled in various ways.

The module-level trapping requires you to define the module first, as described below.

Components

File	Description
ERRHAND.VEX	Export file of the SampleErrorHandling and SampleErrors windows.
See Also:

To run the sample

To test module-level error-handling

To set up module-level error-handling using a non-Explorer database


MSM-Workstation Samples - Error-Handling Sample - To run the sample
To run the sample

1.	If you are not using the Explorer database, load file ERRHAND.VEX.

2.	Follow the steps in "To set up module-level error-handling using a non-Explorer database" below.

3.	Use the System Browser to open window SampleErrors.

4.	Click the Quick Test toolbar button, or press the keyboard shortcut F5.  This will compile the sample if necessary, then run it in test mode.

5.	When done, click the Close button in the upper-right corner of the sample window, and when the Testing window reappears click Close.


To test module-level error-handling

1.	From the File menu, select Test to run the sample window. From the Type list, select Module. From the Name list, select SampleErrorHandling, if this was created during step 2 above. Otherwise use the Explorer database object called ERROR. Click OK.

2.	On the Testing window, set Debug Mode to Off and then click Start.

3.	After testing is complete, close the window being tested.  On the Testing window, click Close.


To set up module-level error-handling using a non-Explorer database

If you are not using the Explorer database, a module must be created before you can run this sample:

1.	From the File menu, select New to create a new module. From the Type list, select Module. In the Name box, enter SampleErrorHandling.

2.	From the Element menu, select Definition.  Attach windows SampleErrorHandling and SampleErrors to the module.

3.	Click on module SampleErrorHandling to set the focus to it.  From the Element menu, select Actions.

4.	From the Event list, select Enter to add an Enter action logic section to the module. In the Action box, enter the following:

; Initialize and start off window

; Clear error codes (new and old)

;

S $EC="",$ZE=""

;

%%DoWin(SampleErrors)

5.	Click Save.

6.	From the Event list, select Error to add an Error action logic section to the module. In the Action box, enter the following:

; Module-level error handling

;

D E^%msgbox("Error trapped by module"_$C(13,10,10)_
"$EC="_$EC_$C(13,10,10)_"$ZE="_$ZE,"SampleErrorHandling 	(Module)")

;

;	Use NotOK (uncomment next line) to report error back to caller

;	%%NotOK

7.	Click Save, and then click Close.

8.	From the File menu, select Save to save the module.

9.	From the File menu, select Compile to compile the module. After the module compiles, click OK.


Front-End Sample

This sample is a simple front-end for a hypothetical client-management system. It demonstrates user-defined macros and parameter passing to windows.

Background

Passing arrays of parameters to and from windows can be performed easily with a reusable block of code programmed as a user-defined macro. This sample presents a dialog that prompts for client attributes. When you exit the dialog, the parameter array being returned to the caller is displayed.

Components

File	Description
FRONTEND.VEX	Export file of the SampleFrontEnd window.
See Also:

To run the sample


MSM-Workstation Samples - Front-End Sample - To run the sample
To run the sample

1.	If you are not using the Explorer database, load file FRONTEND.VEX.

2.	Use the System Browser to open window SampleFrontEnd.

3.	Click the Quick Test toolbar button, or press the keyboard shortcut F5.  This will compile the sample if necessary, then run it in test mode.

4.	When done, click the Close button in the upper-right corner of the sample window, and when the Testing window reappears click Close.


Generic Box Drawing Sample

This sample demonstrates how to use the spin control and some of the generic box drawing capabilities.

The window contains a Generic Box control, four Spin controls, and a Button control.  The objective is to create a pie chart in the Generic Box control that represents the values of the spin controls.

Background

The Generic Box control is used to display either a bitmap file or a drawing created at runtime.  To update the drawing or graphic, the developer can use the %%MergeCtl() macro.

This sample is intended to provide insight into the commands required to create a drawing at runtime.

Components

File	Description
GENPIE.VEX	Export file of the SampleGenericPie window.
See Also:

To run the sample


MSM-Workstation Samples - Generic Box Drawing Sample - To run the sample
To run the sample

1.	If you are not using the Explorer database, load file GENPIE.VEX.

2.	Use the System Browser to open window SampleGenericPie.

3.	Click the Quick Test toolbar button, or press the keyboard shortcut F5.  This will compile the sample if necessary, then run it in test mode.

4.	When done, click the Close button in the upper-right corner of the sample window, and when the Testing window reappears click Close.


Letter Slide Sample

This advanced sample combines many features.  It consists of a single window which implements the "letter slide" game.  A 5 x 5 array contains 24 shuffled letters, and the letters are to be returned to alphabetical order.  The number of shuffles and speed of shuffling can be controlled by startup parameters.

Background

This sample is an entertaining game that also illustrates the following:

•	Placing complex logic in the Common Code area behind an application window.

•	Passing command line arguments to executables (build the application module described below).

•	Using a timer (which controls shuffling speed).

•	Using button titles and visibility to simulate button movement.

•	Using simple macros.

Components

File	Description
LSLIDE.VEX	Export file with the SampleLetterSlide window.
See Also:

To run the sample

To create an executable (.EXE) using the Explorer database

To create an executable using a non-Explorer database

To run the .EXE


MSM-Workstation Samples - Letter Slide Sample - To run the sample
To run the sample

1.	If you are not using the Explorer database, load file LSLIDE.VEX.

2.	Use the System Browser to open window SampleLetterSlide.

3.	Click the Quick Test toolbar button, or press the keyboard shortcut F5.  This will compile the sample if necessary, then run it in test mode.

4.	When done, click the Close button in the upper-right corner of the sample window, and when the Testing window reappears click Close.


MSM-Workstation Samples - Letter Slide Sample - To create an executable (.EXE) using the Explorer database
To create an executable (.EXE) using the Explorer database

If you wish to build the executable, follow this procedure:

1.	From the File menu, select Open. From the Type list, select Application. From the Name list, select LETTERSLIDE. Click Open.

2.	From the File menu, select Make .EXE to create an executable file. Click the Make .EXE button.


MSM-Workstation Samples - Letter Slide Sample - To create an executable using a non-Explorer database
To create an executable using a non-Explorer database

If you are not using the Explorer database, you must create a module before the executable is built:

1.	From the File menu, select New to create a new application module. From the Type list, select Application. In the Name box, enter LETTERSLIDE.

2.	From the Element menu, select Definition. Attach window SampleLetterSlide to the module.

3.	From the Element menu, select Actions. From the Event list, select Enter.

4.	In the Action box, enter the following:

; Run the game, pass it any command-line arguments.

; Arguments recognized are:

;	shuffle	# of times to shuffle (default 20)

;	delay	seconds to wait between shuffling steps (default .1)

N Args

D  ; Put labelled parameters into Args().

. N n,p,v

. F n=1:1:$L(%%IOVar,",") S p=$P(%%IOVar,",",n),v=$P(p,"=")
 	S:v'=""  Args(v)=$P(p,"=",2,99)

%%DoWin(LetterSlide,.Args)

5.	Click Save, and then click Close.

6.	From the File menu, select Make .EXE to create an executable file. Click the Make .EXE button.


MSM-Workstation Samples - Letter Slide Sample - To run the .EXE
To run the .EXE

To run the .EXE, double-click LETTERSL.EXE.

To run the .EXE and supply command-line parameters, start the command-mode Run entry (select Start/Run from Windows 95 or Windows NT 4.0) or create a shortcut with parameters on the command line.

The command line can include optional parameters that define the number of shuffles and the delay between each move.  For example, to shuffle 10 times and pause .5 seconds between each shuffle, use the following command line:

<path>\LETTERSLIDE.EXE delay=.5,shuffle=10


List Selection Sample

This sample illustrates several important macros that can be used with any control that displays choices to the user (such as lists or radio buttons).

In this sample, items from one list are copied to another list and, are optionally removed from the first list.

Background

The manipulation of lists of choices is quite complex. Every list entry may have three different parts:

•	A string which determines order.

•	A string which is displayed.

•	A string which is an internal identifier, but is neither displayed nor determines order.

In addition, these concepts must be distinguished:

•	Choices available in the list.

•	Selections made by the user from available choices.

Macros are provided to deal with these complications. This sample illustrates the following macros:

%%GetSel

%%ResetSel

%%GetChoice

%%SetChoice

%%ResetChoice

Components

File	Description
LISTSEL.VEX	Export file of the SampleListSelection window.
See Also:

To run the sample


MSM-Workstation Samples - List Selection Sample - To run the sample
To run the sample

1.	If you are not using the Explorer database, load file LISTSEL.VEX.

2.	Use the System Browser to open window SampleListSelection.

3.	Click the Quick Test toolbar button, or press the keyboard shortcut F5.  This will compile the sample if necessary, then run it in test mode.

4.	When done, click the Close button in the upper-right corner of the sample window, and when the Testing window reappears click Close.


MDI Sample

This sample demonstrates the use of MDI parent and child windows.

Background

The sample displays an MDI parent window with a menu bar which has a choice that is clicked to create an MDI child window.

The MDI child window also has a menu bar defined.  The child's menu bar appears on the parent when the child has focus.  There are menu choices to create more MDI children, and to arrange or select the other MDI child windows.

The MDI child windows each have one large button that displays the number of times the button has been pressed. This is done using a variable that is private to that window and is defined with a '#%Declare' macro in the Common Code. Even though all the MDI child windows use the same variable name each is provided with a private copy, so the counts are correctly maintained.

On the MDI child window the menu bar demonstrates how to extend the 'Window' menu with the list of MDI children, and also how to arrange and tile the MDI child windows.

The 'New' menu item shows how to open multiple MDI child windows by indexing them.  This lets %%OpenWin(SampleMDIchild[index]) open the SampleMDIchild window with an index of 'index'.

The 'POS' parameter is passed into the %%OpenWin so that the child windows do not stack on top of each other, but are all initially cascaded.

Components

File	Description
MDI.VEX	Export file of the SampleMDIParent and SampleMDIChild windows.
See Also:

To run the sample


MSM-Workstation Samples - MDI Sample - To run the sample
To run the sample

1.	If you are not using the Explorer database, load file MDI.VEX.

2.	Use the System Browser to open window SampleMDIChild.

3.	From the File menu click Compile to compile SampleMDIChild.

4.	Use the System Browser to open window SampleMDIParent.

5.	Click the Quick Test toolbar button, or press the keyboard shortcut F5.  This will compile the sample if necessary, then run it in test mode.

6.	When done, click the Close button in the upper-right corner of the sample window, and when the Testing window reappears click Close.


Message Box Sample

This sample demonstrates how to use the standard Windows pop-up message box.

Background

Entry points in the system service routine ^%msgbox provide various standard message boxes for displaying errors, warnings, and queries.

Components

File	Description
MSGBOX.VEX	Export file of the SampleMessageBox window.
See Also:

To run the sample


MSM-Workstation Samples - Message Box Sample - To run the sample
To run the sample

1.	If you are not using the Explorer database, load file MSGBOX.VEX.

2.	Use the System Browser to open window SampleMessageBox.

3.	Click the Quick Test toolbar button, or press the keyboard shortcut F5.  This will compile the sample if necessary, then run it in test mode.

4.	When done, click the Close button in the upper-right corner of the sample window, and when the Testing window reappears click Close.


MSM-Activate Banking Sample

This sample demonstrates how to use Workstation as an Automation Controller and as an Automation Server, in conjunction with MSM-Activate. For additional information on setting up connections, refer to "Workstation as an Automation Controller" and "Workstation as an Automation Server" in the MSM-Workstation Technical Reference.

Background

This sample demonstrates three methods of controlling the server. M.Xecute is used to retrieve the Server UCI and Volume Group which display in the message after a successful connection is made. M.Do is used to call entry points as extrinsic functions and return values and to run the entry point Dep^SAMbank without returning any value.

If you are using the sample with a remote MSM-Activate server, the global ^SAMacct (which holds the sample database) is a regular M global stored on disk.

If you are using the sample with a Workstaion-built Automation Server, the global ^SAMacct is stored in a memory database.  Because a memory database is not persistent, data is not retained after the process terminates.

Components

File	Description
BANK.VEX	Export file of the four sample windows: SampleAcct, SampleAcctBal, SampleAcctDep, and SampleAcctWith.
BANK.RTN	Routine save of the SAMbank server routine.
BANK.MCO	.MCO template.
See Also:

To set up the server

To run the sample client

To test the Automation Server

To create an Automation Server using the Explorer database

To create an automation server using a non-Explorer database

Example .MCO file


To set up the server

1.	If you are using a remote MSM server running MSM-Activate, restore BANK.RTN to the server as the routine SAMbank by using %RR in the UCI that you will connect to.

2.	Run SetGlb^SAMbank to create a global called ^SAMacct in the same UCI.

3.	Modify your .MCO file so that server specifications are provided to allow accessing the server. This will include setting TYPE=TCPIP.

4.	If you are using an Automation Server, modify your .MCO file so that the path to the executable appears in the SERVER= line.


To run the sample client

1.	If you are not using the Explorer database, load file BANK.VEX.

2.	Use the System Browser to open window SampleAcct.

3.	Click the Quick Test toolbar button, or press the keyboard shortcut F5.  This will compile the sample if necessary, then run it in test mode.

4.	To connect to the server, first select Connect and then specify your .MCO file.

5.	Enter an account number between 1000 and 1010 and then select OK. You now can check the account balance or withdraw a deposit.

6.	When done, click the Close button in the upper-right corner of the sample window, and when the Testing window reappears click Close.


To test the Automation Server

The BANKSERV.EXE server built using MSM-Workstation provides the following entry points:

Entry point	Description
Acctlst	Returns a list of account numbers (separated by "^") that are present in the database.
Verify(accno)	Verifies that account number accno exists and gets the account name if it does. Returns the name of the account holder if it exists, or zero otherwise.
Dep(accno,amt)	Deposits amount amt into account number accno. Does not return a value.
Bal(accno)	Returns the balance of account number accno.
Withd(accno,amt)	Withdraws amount amt from account number accno. Returns 0 if it works, and returns 1 if there are insufficient funds to support this withdrawal.
Example

To write the account number, name, and balance of the first account in the database, run the following code from MSM-Workstation:

S M=$ZGetObject("BANK.MCO")	; Point to real location of .MCO file

D M.Login

S Account=$P(M.Do("AcctLst^SAMbank"),"^")

W "Account: ",Account,!

W "Name: ",M.Do("Verify^SAMbank",Account),!

W "Balance: ",M.Do("Bal^SAMbank",Account),!


To create an Automation Server using the Explorer database

To build BANKSERV.EXE when using the Explorer database, use the following procedure.

1.	Use the System Browser to open application BANKSERV.

2.	From the File menu, select Make .EXE to create an executable file. Select Options, then from the Operating Modes options, click Interactive to clear the checkbox. This action sets Automation Server to the selected state.  Click OK, then click the Make .EXE button.

3.	Modify your .MCO file so that the path to the executable appears in the SERVER= line.


To create an automation server using a non-Explorer database

If you are not using the Explorer database, you must load the sample routine from a host file and then construct and compile an application module.

1.	Restore routines in file BANK.RTN, creating routine SAMbank.

2.	From the File menu, select New to create a new application module. From the Type list, select Application. In the Name box, enter BANKSERV.

3.	From the Element menu, select Definition.  Attach routine SAMbank. Click OK.

4.	From the Element menu, select Actions, then select the Enter event and copy in the following:    Do locbld^SAMbank.

5.	From the File menu, select Save to save the module.

6.	In the Application BANKSERV window, select <Components>. From the File menu, select Compile. After the module compiles, click OK.

7.	From the File menu, select Make .EXE to create an executable file. Select the Options button, and in the Options dialog box, select Automation Server and clear (deselect) the Interactive checkbox.


Example .MCO file

[M.Command]

VERSION=2

TYPE=LOCALOLE

SERVER="C:\MSMWS\BANKSERV.EXE"


Printer Sample

This sample demonstrates how to access Windows printer devices.

Background

Access to Windows printer devices, which may be printers, faxes, host files, and other devices, is via a printer device (devices 3-10) and printer mnemonic commands.

The window displays a document control for input, and a single print button.  Pressing the button prints what was entered in the document.  The use of several printer mnemonics is illustrated, including  /CHOOSEPRINTER and  /CHOOSEFONT.

Components

File	Description
PRINTER.VEX	Export file of the SamplePrinter window.
See Also:

To run the sample


MSM-Workstation Samples - Printer Sample - To run the sample
To run the sample

1.	If you are not using the Explorer database, load file PRINTER.VEX.

2.	Use the System Browser to open window SamplePrinter.

3.	Click the Quick Test toolbar button, or press the keyboard shortcut F5.  This will compile the sample if necessary, then run it in test mode.

4.	When done, click the Close button in the upper-right corner of the sample window, and when the Testing window reappears click Close.


Socket Sample

This sample demonstrates how to use TCP/IP Sockets. It demonstrates both the client and server sides of this connection.

Background

Sockets are used to connect across a network, often between unlike applications.  In this example, we use two executables built with MSM-Workstation.  The Server is listening on port 1234 (an arbitrary port number 1234 is used; if that port is already designated for another purpose on your system, the sample will not work unless the sample source is changed). The Server waits for a connection to this port from the Client. The $ZA, $ZB, $ZC values provide information about the success or failure of the connect request.

Once connected, the client and server can both send and receive. To simplify this sample, the Client prompts the user for a message and then sends the message to the Server. The Server displays the received message and then waits to read another message or to be shut down.  Both the Client and Server display their current $ZA, $ZB, and $ZC values.

Two executables are used.  The Client is the "controller" and uses window SampleSocketC; the Server is the "listener" and uses window SampleSocketL.

Components

File	Description
SOCKET.VEX	Export file of the Socket windows.
See Also:

To run the sample

To create executables (.EXEs) using the Explorer database

To create the server executable using a non-Explorer database

To create the client executable using a non-Explorer database


MSM-Workstation Samples - Socket Sample - To run the sample
To run the sample

This sample is intended to be run as two separate executables on a single machine. If you are not using the Explorer database, refer to the instructions below on building the executables.

1.	Double-click SOCKETL.EXE to start the Server. The Server now waits for a socket connection and will not respond to any other events.

2.	Double-click SOCKETC.EXE to start the Client. You should do this on the same machine, unless you have modified the sample's logic.

3.	Click the Connect button.

4.	In the Message box, enter the text to be sent and then click Send. The message appears on the Server, which responds by sending a message to appear on the Client's status bar. To see this message, click away from the Send button, back onto the Message box.

5.	The Server is shut down when the Client is closed.


To create executables (.EXEs) using the Explorer database

Executables SOCKETL.EXE and SOCKETC.EXE are supplied in the samples subdirectory and can be used directly.  To rebuild the executables, use the following procedure:

1.	Use the System Browser to open application SOCKETL.

2.	From the File menu, select Make .EXE to create an executable file. Click the Make .EXE button.

3.	From the File menu, select Open. In the Type list, select Application. In the Name list, select SOCKETC. Click Open.

4.	From the File menu, select Make .EXE to create an executable file. Click the Make .EXE button.


To create the server executable using a non-Explorer database

1.	If you haven't done so, load file SOCKET.VEX

2.	Create the listening module:  From the File menu, select New to create a new application module.  In the Type list, select Application and then in the Name box, enter SOCKETL.

3.	From the Element menu, select Definition. Attach window SampleSocketL to the module. Click OK.

4.	From the Element menu, select Actions. From the Event list, select Enter.

5.	In the Action box, enter the following:

%%DoWin(SampleSocketL)

6.	Click Save, and then click Close.

7.	From the File menu, select Make .EXE to create an executable file.


To create the client executable using a non-Explorer database

1.	If you haven't done so, load file SOCKET.VEX

2.	Create the controlling module: From the File menu, select New to create a new application module. From the Type list, select Application. In the Name box, enter SOCKETC.

3.	From the Element menu, select Definition.  Attach windows SampleSocketC and SampleSocketIp to the module. Click OK.

4.	From the Element menu, select Actions. From the Event list, select Enter.

5.	In the Action box enter the following:

%%DoWin(SampleSocketC)

6.	Click Save, and then click Close.

7.	From the File menu, select Make .EXE to create an executable file.


Tab Sample

This sample introduces the TabbedGroup control which acts as a container control for other gadgets.

It displays two tab pages with a set of radio buttons on the first page to select the type of drink, and check boxes on the second page to select additions to the drink. There are buttons that demonstrate switching between the two tab pages programmatically. When you press OK it tells you which drink you selected.

Background

The TabbedGroup control permits efficient use of screen space. The user switches from one set of controls to another set of controls by clicking on one of the tabs. The page shown can also be switched programmatically using the %%SetFocus macro. If you set focus onto a control on another page of the TabbedGroup, the page switches automatically. Also if you %%SetFocus(TabCtrl[2]) then it switches to page 2 on the TabbedGroup control named TabCtrl.

To add a control to a TabbedGroup control you must create it on top of the desired page. If you just move an existing control over the tab control this does not make the association.  To move an existing control onto a tab page, cut and paste it on there. You can see if a control is contained by another control by looking at its 'Container' property on the Property Bar.

Components

File	Description
TABSTRIP.VEX	Export file of the window.
TABSTRIP.VXS	Secondary file assiciated with window export
See Also:

To run the sample


MSM-Workstation Samples - Tab Sample - To run the sample
To run the sample

1.	If you are not using the Explorer database, load file TABSTRIP.VEX. The secondary file TABSTRIP.VXS must be present too.

2.	Use the System Browser to open window SampleTabStrip.

3.	Click the Quick Test toolbar button, or press the keyboard shortcut F5.  This will compile the sample if necessary, then run it in test mode.

4.	When done, click the Close button in the upper-right corner of the sample window, and when the Testing window reappears click Close.


Tic Tac Toe Sample

This advanced sample combines many features described in other simpler samples.

The sample consists of two windows.  The main window contains a single Button control which is cloned at run-time according to the board dimension required. A menu choice from the main window calls a second window to obtain the user's choice of board dimension, which is returned back to the main window.

The computer opponent uses the $Random function to determine where to move. If desired, the developer can create a more advanced algorithm.

Background

Creating advanced applications requires an understanding of several concepts, including: creating controls at runtime, sharing data between screens, and window modality. In addition, most applications require more than a cursory knowledge of basic features. For these reasons, this advanced implementation of a simple game is a useful demonstration.

This sample illustrates the following features:

•	Passing arguments to and retrieving results from a child window (see label Redim in the Common Code for SampleTicTacToe).

•	Passing command line arguments to executables (build the application module described below).

•	Placing bitmaps on button faces (see label Reset).

•	Using the common dialog for file lookup (see label ChangeP).

•	Simple macros.

Components

File	Description
TICTACTO.VEX	Export file with the SampleTicTacToe and SampleTicTacToeRedim windows.
X.ICO	Default icon for X.
O.ICO	Default icon for O.
BLANK.ICO	Default icon for an empty button.
See Also:

To run the sample

To create an executable (.EXE) using the Explorer database

To create an executable using a non-Explorer database

To run the .EXE


MSM-Workstation Samples - Tic Tac Toe Sample - To run the sample
To run the sample

1.	If you are not using the Explorer database, load file TICTACTO.VEX.

2.	Use the System Browser to open window SampleTicTacToe.

3.	Click the Quick Test toolbar button, or press the keyboard shortcut F5.  This will compile the sample if necessary, then run it in test mode.

4.	When done, click the Close button in the upper-right corner of the sample window, and when the Testing window reappears click Close.


MSM-Workstation Samples - Tic Tac Toe Sample - To create an executable (.EXE) using the Explorer database
To create an executable (.EXE) using the Explorer database

Use the following procedure if you wish to build the executable:

1.	From the File menu, select Open. From the Type list, select Application. From the Name list, select TICTACTOE. Click Open.

2.	From the File menu, select Make .EXE to create an executable file. Click the Make .EXE button.


MSM-Workstation Samples - Tic Tac Toe Sample - To create an executable using a non-Explorer database
To create an executable using a non-Explorer database

If you are not using the Explorer database, a module must be created before the executable is built:

1.	From the File menu, select New to create a new application module. In the Type list, select Application. In the Name box, enter TICTACTOE.

2.	From the Element menu, select Definition.  Attach windows SampleTicTacToe and SampleTicTacToeRedim to the module.  Click OK.

3.	From the Element menu, select Actions.  From the Event list, select Enter.

4.	In the Action box, enter the following:

; Create local array Args with a subscript of 'Dim'

; Set Args("Dim") equal to command line arguments

S Args("Dim")=%%IOVar

; Pass array by reference into the startup window.

%%DoWin(SampleTicTacToe,.Args)

5.	Click Save, and then click Close.

6.	From the File menu, select Save to save the module.

7.	In the Application TICTACTOE window, select <Components> and Win LetterSlide.  From the File menu, select Compile. After the module and window compile, click OK.

8.	From the File menu, select Make .EXE to create an executable file.


MSM-Workstation Samples - Tic Tac Toe Sample - To run the .EXE
To run the .EXE

To run the .EXE, double-click the created .EXE file.

To run the .EXE and supply command-line parameters, start the command-mode Run entry (select Start/Run from Windows 95 or Windows NT 4.0) or create a shortcut with parameters on the command line.

The command line can include an optional parameter that defines the dimensions of the startup TicTacToe board.  The default dimension is 3 x 3.  The following command line will create a 6 x 6 board at startup:

TICTACTO.EXE 6


Two Timers Sample

This sample demonstrates how to use timers.

The window contains two timers which initially are inactive. You can start and stop them independently by using buttons. The interval of the first timer is 0.1 seconds; the interval of the second timer is one second.

Background

Event-driven programming requires events to occur before actions can be performed.  Although most events occur as a result of user actions, sometimes an action needs to be performed independently of the user. Use the Timer control in these situations.

The Timer control's Interval property is set to a number greater than zero. If the timer is active, then every time the interval (represented as seconds) elapses, the timer event is called. When you convert real-time applications to event-driven interfaces, use the Timer control's Interval and Active properties and its timer event.

The definition interface for the Timer control allows a minimum interval of one second.  If a smaller interval is desired, (as in this example), set the Interval property by using the %%Set() macro.

Timers are implicitly restarted after the timer event has finished executing. To avoid restarting the timer automatically, set the Active property to 0 within the event.

Components

File	Description
TWOTIMER.VEX	Export file of the SampleTwoTimers window.
See Also:

To run the sample


MSM-Workstation Samples - Two Timers Sample - To run the sample
To run the sample

1.	If you are not using the Explorer database, load file TWOTIMER.VEX.

2.	Use the System Browser to open window SampleTwoTimers.

3.	Click the Quick Test toolbar button, or press the keyboard shortcut F5.  This will compile the sample if necessary, then run it in test mode.

4.	When done, click the Close button in the upper-right corner of the sample window, and when the Testing window reappears click Close.