Headless API

Headless API support is added in our latest version of Green Screens Web Terminal. Now it is possible to include only our JavaScript library in 3rd party web applications and use terminal API to access and navigate terminal screens without UI interface.

This opens whole new set of possibilities like creating custom UI, having screen scraping inside web browser or adding new modernization features by converting 5250 screens into JSON data format and use that format to render GUI interfaces.

How simply it is, let us show you with few examples...

First, let's connect to Green Screens Terminal Service

Tn5250.Base.connect('http://localhost:9080', {uuid:0, host:'DEMO'}, function() {
  consonle.log('Connected')
});

Next, attach screen listener. Listener will triggger every time new screen arrives. In this case we will convert current screen data into simple text just to print current screen state on the console.

Tn5250.Application.listen('display', function(cfg, screen) {
 var cols = cfg.cols-1;
 var rows = cfg.rows-1;
 var txt = Tn5250.Parser.textRangeExtract(screen, 0, 0, cols, rows);
 console.log(txt);
});

Now, let's fill screen fields and send some commands. In this case, we will populate login screen data and press ENTER.

var cfg = Tn5250.Application.getConfig();
var CMD = Tn5250.Keyboard.COMMANDS;
Tn5250.GUI.setField(1,'QSECOFR');
Tn5250.GUI.setField(2,'QSECOFR');
Tn5250.Keyboard.sendCommand(CMD.ENTER, cfg)

Go to WRKACTJOB

var cfg = Tn5250.Application.getConfig();
var CMD = Tn5250.Keyboard.COMMANDS;
Tn5250.GUI.setField(1,'WRKACTJOB');
Tn5250.Keyboard.sendCommand(CMD.ENTER, cfg)

Navigate WRKACTJOB

var cfg = Tn5250.Application.getConfig();
var CMD = Tn5250.Keyboard.COMMANDS;
Tn5250.Keyboard.sendCommand(CMD.PGDOWN, cfg)

Exit from  WRKACTJOB

var cfg = Tn5250.Application.getConfig();
var CMD = Tn5250.Keyboard.COMMANDS;
Tn5250.Keyboard.sendCommand(CMD.PF3, cfg);

And finally sign-off.

var cfg = Tn5250.Application.getConfig();
var CMD = Tn5250.Keyboard.COMMANDS;
Tn5250.GUI.setField(1,'90');
Tn5250.Keyboard.sendCommand(CMD.ENTER, cfg);

See all in this 30sec video.


Now, it is possible to automate tasks with combination of hash execution, macro engine and etl engine to handle specific screens like mapping every screen to custom UI renderer.

UI renderer itself can be any kind of web framework one can use to create modern looking web application from legacy green screens.

We hope that we manage to show you base headless API usage example and tickle your imagination.