Last active
December 17, 2021 07:26
-
-
Save yiminghe/ba75422198cf472485e61009c0c8812d to your computer and use it in GitHub Desktop.
vba demo
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>vba demo</title> | |
<meta charset="UTF-8" /> | |
</head> | |
<body> | |
<div> | |
<a href="https://bl.ocks.org/yiminghe/ba75422198cf472485e61009c0c8812d" target="_blank">blocks</a> | |
<a href="https://gist.github.com/yiminghe/ba75422198cf472485e61009c0c8812d" target="_blank">gist</a> | |
<br/> | |
</div> | |
<div id="app"></div> | |
<script type="module"> | |
import { Context } from 'https://unpkg.com/[email protected]/dist-web/index.js'; | |
const sampleCode = ` | |
sub main | |
debug.print 1 | |
debug.print 2 | |
end sub | |
`.trim(); | |
let ret = []; | |
const MsgBoxSub = { | |
name: "debug.print", | |
argumentsInfo: [ | |
{ | |
name: "msg" | |
} | |
], | |
async value(args) { | |
ret.push((await args.getValue("msg"))?.value); | |
console.log(ret[ret.length - 1]); | |
} | |
}; | |
async function main() { | |
const context = new Context(); | |
context.registerSubBinding(MsgBoxSub); | |
await context.load(sampleCode); | |
await context.callSub("main"); | |
// console log 1 and 2 | |
document.getElementById("app").innerHTML = | |
` | |
<h2>demo of npm package: vba</h2> | |
` + ret.join("<br>"); | |
} | |
main(); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment