Skip to main content
Ian Proudfoot
Legend
January 24, 2017
Question

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

  • January 24, 2017
  • 4 replies
  • 672 views

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

This topic has been closed for replies.

4 replies

Inspiring
January 24, 2017

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

Ian Proudfoot
Legend
January 24, 2017

Thank you Markus,

Ingenious, will try that tomorrow! 

Regards

Ian