Training, Open Source computer languages

This is page http://www.wellho.net/forum/The-Tcl- ... guage/Managing-errors-in-a-different-language.html

Our email: info@wellho.net • Phone: 01144 1225 708225

 
For 2023 (and 2024 ...) - we are now fully retired from IT training.
We have made many, many friends over 25 years of teaching about Python, Tcl, Perl, PHP, Lua, Java, C and C++ - and MySQL, Linux and Solaris/SunOS too. Our training notes are now very much out of date, but due to upward compatability most of our examples remain operational and even relevant ad you are welcome to make us if them "as seen" and at your own risk.

Lisa and I (Graham) now live in what was our training centre in Melksham - happy to meet with former delegates here - but do check ahead before coming round. We are far from inactive - rather, enjoying the times that we are retired but still healthy enough in mind and body to be active!

I am also active in many other area and still look after a lot of web sites - you can find an index ((here))
Managing errors in a different language

Posted by nicolascastagne (nicolascastagne), 6 April 2005
Hi all,

We are using Tcl for supporting a user-dedicated langage within a big GUI-based application developped in C++.
The user will use this language to manage some sort of "macros".
Nothing particular so far : tcl is adequate to this usage.

However, we encounter huge difficulties to manage the errors.

Indeed, we need to translate the errors in the appropriate language : italian, french, etc.

This is not a problem for the proc we provide ourselves. But how could we handle the errors generated within Tcl ?
For example, in case of a syntax error, we cannot display the basic Tcl output errorInfo to our user.

A solution would be to get a "error code" from Tcl, that we could "expand" in the appropriate string form. But, so far, we do not succeed in recovering any error code in the C++ code - only the wall char* errorInfo .
Is that possible ? Where can we find a description of all the error codes Tcl may generate ?

More generally, since Tcl is widely used for managing languages within apps... How is this problem handled usually ?

Thx in advance !

Posted by admin (Graham Ellis), 10 April 2005
Hi, Nicolas ... I'm not ignoring the question, but this isn't one that I've come across personally and I was hoping that someone else had ...

Posted by Custard (Custard), 10 April 2005
Hi,

I just wrote a lengthy post that completely missed the point after I re read your post..

Try no,2


Catch!

According to my book,

Code:
catch { your code } msg



Will run 'your code' and if there is an error, the catch returns a 1, and msg is set to whatever the error was.
If 'your code' was successful, catch returns a 0, and msg contains the return value from 'your code'

Is this any use?

B

Posted by admin (Graham Ellis), 11 April 2005
Ah ... I had forgotten / overlooked catch. It might well be the trigger that Nicolas is looking for.

If that other lengthy piece of text is of general interest / as a tip on Tcl, do feel free to start a new thread, "B"  

Posted by Custard (Custard), 11 April 2005
Hi,

(Graham, I will post here as it is sort of pertinent to the subject of this thread even though the OP may have solved this bit already.
I just like this way as it enables use of java-like message bundles.
And you're lucky it was still in my cut-buffer!)

This is one of the briefs in my current project (which is admittedly perl, but the prinicples are the same).

What I have is a config file with entries for country/language like

Code:
country = EN
language = EN



And a class (in perl) which is initialised with these codes, and looks for a message bundle in a config directory. In my case, the message bundle would be config/Messages_EN_EN.

Code:
error.cannotload = Cannot Load File ()
msg.started = Started () at ().



The message bundle (suspiciously similar in format to the Java message bundles) is loaded into a hash.
Empty parens () are substituted with args in the message function.

Then you can call the message function like  

Code:
message "error.cannotload" "file.txt"



Translate my description into TCL-speak, and write your 'init' and 'message' function, and you're close.

I hope this is what you mean, and is helpful.

For perl there are various ways of doing it, and I'm sure there are for TCL, and maybe there is something out there. I rolled my own because it suited me to.

HTH

B


Posted by admin (Graham Ellis), 12 April 2005
That takes me back to my days of CAD software writing ... with support for English and Norwegian.  All meesages numbered, and the appropriate message file loaded without anything so fancy as a config file (but it was a very long time ago).   We also had a reverse translation setup, as keywords and single letter confirmations entered were best translated too.



This page is a thread posted to the opentalk forum at www.opentalk.org.uk and archived here for reference. To jump to the archive index please follow this link.

© WELL HOUSE CONSULTANTS LTD., 2024: Well House Manor • 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • FAX: 01144 1225 793803 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho