Advanced STRRMTCMD for Android
Our Android application supports STRRMTCMD to start another Android application with additional parameter values as described in our previous blog here
In this post we will describe advanced possibilities using this feature as dynamic parameters passing.
Except sending IBM I generated parameters we can also create custom data inside 5250 web terminal itself then use STRRMTCMD to start Android app.
Base idea is to use Web Admin console to add custom script as described here and here and later call it with STRPCCMD.
Our custom script might extract screen data and prepare it to specific format or even use Tn5250 API events to trigger every time when screen change to automatically update shared parameter.
Also, we can call 3rd party Android app every time new spool is received. For example, 3rd party app can be used to download PDF spool, digitally sign it and send it to some email address etc.
(function() {
'use strict';
// will execute every time new screen generated to update Android screen data
// This data will be forwarded when terminal app calls STRRMTCMD to start Android app
function onScreen(cfg) {
// generate screen data in JSON format
var scr = Tn5250.Application.screenToJson();
//set scr variable for Android app
Tn5250.Application.trigger('rmtcmd', 'var:scr=' + btoa(JSON.stringify(scr)));
}
// will execute when terminal is connected
function onTerminal() {
// will trigger when new screen is rendered
Tn5250.Application.listen('display', onScreen);
// called whenever SPOOL file is released to active virtual printer
Tn5250.Application.listen('report', function(url, par, reportName) {
// set report url and name to Android variable
Tn5250.Application.trigger('rmtcmd', 'var:url=' + url);
Tn5250.Application.trigger('rmtcmd', 'var:reportName=' + reportName);
// Call custom Android application to download and process report
Tn5250.Application.trigger('rmtcmd', 'android:io.greenscreens.reports');
});
}
// register Web Terminal start event
window.addEventListener('greenscreens', onTerminal);
})();
// use this sample function to update cursor position
function myScript() {
var cfg = Tn5250.Applciation.getConfig();
Tn5250.Application.trigger('rmtcmd', 'var:row=' + cfg.row);
Tn5250.Application.trigger('rmtcmd', 'var:col=' + cfg.col);
}
Based on sample shown above, scr parameter in received Intent will contain screen data in JSON format when 5250 terminal calls Android app from STRRMTCMD.
STRPCO
STRPCCMD PCCMD('android:io.greenscreens.demo') PAUSE(*NO)
In this sample we will call custom script injected inside web terminal. Injected script will update mobile shared parameter values for current cursor position. Later we will call our Android app to receive last known row and col.
STRPCO
STRPCCMD PCCMD('script:myScript()') PAUSE(*NO)
STRPCCMD PCCMD('android:io.greenscreens.demo') PAUSE(*NO)
Use received Intent in 3rd party Android app to extract shared parameter values.
// get last cursor position
String row = intent.getString("row");
String col = intent.getString("col");
// get scree ndata in JSON format
String scr = intent.getString("scr");
// get last spool url and report file name
String url = intent.getString("url");
String rnm = intent.getString("reportName");