Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Calling a C function with a parameter in AppleScript Studio




On Mar 30, 2005, at 10:36 AM, Gerard Brochu wrote:

Hello,

I want to call a C function with a parameter in an AppleScript Studio application, I have look at in the developer examples for AppleScript Studio in the Multi-Language projet how to call a C function. In the project there is no parameter for the function, I need to know how to pass a string parameter.

How can I modify the Multi-Language.mm file to pass the parameter use in the following Script button ?

Here below are all the modified code from the Multi-Language projet that I use in my own projet.

---------------------- The Script button
on clicked theObject
tell window of theObject
-- Call the Objective-C method "nameForCLanguage" defined in "Multi-Language.h"
-- It in turn, will call a function defined in "C.h"
set contents of text field "MotDePasse" to call method "nameForCLanguage" with parameter "Language C"
end tell
end clicked




- (NSString *)nameForCLanguage;

Change this to
- (NSString *)nameForCLanguage:(NSString *)aString;


- (NSString *)nameForCLanguage

change this to match the prototype

- (NSString *)nameForCLanguage:(NSString *)aString


{
// This will create a string using the c string returned from the function call 'getNameForCLanguage' which is defined in "C.h" and is implemented in "C.c".
NSString *languageName = [NSString stringWithCString:getNameForCLanguage()]; // Return the language name.


Use the variable here..
NSString *languageName = [NSString stringWithCString:getNameForCLanguage([aString cString])];


    return languageName;
}

------------------------------------------------

Thank for your help,

no problem.

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-studio mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/applescript-studio/email@hidden

This email sent to email@hidden
References: 
 >Calling a C function with a parameter in AppleScript Studio (From: "Gerard Brochu" <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.