launchFile(QString)

Parent Previous Next

TW.launchFile(QString pathAndFileName)


Set full path and file name.

Returns an object map with two member properties:


  "status" and "message".


There no arguments (options or switches) can be supplied see no variation will work.


This function is controlled by the Edit /Preferences/ Scripts - checkbox "allow scripts to run system commands".

Which is "off" by default.



Any directory (as  pathAndFileName) can be opened no matter what the security setting is.


  e.g. both of these work


var whatHappened = TW.launchFile("c:/TexProjects/writing");

var whatHappened = TW.launchFile("c:/TexProjects/writing/");


And local or web:—


var whatHappened = TW.launchFile("http://PaulANorman.info");



For a supplied filename, if the user has enabled System commands, then a file can be 'opened' or 'launched' by its system associated executable.


    1. If a document filename is supplied, it will be opened by what ever is set to handle the file type.
    2. If an executable's filename is supplied to the function the executable will be started.


1. On windows under normal default settings, notepad.exe might be expected to open this document.


var whatHappened =  launchFile("c:/to/somewherre/myFile.txt");


2. On windows under normal default settings, this usage would launch notepad.exe with a blank document showing.


var whatHappened =  launchFile("c:/windows/notepad.exe");

This type of thing will not currently work under any variation:

 var whatHappened =  TW.launchFile("c:/windows/notepad.exe c:/hold/MyFile.txt"



Return Values


The function returns an object with two member properties:


  "status" and "message"


The following tables list the return values for whatHappened


 whatHappened["status"] —  

Condition

Integer returned

Value

on success

SystemAccess_OK

0

on file access failure (e.g. wrong name supplied)

SystemAccess_Failed

1

if Preference Permission not set by User yet

SystemAccess_PermissionDenied

2



 whatHappened["message"]  —


Condition

String Returned

on success

a blank message - empty string

on file access failure (e.g. wrong name)

""c:/to/somewherre/myFile.txt" could not be opened."

if Preference Permission not set by User yet

"System command execution is disabled (see Preferences)"



Created with the Personal Edition of HelpNDoc: Easily create iPhone documentation