Computer Corporation of America
|
Feedback
Search CCA:
   
USA CCA
CCA Products
CCA Customer Support
CCA Resources
CCA - Company
CCAPRINT: A Newsletter for Model 204® and System 1032® Users
December 18, 2008
     
Model 204: $MOD – A Versatile $Function Printer-friendly version
System 1032: Providing Input to Applications: Part 2 Printer-friendly version

 

Model 204
USE OF AND ACCESS TO PRODUCTS AND FEATURES ARE IN ACCORDANCE WITH THE TERMS AND CONDITIONS OF THE USER’S SOFTWARE LICENSE. THE PRESENTATION OF MATERIAL HEREIN DOES NOT, IN ANY MANNER, MODIFY SUCH TERMS AND CONDITIONS.

$MOD – A Versatile $Function
By James Damon



Almost two hundred CCA-written $functions are linked into the Model 204 nucleus. These functions are written in IBM Assembly Language and perform highly specialized operations that require less CPU and fewer instructions than would be required were they written in User Language. And while many could be written, with no small effort, in User Language, many cannot.

You are probably familiar with and use in all sorts of situations these $functions:

Other functions are more obscure and even more specialized, but extremely useful in certain situations:

And still other $functions are more flexible and useful than you might initially think, for example, the $MOD function.

Revisiting the $MOD function
You might sometimes overlook the $MOD function because its name is somewhat arcane and its purpose is not immediately obvious from its name. It can, however, be very handy to have in several situations. MOD is an abbreviation for modulo and is simply a function that provides the remainder from the division of two numbers.

"Given two numbers, a (the dividend) and n (the divisor), a modulo n (abbreviated as a mod n) is the remainder on division of a by n." 1

In Model 204 User Language, the function syntax is:

%REMAINDER = $MOD(%A,%N) 
or, more simply
%X = $MOD(%A,%N)

Using the $MOD Function
Perhaps the following examples will spark a fresh possibility in your mind as to how and where you can use the $MOD function. Probably the most common uses of $MOD are to:

BEGIN
PRINT ‘REMAINDER = ‘ WITH $MOD(337,50)
END
REMAINDER = 37
BEGIN
PRINT ‘68745 IS ‘ WITH . . .
IF NOT $MOD(68745,2) THEN
PRINT ‘EVEN’
ELSE
PRINT ‘ODD’
END
68745 IS ODD
BEGIN
FOR %I FROM 1 TO 500000
%DATE = $DATE(1)
%TIME = $TIME(2)
%PI = $PI
STORE RECORD
FIELD1 = %DATE
FIELD2 = %TIME
FIELD3 = %PI
END STORE
IF $MOD(%I,100) = 0 THEN /? COMMIT AFTER EVERY 100 ?/
COMMIT /? STORE RECORDS ?/
END IF
END FOR
END

In Summary
You can probably think of other uses of the $MOD function. In any case, it does have a number of applications including the three I have shown.

All of the CCA-written $functions are documented in the Model 204 User Language Guide with examples. Take a look! There just may be a $function hiding in there that provides exactly what you’re looking for without you having to write a lot of User Language code. And if you don’t find what you need, you can write your own and link it into the Model 204 nucleus! More about that in a future issue of CCAPrint.

1 Modulo operation. (2008, November 19). In Wikipedia, The Free Encyclopedia. Retrieved 22:15, December 3, 2008, from http://en.wikipedia.org/w/index.php?title=Modulo_operation&oldid=252876557

 

System 1032
USE OF AND ACCESS TO PRODUCTS AND FEATURES ARE IN ACCORDANCE WITH THE TERMS AND CONDITIONS OF THE USER’S SOFTWARE LICENSE. THE PRESENTATION OF MATERIAL HEREIN DOES NOT, IN ANY MANNER, MODIFY SUCH TERMS AND CONDITIONS.

Providing Input to Applications: Part 2
By Tym Stegner

Tym

A question from a customer, who had acquired responsibility for application systems, prompted me to write this article about how to provide input to applications. Part 1, last month’s article dealt with the basic concepts of data prompting via the System 1032 ACCEPT command and how to incorporate its use with a DCL COM file.

However, the customer wanted to learn about the mechanics of allowing a DMC or COM file the ability to pass parameters to an application. Running a DMC file from a command file or a command variable is a common occurrence in VMS/System 1032. However, there are application details I need to know, because operating with parameters differs slightly compared to working with prompts. Here are my follow up questions:

I received the following reply.

In the example I am learning from, the DMC currently accepts prompts. I am running the DMC via the USE command via the S1032 prompt. I am open to learning to use parameters or the CALL command. All of this is new [to me] and I am trying to figure this out from our applications.

Shifting to a COM File with an INQUIRE Command
Both Options #3 and #4 that follow employ a COM file and the VMS INQUIRE command. To illustrate the progression of our thinking the examples will continue using the code for the TTT.DMC from Options #1 and #2 that were introduced in Part 1.

When running from a COM file, you must pay close attention to where your input stream originates. Our objective is to remove the terminal processing from the DMC file and perform that work within the COM file, thereby removing from DCL the command input redefinition complexity.

The equivalent to a PL1032 ACCEPT command is the DCL INQUIRE command. After a bit of rewrite, our DMC and command files are as follows:


!TT2.DMC
Var MyAsk Text Varying
!Accept MyAsk Prompt "Enter text: "
Print MyAsk


$! ASK.COM - Drive an S1032 DMC file
$!
$ Inquire ASK "Enter text"
$!
$ S1032
USE TT2
EXIT
$!
$ Exit

$ @ASK
Enter text: waggle
Computer Corporation of America System 1032 Version V9.81-1
Copyright 2002, Computer Corporation of America
MYASK
--------------------
?
$


Now, running the COM file via "@ASK" handles the prompting and runnng the DMC file via the S1032 USE command outputs the result. At least, it will output a result once we have a way to get the variable’s value from the DCL context into the System 1032 context of the DMC.

Option #3. Adding a Command Line Variable
For a small number of values to pass, we can use the earlier technique (shown in Part1) of commands on the S1032 command line. In the following example, I define the variable on the command line, putting the value of the DCL symbol ASK into the variable’s INITIALLY option via DCL symbol substitution:

!TT2.DMC
!Var MyAsk Text Varying !Comment out variable definition
!Accept MyAsk Prompt "Enter text: "
Print MyAsk $! ASK.COM - Drive an S1032 DMC file
$!
$ Inquire ASK "Enter text" !Prompt for variable in DCL
$!
$ S1032 Var MyAsk Text Varying Init "''ASK'"
USE TT2
EXIT
$!
$ Exit

In this example, the original MyAsk variable definition is moved from the DMC file to the DCL command file. On the System 1032 command line, I specify a VARIABLE command to declare the value repository for the System 1032 context, and set its initial value using the DCL variable.

At run time, the prompt comes from DCL, not System1032:

$ @ASK
Enter text: wubble
Computer Corporation of America System 1032 Version V9.81-1
Copyright 2002, Computer Corporation of America
MYASK
--------------------
WUBBLE
$

Repeating the example after adding a SET VERIFY command, we can observe the symbol value substitution on the System 1032 command line.

$ Set Verify
$ @ASK
$! ASK.COM - Drive an S1032 DMC file
$!
$ Inquire ASK "Enter text"
Enter text: wyggle
wyggle
$!
$ S1032 Var MyAsk Text Varying Init "WYGGLE"
Computer Corporation of America System 1032 Version V9.81-1
Copyright 2002, Computer Corporation of America
USE TT2
MYASK
--------------------
WYGGLE
EXIT
$!
$ Exit
$

Option #4. Substituting a GET_SYMBOL procedure
When you have to pass multiple variables, you may encounter problems because the maximum command line length in DCL is only about 250 characters. When we have more variables than we have command line length, we can use a tools procedure to directly translate the DCL symbols from within System 1032:


!TT3.DMC
Open Library S1032_UTL In S1032_TOOLS Readonly
!Library contains procedure
Var myAsk Text Varying !Text output parameter
Var IX Integer !Integer output parameter
Call GET_SYMBOL( MyAsk, IX, "ASK" ) !Function call
Print MyAsk$! ASK.COM - Drive an S1032 DMC file
$!
$ Inquire ASK "Enter text"
$!
$ S1032
USE TT3 !Run DMC file
EXIT !exit S1032
$!
$ Exit!

In the DCL command file the VARIABLE command on the command line is replaced by the GET_SYMBOL tools procedure call, now within the System 1032 DMC file.


$ SET VERIFY
$ @ASK
$! ASK.COM - Drive an S1032 DMC file
$!
$ Inquire ASK "Enter text"
Enter text: weeble
$!
$ S1032
Computer Corporation of America System 1032 Version V9.81-1
Copyright 2002, Computer Corporation of America
USE TT3
MYASK
--------------------
WEEBLE
EXIT
$!
$ Exit
$

While a System 1032 session is processing, all the symbols defined in the COM file context, or even the user’s process context, are available to the System 1032 environment. The GET_SYMBOL procedure is hooked to a VMS system service that allows for in-program translation of DCL symbols. In our case the TT3.DMC file must be pre-loaded with the name of the DCL symbol to be translated. In the prior examples, only the value of the DCL symbol is moved from DCL into System 1032, and the System 1032 variable is pre-loaded into the DMC file.

Refining Option #4: Command Line Parameters
We can improve on the previous example a bit. Instead of prompting for the value we can reasonably expect the user to pass it in on the command line of our external COM file, as if supplying parameters or data to a DCL command.

The following DCL file will prompt for the value required if the user does not supply it.


$! ASK.COM - Drive an S1032 DMC file
$!
$ ASK := ""
$ If P1 .Eqs. "" !Check parameter 1
$ Then !Blank, so prompt
$ Inquire ASK "Enter text"
$ Else !Not blank, so assign
$ ASK = P1
$ Endif
$!
$ S1032
USE TT3
EXIT
$!
$ Exit

The DMC file is unchanged so it is not displayed. Here we use DCL logical expressions to test the first of the default Pn parameters (up to 8 are available) to ensure a value was supplied to our command symbol. If not, the P1 value is null, so only at that time will the command file prompt for it.


$ Set Noverify
$ @ASK
Enter text: leggo
Computer Corporation of America System 1032 Version V9.81-1
Copyright 2002, Computer Corporation of America
S1032_UTL is already in use
MYASK
--------------------
LEGGO
$

In this case, a value was not supplied, so the DCL file prompts for a value. Additional code could be included to force data entry or to abort operations, if no value is specified.


$ @ASK hondo
Computer Corporation of America System 1032 Version V9.81-1
Copyright 2002, Computer Corporation of America
MYASK
--------------------
HONDO
$

In this case, a value is supplied to the command symbol, so no prompting is required of the DCL file.

In Summary
We have reviewed the most common means of passing data into a System 1032 environment to ease the use of applications. Methods include both System 1032 –centric and DCL-centric approaches. The choice depends on the required complexity of the data to be supplied to the application.

Not only do these articles described how the programmer can accomplish data prompting, they also serve to explain how these designs work, so you can review existing applications to track data flow into the application.


Copyright © 2008 Computer Corporation of America.
All right reserved. Published in the United States of America.


Contact CCA Webmaster
Copyright 2008