%DH: Decimal to hexadecimal conversion.
%DO: Decimal to octal conversion.
%HD: Hexadecimal to decimal conversion.
%HO: Hexadecimal to octal conversion.
%LCASE: Converts a string to all lower case.
%OD: Octal to decimal conversion.
%OH: Octal to hexadecimal conversion.
%UCASE: Converts a string to all upper case.
The conversion utilities can be invoked as extrinsic functions.
%DH: As input, contains input decimal number.
%DL: Specifies how many digits appear in the output, defaults to eight.
Decimal: Requests a decimal number for conversion to hexadecimal.
Digits: Requests the length of the output in digits; eight by default.
Decimal: Requests a decimal number for conversion to octal.
Digits: Requests the length of the output in digits; 12 by default.
%DO: As input, contains input decimal number.
%DL: Specifies the number of digits in the output, defaults to 12.
INT: Converts hexadecimal number entered interactively to decimal number.
FUNC(h): Invokes %HD as an extrinsic function returning the decimal equivalent of the argument.
INT: Converts hexadecimal number entered interactively to octal number.
FUNC(h): Invokes %HO as an extrinsic function returning the octal equivalent of the argument.
^%JSWRITE(glvnode,[expr1,expr2])
# Demo lv GTM>zwrite demodevtest demodevtest("Developer1","Token1","testSetup")="runtest holt maintest cpipe" demodevtest("Developer1","Token1","testSetup","65401,11987")=1 demodevtest("Developer1","Token1","testSetup","holt","t")="mtest" demodevtest("Developer1","Token1","testSetup","holt","t","SendReport",65401,12073)=1 demodevtest("Developer1","Token1","testSetup","holt","t","cpipe",65401,12025)=0 demodevtest("Developer1","Token2","testSetup")="runtest holt maintest tconv" demodevtest("Developer1","Token2","testSetup","holt","65401,21987")=1 demodevtest("Developer1","Token2","testSetup","holt","t")="mtest" demodevtest("Developer1","Token2","testSetup","holt","t","SendReport",65401,22073)=1 demodevtest("Developer1","Token2","testSetup","holt","t","tconv",65401,22025)=0 demodevtest("Developer2","Token3","testSetup")="runtest holt maintest tconv" demodevtest("Developer2","Token3","testSetup","holt","65401,21987")=1 demodevtest("Developer2","Token3","testSetup","holt","t")="mtest" demodevtest("Developer2","Token3","testSetup","holt","t","SendReport",65401,22073)=1 demodevtest("Developer2","Token3","testSetup","holt","t","tconv",65401,22025)=0 demodevtest("Developer3","Token4","testSetup")="runtest holt maintest tconv" demodevtest("Developer3","Token4","testSetup","holt","65401,31987")=1 demodevtest("Developer3","Token4","testSetup","holt","t")="mtest" demodevtest("Developer3","Token4","testSetup","holt","t","SendReport",65401,32073)=1 demodevtest("Developer3","Token4","testSetup","holt","t","tconv",65401,32025)=0 GTM>set glvn="demodevtest(""Developer2"")" GTM>do ^%JSWRITE(glvn,"*") ; JS Object Strings: All descendants of demodevtest("Developer2") {"demodevtest":{"Developer2":{"Token3":{"testSetup":"runtest holt maintest tconv"}}}} {"demodevtest":{"Developer2":{"Token3":{"testSetup":{"holt":{"65401,21987":1}}}}}} {"demodevtest":{"Developer2":{"Token3":{"testSetup":{"holt":{"t":"mtest"}}}}}} {"demodevtest":{"Developer2":{"Token3":{"testSetup":{"holt":{"t":{"SendReport":{"65401":{"22073":1}}}}}}}}} {"demodevtest":{"Developer2":{"Token3":{"testSetup":{"holt":{"t":{"tconv":{"65401":{"22025":0}}}}}}}}} GTM>do ^%JSWRITE(glvn,"[*]") ; Array: All descendants of demodevtest("Developer2") [{"demodevtest":{"Developer2":{"Token3":{"testSetup":"runtest holt maintest tconv"}}}}, {"demodevtest":{"Developer2":{"Token3":{"testSetup":{"holt":{"65401,21987":1}}}}}}, {"demodevtest":{"Developer2":{"Token3":{"testSetup":{"holt":{"t":"mtest"}}}}}}, {"demodevtest":{"Developer2":{"Token3":{"testSetup":{"holt":{"t":{"SendReport":{"65401":{"22073":1}}}}}}}}}, {"demodevtest":{"Developer2":{"Token3":{"testSetup":{"holt":{"t":{"tconv":{"65401":{"22025":0}}}}}}}}}] GTM> do ^%JSWRITE(glvn,"#") ; JS Object Strings: All descendants of demodevtest starting from demodevtest("Developer2") {"demodevtest":{"Developer2":{"Token3":{"testSetup":"runtest holt maintest tconv"}}}} {"demodevtest":{"Developer2":{"Token3":{"testSetup":{"holt":{"65401,21987":1}}}}}} {"demodevtest":{"Developer2":{"Token3":{"testSetup":{"holt":{"t":"mtest"}}}}}} {"demodevtest":{"Developer2":{"Token3":{"testSetup":{"holt":{"t":{"SendReport":{"65401":{"22073":1}}}}}}}}} {"demodevtest":{"Developer2":{"Token3":{"testSetup":{"holt":{"t":{"tconv":{"65401":{"22025":0}}}}}}}}} {"demodevtest":{"Developer3":{"Token4":{"testSetup":"runtest holt maintest tconv"}}}} {"demodevtest":{"Developer3":{"Token4":{"testSetup":{"holt":{"65401,31987":1}}}}}} {"demodevtest":{"Developer3":{"Token4":{"testSetup":{"holt":{"t":"mtest"}}}}}} {"demodevtest":{"Developer3":{"Token4":{"testSetup":{"holt":{"t":{"SendReport":{"65401":{"32073":1}}}}}}}}} {"demodevtest":{"Developer3":{"Token4":{"testSetup":{"holt":{"t":{"tconv":{"65401":{"32025":0}}}}}}}}} GTM>do ^%JSWRITE(glvn,"[#]") ; Array: All descendants of demodevtest starting from demodevtest("Developer2") [{"demodevtest":{"Developer2":{"Token3":{"testSetup":"runtest holt maintest tconv"}}}}, {"demodevtest":{"Developer2":{"Token3":{"testSetup":{"holt":{"65401,21987":1}}}}}}, {"demodevtest":{"Developer2":{"Token3":{"testSetup":{"holt":{"t":"mtest"}}}}}}, {"demodevtest":{"Developer2":{"Token3":{"testSetup":{"holt":{"t":{"SendReport":{"65401":{"22073":1}}}}}}}}}, {"demodevtest":{"Developer2":{"Token3":{"testSetup":{"holt":{"t":{"tconv":{"65401":{"22025":0}}}}}}}}}, {"demodevtest":{"Developer3":{"Token4":{"testSetup":"runtest holt maintest tconv"}}}}, {"demodevtest":{"Developer3":{"Token4":{"testSetup":{"holt":{"65401,31987":1}}}}}}, {"demodevtest":{"Developer3":{"Token4":{"testSetup":{"holt":{"t":"mtest"}}}}}}, {"demodevtest":{"Developer3":{"Token4":{"testSetup":{"holt":{"t":{"SendReport":{"65401":{"32073":1}}}}}}}}}, {"demodevtest":{"Developer3":{"Token4":{"testSetup":{"holt":{"t":{"tconv":{"65401":{"32025":0}}}}}}}}}] $ $gtm_dist/mumps -r %XCMD 'ZWRITE ^demodevtest' | $gtm_dist/mumps -r STDIN^%JSWRITE [{"^demodevtest":{"Developer1":{"Token1":{"testSetup":"runtest holt maintest cpipe"}}}}, {"^demodevtest":{"Developer1":{"Token1":{"testSetup":{"65401,11987":1}}}}}, {"^demodevtest":{"Developer1":{"Token1":{"testSetup":{"holt":{"t":"mtest"}}}}}}, {"^demodevtest":{"Developer1":{"Token1":{"testSetup":{"holt":{"t":{"SendReport":{"65401":{"12073":1}}}}}}}}}, {"^demodevtest":{"Developer1":{"Token1":{"testSetup":{"holt":{"t":{"cpipe":{"65401":{"12025":0}}}}}}}}}, {"^demodevtest":{"Developer1":{"Token2":{"testSetup":"runtest holt maintest tconv"}}}}, {"^demodevtest":{"Developer1":{"Token2":{"testSetup":{"holt":{"65401,21987":1}}}}}}, {"^demodevtest":{"Developer1":{"Token2":{"testSetup":{"holt":{"t":"mtest"}}}}}}, {"^demodevtest":{"Developer1":{"Token2":{"testSetup":{"holt":{"t":{"SendReport":{"65401":{"22073":1}}}}}}}}}, {"^demodevtest":{"Developer1":{"Token2":{"testSetup":{"holt":{"t":{"tconv":{"65401":{"22025":0}}}}}}}}}, {"^demodevtest":{"Developer2":{"Token3":{"testSetup":"runtest holt maintest tconv"}}}}, {"^demodevtest":{"Developer2":{"Token3":{"testSetup":{"holt":{"65401,21987":1}}}}}}, {"^demodevtest":{"Developer2":{"Token3":{"testSetup":{"holt":{"t":"mtest"}}}}}}, {"^demodevtest":{"Developer2":{"Token3":{"testSetup":{"holt":{"t":{"SendReport":{"65401":{"22073":1}}}}}}}}}, {"^demodevtest":{"Developer2":{"Token3":{"testSetup":{"holt":{"t":{"tconv":{"65401":{"22025":0}}}}}}}}}, {"^demodevtest":{"Developer3":{"Token4":{"testSetup":"runtest holt maintest tconv"}}}}, {"^demodevtest":{"Developer3":{"Token4":{"testSetup":{"holt":{"65401,31987":1}}}}}}, {"^demodevtest":{"Developer3":{"Token4":{"testSetup":{"holt":{"t":"mtest"}}}}}}, {"^demodevtest":{"Developer3":{"Token4":{"testSetup":{"holt":{"t":{"SendReport":{"65401":{"32073":1}}}}}}}}}, {"^demodevtest":{"Developer3":{"Token4":{"testSetup":{"holt":{"t":{"tconv":{"65401":{"32025":0}}}}}}}}}]
$ $gtm_dist/mumps -r ^RTN abc("firstname")="John" abc("lastname")="Doe" abc("firstname")="Jane" abc("lastname")="Doe" $ $gtm_dist/mumps -r ^RTN | $gtm_dist/mumps -r STDIN^%JSWRITE singlesub [{"firstname":"John","lastname":"Doe"}, {"firstname":"Jane","lastname":"Doe"}]
fis-gtm-jswrite.tar.gz is an npm package containing four ^%JSWRITE reference implementations and three examples for the ^%JSWRITE utility routine. It also includes a utility class called JSWRITE.js to help process the output of the ^%JSWRITE utility routine for use in a JavaScript runtime environment and convert JavaScript objects to SET @ arguments.
The fis-gtm-jswrite.tar.gz package is available only for supported GT.M customers from the FIS Client Portal (https://my.fisglobal.com/products/gtm). Being a supported GT.M customer entitles you to receive package patches and upgrades under the terms of your support agreement. Note that the license for the fis-gtm-jswrite.tar.gz does not permit redistribution. You may use the fis-gtm-jswrite.tar.gz package as-is or modify as appropriate to suit your needs. In both the cases, you must adequately test the reference implementations and the utility class before using them in a production environment. Please contact gtmsupport@fisglobal.com or your support channel for more information on obtaining this package.
The ^%JSWRITE reference implementations are:
Dynamic Journal File Progress Bar: GTMJSJNLCHAIN.m/gtmjsjnlchain.js
Global Buffers Dashboard: GTMJSACCESSBG.m/gtmjsaccessbg.js
Journal File Chain Report: GTMJSJNLCHAIN.m/gtmjsdbjnl.js
%YGBLSTATS Sparkline Chart and %YGBLSTATS to JSON: GTMJSGVSTATS.m/gtmjsgvstats.js
The examples are:
gtmjstree.js (renders ^sampletree in the form of a tree)
gtmjs-sql1.js (a simple example)
gtmjs-sql2.js (a simple example)
gtmjs-to-gtm.js (example of JSWRITE.js helper class)
Step 1: Install node.js and npm
curl -sL https://deb.nodesource.com/setup_13.x | sudo -E bash - sudo apt-get install -y nodejs curl -L https://www.npmjs.com/install.sh | sh
Step 2: Install the fis-gtm-jswrite npm package
cd $project_dir npm install /path/to/fis-gtm-jswrite.tar.gz # This command installs the @fis-gtm/jswrite package and the relevant %JSWRITE reference implementation dependencies. npm audit --fix
Step 3: Run the %JSWRITE reference implementations
# The following reference implementations use the "STDIN^%JSWRITE singlesub" entry point and require the gtmposix plugin. export gtmroutines="node_modules/@fis-gtm/jswrite/reference_implementations $gtmroutines" # include the reference_implementations directory in the search list node node_modules/@fis-gtm/jswrite/reference_implementations/gtmjsjnlchain.js # journal file chain status sheet node node_modules/@fis-gtm/jswrite/reference_implementations/gtmjsaccessbg.js # %dirty buffer dashboard node node_modules/@fis-gtm/jswrite/reference_implementations/gtmjsdbjnl.js # displays the size of the database and journal files # Set the environment variable LC_ALL to a UTF8 locale (needed for the %JSWRITE Sparkline Chart (GTMJSGVSTATS.m/gtmjsgvstats.js) reference implementation) node node_modules/@fis-gtm/jswrite/reference_implementations/gtmjsgvstats.js # By default, this reference implementation displays a sparkline chart for SETs and GETs. For monitoring other statistics, open gtmjsgvstats.js and update the STAT array to include the list of statistics which require sparkline chart style monitoring.
Create a sandbox environment for GT.M and run the following commands:
$gtm_dist/mupip set -key_size=1019 -region "*" $gtm_dist/mupip load node_modules/@fis-gtm/jswrite/examples/sample.zwr $gtm_dist/mupip load node_modules/@fis-gtm/jswrite/examples/sampletree.zwr export "gtmroutines=node_modules/@fis-gtm/jswrite/examples/ $gtmroutines" # The following example uses the do ^%JSWRITE("^sample","[*]") entry point. This uses the lodash library to merge the nodes coming from %JSWRITE. npm install lodash@latest node node_modules/@fis-gtm/jswrite/examples/gtmjstree.js # loads sample.zwr in the tree format # The following two examples use the STDIN^%JSWRITE entry point of the %JSWRITE utility routine and then use the getter methods of the JSWRITE.js helper class to create the SQL queries. npm install alasql@latest node node_modules/@fis-gtm/jswrite/examples/gtmjs-sql1.js npm install sqlite3@latest node node_modules/@fis-gtm/jswrite/examples/gtmjs-sql2.js # The following example uses the @fis-gtm/jswrite helper class (JSWRITE.js) to send data back to GT.M in SET @ argument form using shelljs. npm install shelljs@latest node node_modules/@fis-gtm/jswrite/examples/gtmjs-to-gtm.js
$gtm_dist/mumps -r ^GTMJSGVSTATS | $gtm_dist/mumps -r STDIN^%JSWRITE singlesub > /src/toExcel/gvstats.json
You can also choose the statistics that you want in the JSON file with the following:
$gtm_dist/mumps -r ^GTMJSGVSTATS TR0,TR1,TR2,TR3,TR4 | $gtm_dist/mumps -r STDIN^%JSWRITE singlesub > /src/toExcel/gvstats.json
getSubs |
Returns an array containing the unsubscripted GT.M glvname and their subscripts. The first element of the array is always the glvname. | |
getValue |
Returns the value of the GT.M glvname. | |
getZWRLines |
Contains an array of ZWR lines with each element represents one valid argument for use with SET @ in GT.M. |
For example, for following GT.M lv structure:
GTM>zwrite A("One","Two","Three","Four")="Demo" GTM>do ^%JSWRITE("A","*") {"A":{"One":{"Two":{"Three":{"Four":"Demo"}}}}}
..instantiate an object as follows:
> var JSWRITE=require("@fis-gtm/jswrite") > JSObj=new JSWRITE({"A":{"One":{"Two":{"Three":{"Four":"Demo"}}}}})
The getter functions return the following values:
JSObj.getSubs |
| |
JSObj.getValue |
| |
JSObj.getZWRLines |
|
toZWR(JSONobj) |
Attempts to traverse and convert the JSON paths and their values of JSONObj to a form that can be used with SET @. The argument must be an object. Specifying an array produces an error. Invoking the .toZWR(JSONObj) method appends the getZWRLines array. | |
customZWR(glvName, [subscripts], glvValue) |
Returns an array containing the unsubscripted GT.M glvname and their subscripts. The first element of the array is always the glvname. | |
validateJSON(str) |
Checks whether the string argument is a valid JSON object. If str is a valid JSON string, it returns the result of JSON.parse(str). |
>var JSWRITE=require("@fis-gtm/jswrite") undefined > JSObj=new JSWRITE({}) undefined > JSObj.toZWR({"A":{"A1":[1,2,{"C":"C3"},4]}}) undefined > JSObj.getZWRLines [ 'A("A1","0")="1"', 'A("A1","1")="2"', 'A("A1","2","C")="C3"', 'A("A1","3")="4"' ] >
> JSObj.customZWR("A",[1,2,3,4,5],"ABCD\n") undefined > JSObj.getZWRLines [ 'A(1,2,3,4,5)="ABCD"_$C(10)_""' ]
INT: Converts interactively a string to lower-case.
FUNC(s): Invokes %LCASE as an extrinsic function returning the lower-case form of the argument.
INT: Converts octal number entered interactively to decimal number.
FUNC(oct): Invokes %OD as an extrinsic function returning the decimal equivalent of the argument.