Date: 2/9/2006
| Today I got the Scripting Language in i.Mage to call into an external DLL. The test script was simple:
extern int MessageBoxA(HWND, LPCTSTR, LPCTSTR, UINT) in "User32.dll";
MessageBoxA(Parent, "Title", "Message", 0);
Which now runs as you'd expect. The "parent" variable is a predefined uint32 containing the handle of the script window. The other predefined variable at this point is a DOM pointer to the i.Mage application itself.
This will most likely appear in the next Scribe release in the filters, so that you can create very custom filters. By being able to define calls into external DLL's you could write some code in any language you want and call it from Scribe. Some of the tools hanging onto various menus in Scribe will most likely be rewritten in Script instead of C++ and thus Scribe will become extensible. e.g. the little utils hanging off the bottom of the Tools menu are begging to be re-written in Script.
If you liked that first snippit, then you'll love this. Check out this new working script:
extern int MessageBoxA(HWND, LPCTSTR, LPCTSTR, UINT) in "User32.dll";
extern DWORD GetTempPathA(DWORD, LPTSTR) in "Kernel32.dll";
s.length = 256;
GetTempPathA(s.length, s);
MessageBoxA(Parent, s, "Title", 0);
Variables can now have members, i.e. DOM style addressing. Assigning a value to the .length member of a variable turns it into a string of spaces of the requested length. This is useful for preallocating string buffer memory for calling C functions that expect that. Conversely getting the .length member of a string returns "strlen(c_str)".
I've kinda left room for expanding this out to use non-atomic types like structures and so on, but that isn't implemented yet. I have to implement code to parse the type definition first and then code to use allow the script to declare a variable of that type and use it. Which is a substantial feature to add.
|
Ben 03/09/2006 9:00am
| Very intresting, but I have a question, didn't you think about using an already existing scripting language to do the job?
I admire your work, but it will be 'another' scripting language one will have to 'learn' to write image or scribe addon.
If you would use lua for example, already know by a large number, you would have a branding to encourage people to write plugin, addon, etc.
|