#inline #scripting-language #wsh #vbscript #activescript #rust

inline-vbs

Embed VBScript (and JScript, Ruby, Perl, ...) code inside Rust

6 releases

0.4.0 Apr 29, 2023
0.2.1 Nov 8, 2022
0.1.2 Mar 2, 2022

#415 in Programming languages

MIT/Apache

21KB
425 lines

inline-vbs

inline-vbs is a crate that allows you to embed VBScript, JScript and many other languages inside Rust code files. It uses the Active Scripting COM APIs to dynamically parse and execute (optionally, evaluate) code.

image

Basic usage

use inline_vbs::*;

fn main() {
    vbs! { On Error Resume Next } // tired of handling errors?
    vbs! { MsgBox "Hello, world!" }
    let language = "VBScript";
    assert_eq!(vbs_!['language & " Rocks!"], "VBScript Rocks!".into());
}

Macros:

  • vbs! - Executes a statement or evaluates an expression (depending on context)
  • vbs_! - Evaluates an expression
  • vbs_raw! - Executes a statement (string input instead of tokens, use for multiline code) See more examples in tests/tests.rs.

Installation

Add this to your Cargo.toml:

[dependencies]
inline-vbs = "0.4.0"

Important: You need to have the MSVC Build Tools installed on your computer, as required by cc.

Language support

VBScript (vbs!) and JScript (js!) are available out of the box on 32-bit and 64-bit.

Other Active Scripting engines exist:

Note: install an engine matching the bitness of your program; by default Rust on Windows builds 64-bit programs, which can only use 64-bit libraries. If you want to use a 32-bit library, you need to build your program with --target i686-pc-windows-msvc.

Limitations

Many.

Motivation

N/A

License

This project is licensed under either of

Dependencies

~133MB
~2M SLoC