Skip to content

Instantly share code, notes, and snippets.

@mindspank
Created April 15, 2016 20:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mindspank/6db3894982070c486a50ddb0fb2059b4 to your computer and use it in GitHub Desktop.
Save mindspank/6db3894982070c486a50ddb0fb2059b4 to your computer and use it in GitHub Desktop.
const qsocks = require('qsocks');
// Get a global reference
var global = qsocks.Connect();
global.then(function(global) {
return global.createApp('This is my app3');
})
.then(function(reply) {
// Establish a new connection so we don't pollute the current engine session.
return qsocks.ConnectOpenApp({appname: reply.qAppId});
})
.then(function(conns) {
// [global, app]
var app = conns[1];
// Load scripts in Qlik is just a string
var myscript = "Characters:\r\nLoad Chr(RecNo()+Ord('A')-1) as Alpha, RecNo() as Num autogenerate 26;";
// Get a empty script to get correct locale variables
return app.getEmptyScript('Main').then(function(script) {
return app.setScript(script + myscript)
})
// Reload
.then(function() {
return app.doReload()
})
// Save
.then(function() {
return app.doSave()
});
})
.then(function() {
// Probably wanna clean up here and close websockets.
console.log('Done')
})
.catch(function(err) {
console.log(err) // Handle errors
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment