Paul A Norman
paul.a.norman at gmail.com
Sun Oct 31 08:29:45 CET 2010
I've worked through a proof of concept and this looks very feasible,
in fact I'm using it in every day work now.
In it I have used a work around in the meanwhile for loading ECMA libraries.
And wrapped a number of properties and functions in an object called $Tw
The php_js functions are in an object called $PhpJs detailed in
phpjs.namespaced.js from their web site (
http://phpjs.org/packages/configure ). There would be some editing of
phpjs.namespaced.js needed longterm, but it provides very useful
Although php_js does not require it for its own use, I am temporarily
relying on php to give me file read access in loading the needed
and top level functions in, after that all that would be required for
extra JS libraries is function module_load(module_name) ...
////////// Begin Preamble
/* Creates $Tw object with properties and helper functions
and a function in the current scope: module_load()
And sets up $phpjs = new PHP_JS();
See notes in scripts/mod_general.js */
var scriptName = __FILE__ ;
var scriptRoot = __FILE__.substr(0,__FILE__.lastIndexOf("/")) ;
var scriptRoot = scriptRoot.substr(0,scriptRoot.lastIndexOf("/")+1) ;
var loadFile = "\"" + scriptRoot + 'mod_loadFile.php\" mod_general.js';
// Non-windows OSes won't need the cmd /c
////////// END Preamble
Here are some example calls (below) in a Tw QtScript and results,
moving from what we'd expect EMCA to do any way, to extras.
If any one wants to look through this please drop me an email or a
note here, and I'll try and put something of the current state of it
up on the web for download. (Not sure how many are doing Scripting at
$Tw.alert($PhpJs.ucwords("hello this should appear in title case"));
$Tw.alert($PhpJs.sort("hello this should appear in title
case".split(" ")).join(" "));
this should appear in title case"));
$Tw.alert( $Tw.file_get_contents("c:/windows/php.ini") );
On 22 October 2010 17:43, Paul A Norman <paul.a.norman at gmail.com> wrote:
> Hi, FYI,
> Some very clever fellows have ported a considerable number of string
> handling, array handling and other potentially very useful functions
> across from php to EMCA style scripting, and made them all work as per
> the PHP manual (documentation as it already exists).
> (I was thinking these may be useful for Qt scripting? There are of
> course many things that would never be used - and perhaps a core set
> of things we could tie into the TwApi perhaps thorugh a wrapper? like
> a specialized file_get_contents() etc ...
> As said there would be many things that are too web orientated and
> would never be used. And some stuff that wold be directly useful now.)
> Even more cleverly they have made their 'library' customisable
> pre-download so that a script-developer could define their own
> package(s) as needed, with only QtScript relevant functions and
> dependencies in it.
> Food for thought.
> ---- Quote from web site: ----
> "php.js is an open source project that brings high-level PHP functions
> extensions ( Mozilla/Firefox, Chrome ), AIR, and SSJS engines like V8
> ( node.js, v8cgi ), Rhino, and SpiderMonkey ( CouchDB )
> "If you want to perform high-level operations on these platforms, you
> probably need to write JS that combines its lower-level functions and
> build it up until you have something useful like: strip_tags(),
> strtotime(), number_format(), wordwrap().
> "That's what we are doing for you.
More information about the texworks