Blog
Translating Script Menu Names
Date: 13/8/2008
Well I've finally settled on a solution to the translation of scripting menu commands. The new scripting support in Scribe v2 uses the new bytecode VM and I've extended the API to include a wrapper around LgiLoadString which is what Scribe uses natively to load strings from the lr8 resource file. So the script can use that to load it's translated name straight from the source. However that doesn't get it on a menu. So the new scripting engine runs each script in "./Scripts" on startup and the main function of each script calls "AddToolsMenuItem" which is a new function that registers a callback connected to a menu item in the tools menu. i.e.
AddToolsMenuItem(LoadString(IDS_REMOVE_DUPES), "DeleteDuplicateMessages");
So you can see that the text of the menu will be translated and the 2nd parameter to that function is the name of the callback method to call when the user clicks the menu item. All in all it's very neat. There is another tricky part in the define "IDS_REMOVE_DUPES" is in a C header file. So originally I just copied the integer value that it mapped to as a literal into the script file. But I decided that it would break too easily and so I made the script engine cope with C style #include and #define so that I can just include the resource defines straight into the script and then use the actual name of the string.

Neat.

Previously, Previously.
Comments:
Scott W
20/08/2008 10:59am
I'm having trouble getting the new scripts to work. None of them seem to do anything. I have tried running scripts in 1.9 Test4 and 2.0 alpha5, both with the same results.

For example, attempting "Delete Attachments.script" will respond with "Do you want to delete 0 bytes in 0 attachments?" despite attachments being present. Selecting "Yes" does not result in the attachments being deleted. Running "Delete all attachments in current folder" results in the prompt "Do you want to permanently delete 6 attachments taking up 13K?".

Are there any prerequisites for scripts to work?
Scott W
20/08/2008 8:56pm
I'm having trouble getting the new scripts to work. None of them seem to do anything. I have tried running scripts in 1.9 Test4 and 2.0 alpha5, both with the same results.

For example, attempting "Delete Attachments.script" will respond with "Do you want to delete 0 bytes in 0 attachments?" despite attachments being present. Selecting "Yes" does not result in the attachments being deleted. Running "Delete all attachments in current folder" results in the prompt "Do you want to permanently delete 6 attachments taking up 13K?".

Are there any prerequisites for scripts to work?
fret
20/08/2008 10:30pm
I don't know whats going on with the v1.90 scripts but the v2 scripts havn't been released yet, you'll have to wait for the next build of v2.
Scott W
22/08/2008 10:35am
I'm having trouble getting the new scripts to work. None of them seem to do anything. I have tried running scripts in 1.9 Test4 and 2.0 alpha5, both with the same results.

For example, attempting "Delete Attachments.script" will respond with "Do you want to delete 0 bytes in 0 attachments?" despite attachments being present. Selecting "Yes" does not result in the attachments being deleted. Running "Delete all attachments in current folder" results in the prompt "Do you want to permanently delete 6 attachments taking up 13K?".

Are there any prerequisites for scripts to work?
fret
22/08/2008 11:51am
Huh? You're just posting the same thing over and over.

I got the message, I will look at it when I can. Likely you'll have to wait till the next release in any case. Just be patient ok?
fret
25/08/2008 3:22am
This problem is fixed in the most recent release, v1.90 test 5.

Regards :)
Scott W
30/08/2008 11:24pm
Thanks for the fix, it works much better now.

Sorry about the triple posting. I hadn't closed the tab and I think Opera was doing silly things with the cache. (I only hit "Post" once -- honest.)
I will now close this tab so that it only gets posted once (I hope).
 
Reply
From:
Email (optional): (Will be HTML encoded to evade harvesting)
Message:
 
Remember username and/or email in a cookie.
Notify me of new posts in this thread via email.
BBcode:
[q]text[/q]
[url=link]description[/url]
[img]url_to_image[/img]
[pre]some_code[/pre]
[b]bold_text[/b]