[texworks] SCRIPTING: 1. __FILE__ not quite true and 2. TW.system not handling - or _ in path structure(?)

Paul A Norman paul.a.norman at gmail.com
Thu May 19 13:06:18 CEST 2011

Thanks Stefan,

I'll see if I can identify what is happening better.

2. is strange, as it is the paths with out the spaces, using - or _
instead of spaces that is giving me grief.

 process.start("dir \"\"\"My Documents\"\"\""

woah!  I've been getting away with "dir \"dah dah dah\" "
no worries.


On 19 May 2011 22:38, Stefan Löffler <st.loeffler at gmail.com> wrote:
> Hi,
> On 2011-05-19 04:03, Paul A Norman wrote:
>>  TW.information(null, "", __FILE__);
>> Shows the path and file name - but the first segment between the first
>> delimeter / / set  is set to lowercase and I have some capitals there.
>> E.g.
>> Real path is:
>> G:/LaTeXPortable/LaTexUtils/TeXWorks/texworks/config/scripts/Image
>> Handling/convertImage.js
>> But __FILE__ copies to clipboard in Script as:
>> G:/latexportable/LaTexUtils/TeXWorks/texworks/config/scripts/Image
>> Handling/convertImage.js
> Hm, this is weird. __FILE__ is provided directly by the QtScript API,
> though, AFAIK. Tw doesn't do anything with it (nor does it exist in,
> e.g., lua). So this might be a Qt bug (but then again, I'm not sure if
> this feature is documented at all - probably that should be checked first).
>> Also, If I change this part of the path  /Image Handling/  to either
>> of   /Image-Handling/  /Image_Handling/
>> I get strange results when I try to pass this through TW.system even
>> just for:  cmd /c dir /b \" + scriptPath + "\\*.txt\""
>> "Parameter format not correct - "latexportable"."
>> The above works fine when it is /Image Handling/ in the path (with the space).
>> And copying cmd /c dir /b \" + scriptPath + "\\*.txt\"" in expanded
>> form to the clipboard in script and then pasting it into a dos prompt
>> works fine for all three path versions of   /Image Handling/
>> /Image-Handling/  /Image_Handling/
> This is strange, too. Again, Tw doesn't do anything with the command
> line, it passes is straight to
> http://doc.trolltech.com/4.7/qprocess.html#start-2. So, two suggestons:
>  * Does it work (for a path without spaces) if you remove the quotes?
>  * Does it work if you escape the quotes
> (http://doc.trolltech.com/4.7/qprocess.html#start-2 actually has an
> example on `dir`).
> Stefan

More information about the texworks mailing list