Highlighted

Is it possible to run an ExtendScript function from the FDK?

Enthusiast ,
Jan 24, 2017

Copy link to clipboard

Copied

I have created an ExtendScript function that builds and populates a ScriptUI dialog. It then opens a template selected by the user. This works well and does everything I want it to do. Now the problem is that I need to run it from an FDK menu. This ExtendScript function takes a single argument.

I though that F_ApiCallClient() would be the way to go, but it's not documented for that usage. Has anyone tried to do this and succeeded? Or perhaps I'm overlooking a really obvious way to do it?

Thanks

Ian

TOPICS
Scripting

Views

447

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Is it possible to run an ExtendScript function from the FDK?

Enthusiast ,
Jan 24, 2017

Copy link to clipboard

Copied

I have created an ExtendScript function that builds and populates a ScriptUI dialog. It then opens a template selected by the user. This works well and does everything I want it to do. Now the problem is that I need to run it from an FDK menu. This ExtendScript function takes a single argument.

I though that F_ApiCallClient() would be the way to go, but it's not documented for that usage. Has anyone tried to do this and succeeded? Or perhaps I'm overlooking a really obvious way to do it?

Thanks

Ian

TOPICS
Scripting

Views

448

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Jan 24, 2017 0
Engaged ,
Jan 24, 2017

Copy link to clipboard

Copied

Ian,

strange, we had the same question a week ago in FrameDev-Yahoo Group. So I can copy + paste:-)

There is not Chance to provide parameters with F_ApiCallClient(). One solution was to write a temporary file in your FDK Client and read this within your ES. I would recommend to write to JSON Format for more complex data structure, as you can use eval() to deserialize this data to an object model very easily.

Few year's ago, I implemented a solution with F_ApiHypertext which works very well:

In your plugin call following, where you call F_ApiCallClient now

F_Sprintf((StringT)message, "message ScriptingSupport Notification FA_Note_PreFunction: docid:<%d> sparm:<%s> iparm:<%d>", docId, sparm, iparm);

F_ApiHypertextCommand(0, message);

F_ApiHypertextCommand can be called anywhere in your script, of course. The message string doesn’t matter. You only need a rule in your script which can handle and parse this

In your script register for “Constants.FA_Note_PreHypertext” and implement Notify-callback which catches this Event

[…]

if (sparm.substring(0, “message ScriptingSupport Notification FA_Note_PreFunction:”.length) == “message ScriptingSupport Notification FA_Note_PreFunction:”)

{

    //FA_Note_PreFunction Notification was raised by fdk client

    OnHyperTextNotification(Constants.FA_Note_PreFunction, sparm) ;

}

[…]

function  OnHyperTextNotification(notification, str)

{

    var idxDocId = str.indexOf("docid:<") + "docid:<".length;

    var idxSParm = str.indexOf("sparm:<") + "sparm:<".length;

    var idxIParm = str.indexOf("iparm:<") + "iparm:<".length;

    var docid = str.substr(idxDocId).substr(0, str.substr(idxDocId).indexOf(">"));

    var sparm = str.substr(idxSParm).substr(0, str.substr(idxSParm).indexOf(">"));

    var iparm = str.substr(idxIParm).substr(0, str.substr(idxIParm).indexOf(">"));

     //invoke Notify or do anything else

    Notify (notification, docid, sparm, iparm) ;

}

I don’t know yet, if it’s possible to get a return value back from ES to FDK.

I hope this is useful

Markus

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jan 24, 2017 2
Enthusiast ,
Jan 24, 2017

Copy link to clipboard

Copied

Thank you Markus,

Ingenious, will try that tomorrow! 

Regards

Ian

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jan 24, 2017 0
Enthusiast ,
Jan 25, 2017

Copy link to clipboard

Copied

Hello Markus,

Once again thank you for the ideas. In the end I changed the scope of the script so that it created its own menu command. I will try your ideas later when I have more time.

Best regards

Ian

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jan 25, 2017 0
Mentor ,
Jan 25, 2017

Copy link to clipboard

Copied

That hypertext command solution is really very clever, Markus. I suspect that it is just a fortunate accident that FrameMaker allows this interaction between an FDK client and an ES script. Congratulations for finding it.

Russ

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jan 25, 2017 0