Proc Tips
TIME and DATE
The following commands load the current system time and date (in internal format) into the currently active input buffer:
IH%n:F;T:
IH%n:F;D:
The value n has no significance. The time or date value will be placed in the active input buffer at the location pointed to by the buffer pointer. The %n causes :F;T: or :F;D: to be part of the function and not a literal string.
Note
Do not use this feature in a Proc which calls a DataBasic program.
English Statements
Long English statements and/or headings that run over 140 characters can be continued using the stack continuation character (<<).
Another way to continue long statements is through successive use of the H command. Be sure to use a space after the first or before the second (and any subsequent) H commands so that you have a space between words.
001 PQN 002 HGET-LIST listname 003 STON 005 HSORT filename WITH whatever, etc. 006 H HEADING "heading \\ " 007 P
Executing TCL and English Commands
You can use the H command to execute English and TCL from a Proc. This is an extremely useful feature.
Validating Dates and Times
Validating a date or time using pattern checking does not prevent entries like 02/30/86 or 99:99:99 from occurring.
The example below checks for a valid date in D2/ format by converting it internally and then converting it back to D2/ to see if the end result matches the original input. This works because an invalid date converts internally to zero.
001 PQN 002 10 T "ENTER DATE (MM/DD/YY)",(11),+ 003 IBP(%1 004 MV %2 "" 005 IBH%1;D2/; 006 MV %3 "" 007 IBH%2:D2/: 008 IF %1 # %3 T B,"INVALID DATE!"\GO 10 009 ODATE IS OKAY!
How to READV in Proc
A single attribute from an item can be loaded into the active input buffer with the following command:
IBH%n:Tfilename;X;amc;amc:
This is similar to the way an English dictionary item is handled.
MCDX/MCXD
Decimal-to-hex (DTX) and hex-to-decimal (XTD) conversions are available in Proc. The following Procs demonstrate how these conversions work, by converting a number input at TCL.
XD 001 PQN 002 T "ENTER A NUMBER IN HEX",+ 003 IBP:%2 004 MV %2 %2\IBH%2:MCXD:\C Converts to decimal 005 T S3,%2\C Displays decimal number
DX 001 PQN 002 T "ENTER A DECIMAL NUMBER",+ 003 IBP:%2 004 MV %2 %2\IBH%2:MCDX:\C Converts to hex 005 T S3,%2\C Displays hex number
P Option
Any TCL command that accepts the (P) option (printer option) can be executed from within a Proc, producing the same result. For example:
HSORT MD (P)
P
Concatenation
Values can be concatenated (joined together in a series) using an asterisk (*). For example:
001 PQN 002 OENTER TWO VALUES, SEPARATED BY A SPACE+ 003 S1 004 IP 005 MV #1 %1*%2,%1*" "*%2 006 T #1 007 T #2
This Proc requests input into %1 and %2. It concatenates these values and places the result into #1. It then joins %1 and %2, with a space in between, and places the result into #2. Lines 006 and 007 display the contents of #1 and #2.
Hold File Numbers
If a hold file is generated while a Proc is executing, the hold file number is returned to the Proc as an error message number in the secondary input buffer.
Hold file numbers are returned in the form HFN
n,
where n is the hold file number. This is to distinguish them from other
error message numbers.
System Procs
Several Procs are available on the system for your use. The system Procs are included in every new account's MD via a Q-Pointer to the PROCLIB file on the SYSFILES account.
Listing Procs
To generate a list of Procs, use the LISTPROCS command at TCL.
SYSTEM Function
The SYSTEM function in Proc allows you to access various database parameters.