Sunday, September 6, 2015

Teamcenter (Proprietary Scripting)

In the world of programming, there are few things more scary than.... undocumented, proprietary scripting languages.  In my years of experience, IMANScript or also known as TCScript, is one of those languages.

TcScript is the want to be ASP/VBScript (old school, not the new ASP.NET) programming language for the web version (thin-client) of Teamcenter.

So the crazy thing I found is an issue with the TcScript parser.  It was actually quite sad how I figured out the issue. Since every ASP-ish scripting language needs the capability to have include files and functions ... here is how I made the mistake.

#file "reference.isx"
def fnGetCrazy()
    print 'I was crazy here'
enddef\\END OF FILE

Of course "\\END OF FILE" was not actually there, but no character, comment, or other identifier followed the last "enddef" tag. Wildly, this does print an error, though cryptic and seemingly without meaning. The TcScript parser should have died, but it didn't, well not at this point.  The real critical error shows up when this file is included into another file and the new file also has a function defined inside of it.

#include the needed reference file "reference.isx"
include 'reference.isx'
def fnGetCrazy2()
    print 'I was crazy here too'
enddef\\Identification of error

The ending of the new file's, "enddef" causes a failure, because the "reference.isx" did not have a single character or line return following the definition of fnGetCrazy.
#fixed version
#file "reference.isx"
def fnGetCrazy()
    print 'I was crazy here'
enddef
#end with a comment and newline
\\END OF FILE


If you are TcScript guru, I am sorry.