-
Notifications
You must be signed in to change notification settings - Fork 122
Customizing an importer
MY-BASIC tries to load a BASIC source file in plain text format on disk, by using an import
statement without the module prefix ('@'). It's also possible to customize an importer to make your own import algorithm. This is effective when you need to encrypt a part of your product.
Use the following function to customize an importer:
int mb_set_import_handler(struct mb_interpreter_t* s, mb_import_handler_t h);
The handler type mb_import_handler_t
is defined as:
typedef int (* mb_import_handler_t)(struct mb_interpreter_t*, const char*);
Assuming when coded as import "somewhere"
, then the string argument will be passed to the second const char*
parameter. A handler will be invoked during parsing pass; you may do some registrations in a handler body with class, routine, interface, etc. Or just load BASIC programs using a customized algorithm from IO.
Read the Importing another file page to get information about how to import another source code file.
Read the Module (namespace) page to get information about importing a module (using a namespace).
- Principles
- Coding
- Data types
- Standalone shell
- Integration
- Customization
- More scripting API
- FAQ