[texworks] Lua Extension - put into Sentance Case, Trim, Date Time, lowercase, uppercase

Stefan Löffler st.loeffler at gmail.com
Thu Sep 10 12:53:37 CEST 2009


Paul A Norman schrieb:
> Dear Jonathan,

Again not Jonathan, but anyway ;).

> I have been thinking more about these sorts of things, and the
> usefulness of other environments and the COM and related technmologies
> MS do, and I was starting to think of  cross platform solutions and
> then the
> whole XMLHttpRequest() mechanism came ot mind
> Is it at all possible to have that kind of thing, where a port number,
> IP and filename request can be issued and the cleaned up response text
> applied to the selection in the Editor?  Would JavaScript in TW have
> an XMLHttpRequest() type of object available?

I have no experience with this kind of Qt scripting, but a preliminary
search of the docs tells me "yes and no". If what Jonathan has in mind
is indeed QtScript, it is not JavaScript, it's _like_ JavaScript. It has
the same syntax and the same basic functions (e.g. for string handling,
calculations, etc.; technically speaking it implements the ECMA-262
standard), but it doesn't have all the browser/internet related
functions. No window, document, location and also no XMLHttpRequest
(which, IIRC, wasn't supported by many browsers for quite a while). So
much for the bad news.
The good news is that it could be relatively easy to work around this.
Qt does support HTTP requests, and it has additional classes to handle
XML. So one could fabricate something similar to XMLHttpRequest().
However, I'm not sure if this can be done from within the script (I
think it would have to be done on the C++ side and then made available
to the script; but these are details).

> It just seems mind blowing what could be achieved. Tap directly into
> databases .., well do anything that the server that recives the
> request can process.

Just one word of caution at the end. This mechanism can be incredibly
dangerous. If you execute scripts that you don't trust (and many people
seem to do this every day), you open the gates to viruses, hackers and
who knows what else. So I'd discourage automatic internet requests from
within scripts, and in any case the user has to be informed and has to
be able to choose whether or not a particular request should be made.


More information about the texworks mailing list