Embeddable and Extensible Basic Interpreter | CodeGuru

Embeddable and Extensible Basic Interpreter

Environment: Win32, MS Visual C++ 6.0 Sometimes to add new features to an application we need more than to just add new buttons to toolbar. One of the ways to ultimately extend application’s capabilities is to add scripting language to it. BeeBasic embeddable basic interpreter is one of the tools that can be used for […]

Written By
CodeGuru Staff
CodeGuru Staff
Mar 11, 2002
2 minute read
CodeGuru content and product recommendations are editorially independent. We may make money when you click on links to our partners. Learn More

Environment: Win32, MS Visual C++ 6.0


Sometimes to add new features to an application we need more than to just add new buttons to toolbar. One of the ways to ultimately extend application’s capabilities is to add scripting language to it. BeeBasic embeddable basic interpreter is one of the tools that can be used for this purpose.


BeeBasic is made to be embedded in into GUI applications. It creates terminal window to process input and print statements, and dialog widow for its dialog statement (with dialog you can input several vales at a time).


BeeBasic was made to be embedded. By adding extensions you can call your application’s functions and manipulate application’s objects from script. Thare are four kinds of extensions you can add to BeeBasic: constants, subs, functions and objects. I tried to make the process as simple as possible. For example, to add extension function which is to be refered from script as “MyFunction” you have to implement and add it to engine:

void MyFunction_func(int nargs, variable* pargs, variable& result)
{
  // nargs is number of arguments that function receives
  // pargs is a pointer to an array of arguments
  // result is the variable to store function result
  // do what you need and pass result to result
}
….
// add it to engine:
// “MyFunction” is the way it will be used in script
// MyFunction_func is the implementation abow
// 1 is a legal number of arguments
::bee_add_extension_function(“MyFunction”, MyFunction_func, 1);

Once you have performed the abow steps, you can write in script:

print “MyFunction = “, MyFunction(1)

Engine will check syntax and report errors if any. At runtime engine will call your implementation function, pass it arguments and receive result. Isn

t it easy?


Extension constants and objects (like a = Sheet(1).Cell(1, 1)) are added in similar way. Detailed documentation comes with source.

I tried to keep BeeBasic as close to standard basic as possible. It supports the following statements:


  • DIM … AS …

  • IF … THEN … ELSE … END IF (single-line & multy-line)

  • FOR … TO … STEP … NEXT

  • DO … LOOP

  • WHILE … WEND

  • GOTO

  • SUB … END SUB

  • END

  • PRINT

  • INPUT

  • DIALOG (input values in dialog window)

  • BEEP

BeeBasic supports three variable types : string, integer and floating. BeeBasic contains common math and string-manipulation functions. I didn’t try to add as many functions as possible, beacuse every developer can add ANY number of ANY function he needs.

Downloads


Download : source, documentation, samples – 281Kb



Visit homepage

CodeGuru Logo

CodeGuru covers topics related to Microsoft-related software development, mobile development, database management, and web application programming. In addition to tutorials and how-tos that teach programmers how to code in Microsoft-related languages and frameworks like C# and .Net, we also publish articles on software development tools, the latest in developer news, and advice for project managers. Cloud services such as Microsoft Azure and database options including SQL Server and MSSQL are also frequently covered.

Property of TechnologyAdvice. © 2026 TechnologyAdvice. All Rights Reserved

Advertiser Disclosure: Some of the products that appear on this site are from companies from which TechnologyAdvice receives compensation. This compensation may impact how and where products appear on this site including, for example, the order in which they appear. TechnologyAdvice does not include all companies or all types of products available in the marketplace.