vba engine, written in typescript/javascript

demo

https://yiminghe.me/kison/examples/vba

npm package

https://www.npmjs.com/package/vba

features

  • basic type: integer, array, string, double, date
  • expression: not > < <> = >= <= + & * / \ ^ += -= xor and or
  • visibility: public/private variable and sub/function
  • control logic: with, if then else, do while, for next, for each, goto
  • function: sub/function, static variable
  • error handling: function top level error handling
  • class module
  • binding: sub binding and class binding, vba engine even sub binding to provide native vba function/class, such as lbound/ubound/Collection

usage

import { Context, SubBinding } from 'vba';

const sampleCode = `
sub main
debug.print 1
debug.print 2
end sub
`.trim();

const MsgBoxSub: SubBinding = {
  name: 'debug.print',
  argumentsInfo: [
    {
      name: 'msg',
    },
  ],
  async value(args) {
    console.log((await args.getValue('msg'))?.value);
  },
};

async function main(){
  const context = new Context();
  context.registerSubBinding(MsgBoxSub);
  await context.load(sampleCode);
  await context.callSub('main');
  // console log 1 and 2
}

main();

codesandbox

发表评论

Fill in your details below or click an icon to log in:

WordPress.com 徽标

您正在使用您的 WordPress.com 账号评论。 注销 /  更改 )

Twitter picture

您正在使用您的 Twitter 账号评论。 注销 /  更改 )

Facebook photo

您正在使用您的 Facebook 账号评论。 注销 /  更改 )

Connecting to %s