Created
April 15, 2016 20:32
-
-
Save mindspank/6db3894982070c486a50ddb0fb2059b4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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