pattersongray.com
PGA






  Compatibility
  Connectivity
  Examples






M3-Lite incorporates the M programming language as specified in the 1995 ANSI Standard (ANSI/MDC X11.1) and should run most standard M software that meets this or previous M ANSI standards.

Although the language has slowly evolved to provide more portability between vendors, there are a few items that still cause problems. In designing M3-Lite we have tried to minimize those problems by providing more than one syntax for device and routine handling. Unfortunately being all things to all people is an daunting task, so we will save some for later.

The biggest issues usually revolve around device control (opening and closing sockets, files, comm ports, etc) and loading, editing and saving routines. The help text that comes with M3-Lite provides syntax and examples. The routine load facility provided with M3-Lite will load routines from a variety of vendor formats.

 

It is no secret that programmers biggest challenges today are interfacing. To answer the interfacing needs of the modern workplace, M3-Lite incorporates a strong TCP/IP backbone and provides three types of services, client, listener and servers for both TCP and UDP.

To leverage this TCP connectivity M3-Lite sports its own web and SQL server. Access to the database and programs is simple and output to the web is accomplished through the standard output commands. (Currently M3-Lite supports ODBC through third party drivers but will incorporate its own in the future.)

Windows devices such as COMM ports, printers, files and memory mapped I/O are all accessible through M3-Lite and in most cases are shared with other Windows applications.

Remote user terminal access is provided by M3-Lites telnet daemon. Local terminal access is by either telnet or M3-Lite's terminal window.

 


DYNAMIC WEB PROGRAMMING WITH M3-LITE

One of the most important things a web server can do is use input from the client-side browser to somehow dynamically alter a web page. If a browser user clicks a button on a web page that reads "DISPLAY GLOBAL INFORMATION", we need the web server to receive this request and return the global information.

The first part of this process is passing information from the browser to the server in the form of variables. To do this, we use the FORM feature of HTML to capture the input of the browser user and pass it as a variable. We'll use the "post" method of the Form, while the Form's action will be the LINE TAG and ROUTINE NAME of the M routine we want to process the request. The HTML code for setting up a form that will be processed by the M routine "SAMPLE" at entry point "input" would look like this:

<!-- case is not important here -->
<form method="post" action="input^SAMPLE">

Inside the form we set up our input box and a submit button. The user will type text into the input box, which will store that text as the value of a variable named after the name of the input box. Finally, the user will click the submit button that will pass this variable to the server.

<input type=text name="text1" value="">
<input type=button name="submit" value="Submit">

See Our Sample Form

This is all we need on the browser side. Now we have to write the M routine that will receive this text, process it, and return something to the browser. Early versions of M3 will require that your M routine that is to be accessed by the browser be located in the same Namespace (UCI) as the TKWEBC routine ( M3 comes with TKWEBC in UCI-1 ).

A HELPFUL TIP: create a line in your routine that displays all variables passed from the browser. This will help you identify variables and access them appropriately. The argumentless WRITE command dumps all of the currently defined variables, the PRE HTML tags tell the browser to honor the carriage return/line feed sequence to force a new line between each variable.

VAR    ; TKWEB ; display all variables
       W "<pre>" W W "</pre>" Q

The routine that the browser calls must have access to M3, otherwise the browser will display an error message "Entry point not enabled for TkWeb." To enable an entry point, the line tag must be in all CAPS and the word "TKWEB" must be typed as a comment after the line tag.

ENTRY  ; TKWEB
       ; Typing "TKWEB" above allows
       ; access for the browser. The
       ; entry point line tag must
       ; be in CAPS.

When the browser accesses the routine in M3, it will expect a reply. Without a reply, the browser will display a blank page. To reply to the browser, use WRITE statements in your routine. All WRITE statements will output to the browser.

See Our M Routine

If you have any questions, send them to us via our Contact us page.


TIPS FOR PROGRAMMING HTML IN M ROUTINES

While you are debugging your web applications you may view the resultant HTML source code that was sent to your browser by selecting the VIEW SOURCE option of your browser. In order to make your source code more legible, use the line feed (!) operator where you'd like to break up the code. Without this, the code would all read in one long line of text.

W "<html>"
W "<body bgcolor=white>"
W "Hello Everybody","<br>"
W "</body>","</html>"

The coding above would produce this source code:

<html><body bgcolor=white>Hello Everybody<br></body></html>

Now, using the line feed (!) operator:

W "<html>",!
W "<body bgcolor=white>",!
W "Hello Everybody",!,"<br>",!
W "</body>",!,"</html>"

Produces much more legible source code:

<html>
<body bgcolor=white>
Hello Everybody
<br>
</body>
</html>


2000 Patterson, Gray & Associates. All rights reserved.