
How to call a Windows API function from a TCL script
Quote:
>Howdy folks,
>I am researching ways to add scripting support to a PC hardware testing
>program that runs on Windows 95 and Windows NT. I really don't know
>squatt about TCL and I have several questions:
>1- Can an API function be called from within the script, like
>GetSystemMetrics?
Yes! You would have to create a tcl command to convert arguements
and/or results to/from C variables. Check out TclCreateCommand man
page. In the case of GetSystemMetrics, i'd return an array with the
struct element names as the keys and the values as strings. This can
be done from within a c function.
Quote:
>2- Could the script call a DLL function?
Yup! Check out package require and load library. The function called
in the dll must be set up as a tcl command - check out the dll example
available on the Sunscript site.
Quote:
>3- Can the Script and the program share variables and functions from
>within the EXE.
You can explicitly share variables via some sort of accessor commands,
but you can't just declare a var in tcl that is immediately visible to
a C program or vice versa.
Quote:
>4- I know this is hard to answer based on the small amount of
>information I have provided, but how does TCL rate as the script enging
>for my program, compared with others, Perl, Python, et al?
Well, _personally_, I think tcl is the best - it's more tailored for
being a drop-in scripting language then the others. Pearl is very
Unix-centric.
Quote:
>Thanks. I would appreciate any extra insight or knowledge that you can
>throw my way.
1) RTFM :-)
2) Get the next edition of Welch's book due out soon (June??) and the
new TCL extensions book due at the end of May from O'Reilly
(http://www.ora.com) - likely to be a HOT book!
3) If, like the rest of us Windows people, you can't read man pages,
download the itcl2.2 distribution which has all the tcl and tk man
pages turned into html. Itcl is itself a hoot too :-)
4. Check out SWIG - Simplified Wrapper and Interface Generator to
"auto create" C/C++ linkages for tcl (and pearl/python/grail).
http://www.cs.utah.edu/~beazley/SWIG/
5. SCO has the best directory page for tcl goodies in my opinion at
http://www.sco.com/tcl
Quote:
>Harold Howe
Dave