Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Unfortunately there are many problems in your code.</p> <ol> <li><p>The <code>C</code> function <a href="http://developer.apple.com/mac/library/documentation/Darwin/Reference/ManPages/man3/system.3.html" rel="nofollow noreferrer"><code>system</code></a> <em>does not</em> return the standard output of the script as <code>char*</code>.</p></li> <li><p>Even with a function which returns <code>char*</code>, you can't assign it to a array of <code>char</code> as you did:</p> <pre><code> char* str="aeiou"; char foo[100]; foo[100]=str; /* doesn't work */ foo=str; /* doesn't work either */ </code></pre></li> <li><p>Cocoa's string class, <code>NSString*</code>, is not a C string <code>char*</code>, although you can easily convert between the two:</p> <pre><code> NSString* str=[NSString stringWithUTF8String:"aeiou"]; </code></pre></li> </ol> <p>If you want a string out of a call to an Apple script, you need to do the following:</p> <ol> <li><p>Prepare an <a href="http://developer.apple.com/mac/library/documentation/Cocoa/Reference/Foundation/Classes/NSAppleScript_Class/Reference/Reference.html" rel="nofollow noreferrer"><code>NSAppleScript</code></a>:</p> <pre><code>NSDictionary* errorDict; NSAppleScript* script=[[NSAppleScript alloc] initWithContentsOfURL:[NSURL fileURLWithPath:@"path/to/script" ] error:&amp;errorDict]; </code></pre></li> <li><p>Execute and get a reply:</p> <pre><code>NSAppleEventDescriptor* desc=[script executeAndReturnError:&amp;errorDict]; NSString* result=[desc stringValue]; </code></pre></li> <li><p>Release the script:</p> <pre><code>[script release]; </code></pre></li> </ol> <p>Learn C &amp; <a href="http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/ObjectiveC/Introduction/introObjectiveC.html" rel="nofollow noreferrer">Objective-C</a> and have fun!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload