I tried to trim a String but nothing works with JScript (officially there is a Trim()-Function in JScript...).
Any ideas?
Is there a reference for what really works for JScript in DOpus?
I'm a bit annoyed. The staff always propagated "Python sucks, get something else, e.g. JScript ..." now I take JScript and constantly something does not work as exptected ...
JScript for Windows scripting stagnated around the 2010 Javascript standard / IE8 so some newer language additions won't be there, unfortunately. (Newer versions of IE have a different Javascript engine now. I had a quick try of making Opus load that instead of the normal one, and it works but also seems to only provide the same language features as the normal one, so I think it's running in some kind of compatibility mode when invoked in that way, which isn't officially supported anyway.)
On the plus side, you can generally find solutions by searching as hundreds of other people have run into the same things over the years, generating lots of useful Q&As on the web. (Something similar to TBone's functions is in the first Google result for "JScript trim" once you tell Google you really meant "JScript" and not "Javascript".)
It's not perfect, but still a lot fewer problems and easier, quicker-to-find solutions than the relatively uncharted and hostile terrain of using 3rd party languages with ActiveScripting.
Thanks for your replies, even if they are not satisfactory...
@Leo:
I found the 'solution' you mentioned. But because this is from the year 2004, I assumed that there is a better solution now...
Finally it can be said:
On the one hand, 3rd-party languages (e.g. Python) that are up-to-date don't work with ActiveScripting correctly.
On the other hand, languages, that are "made for ActiveScripting" (e.g. JScript, VBScript) are stagnated somewhen and you have to build functions you need yourself.
@dinkelhopper, what you're saying is true. Nothing can be done about it, except joining the development of
a script host of the language you want to support (if it is opensource). 3rd-party languages are primarily used
on their own, not through script hosting, so there isn't really any incentive for the developers to maintain/develop it.
Microsoft's JScript/VBScript are maintained, but only for use inside IE. It has probably stagnated as a script
host because of compatibility reasons.
However, because of JScript/VBScript's support for COM/ActiveX/nameoftheday they are quite extensible.
Which can be done like shown below (by excluding all the javascript blabla). It's what I use with quite satisfiying results.
trim jscript -javascript
Once you "passed" String.trim()/left()/right(), Array.contains() and maybe another handful methods, you can really settle with what jscript offers.
I find jscript quite alright, maybe just because the clearly shaped function/method-set helps to keep oversight. Compared to php, perl, powershell or maybe even javascript, a bloated set of default methods and different options to achieve the same thing can be distracting at times.
Is vbscript any better, just because it has a trim() function? Hell no! There are more important aspects to a language than a builtin trim().
--
Regarding the j(ava)script vs. python topic, an interesting read I found here: blog.glyphobet.net/essay/2557 - I especially liked how this article closed: