Skip to main content
Community Expert
July 24, 2023
Question

Has anybody had any experience developing extendscripts for FrameMaker using chatgpt (or similar AI)

  • July 24, 2023
  • 1 reply
  • 250 views

I have read that one can use AI for generating code, but I have next to none experience with coding. I am merely curious as whether anybody has tried this with FrameMaker?

    This topic has been closed for replies.

    1 reply

    frameexpert
    Community Expert
    Community Expert
    July 24, 2023

    I have used ChatGPT for generating XSLT code, but not ExtendScript.

    Community Expert
    July 24, 2023

    There was a short discussion some time ago about generating a list of variables, so fiddled around with a prompt for that in ChatGPT. Doesn't seem to work though. And since I have no idea what I am doing, I can't trouble shoot it either. This is what it looks like:

     

    var doc = app.ActiveDoc;
    var variables = doc.GetVarFmtNames();
    var varList = "";

    for (var i = 0; i < variables.length; i++) {
    varList += variables[i] + ": " + doc.GetNamedVarFmt(variables[i]).Contents + "\n";
    }

    alert(varList);

    Bjørn Smalbro - FrameMaker.dk
    frameexpert
    Community Expert
    Community Expert
    July 24, 2023

    When it comes to FrameMaker ExtendScript, AI is dumb. Here is a smart solution:

    #target framemaker
    
    var varFmtList, doc, varFmt;
    
    varFmtList = [];
    
    doc = app.ActiveDoc;
    
    varFmt = doc.FirstVarFmtInDoc;
    while (varFmt.ObjectValid () === 1) {
        varFmtList.push (varFmt.Name + ": " + varFmt.Fmt);
        varFmt = varFmt.NextVarFmtInDoc;
    }
    
    alert (varFmtList.join ("\r"));