Run an AppleScript.
Run an AppleScript. The functions expects the complete script text, not a path to an existing script file.
Although the function is defined under Windows it returns an error code here, of course.
| Name | Type | Default | Description |
| Return | int | 0 or ErrorCode -1753 : syntax error in script text -1199 : not implemented (Windows only) |
|
| script | String or char* | - | complete script text (AppleScript of course!) |
| resultString | String or char* | 0 | allocted result string for the scripts return value |
The script expects a complete file path in the current text frame and duplicates this file. The full path of the result file is than written to the log file.
int create_duplicate (char * script)
{
*script = 0;
strcat (script, "set p to \"$MyPath\"\n");
strcat (script, "set a to POSIX file p\n");
strcat (script, "\n");
strcat (script, "tell application \"Finder\"\n");
strcat (script, " set r to duplicate a\n");
strcat (script, "end tell");
strcat (script, "\n");
strcat (script, "set res to POSIX path of (r as string)\n");
strcat (script, "return res");
return 0;
}
int main ()
{
String txt = string::alloc ();
char script [4000];
char resString[4000];
int res;
textmodel::gettext (txt);
create_duplicate (script);
strreplace (script, "$MyPath", file::uncurtain (string::get (txt)));
res = run_applescript (script, resString);
wlog (
"",
"Duplicate returned %d with message '%s'\n",
res, resString);
return 0;
}
... and vice versa cScript executed from AppleScript:
(* Open the products panel, login and load all products. *) tell application "Adobe InDesign CS5" set visible of panel "Product Pool" to 1
set CT to comet 1 -- Die 1 ist wichtig!! tell CT set sc to "" set sc to sc & "int main () {" set sc to sc & "datapool::login (1, \"mysql\", \"root\", \"\", \"tablemodule\", \"\", 0, 0);" set sc to sc & "list::reload (3, 1);" set sc to sc & "return 0;}"
eval cscript sc argument "" options ""
end tell end tell
Alphabetic index HTML hierarchy of classes or Java