• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Get a list of active structured applications

Community Expert ,
Oct 04, 2019 Oct 04, 2019

Copy link to clipboard

Copied

Is there a way to get a list of the current structured application names currently in memory with ExtendScript? I didn't find a similar property in the FDK docs and wonder if this list is exposed to ExtendScript. Thanks.

TOPICS
Scripting , Structured

Views

293

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
community guidelines
Mentor ,
Oct 07, 2019 Oct 07, 2019

Copy link to clipboard

Copied

Hi Klaus,

 

The FDK has a secret property, FP_StructuredApplicationList, which was discussed here (not sure if you can read this thread):

 

https://groups.yahoo.com/neo/groups/Frame_dev/conversations/topics/1110

 

It is referenced in the ExtendScript documentation in the list of constants, but nothing further. I could not get it to work, so maybe it is not implemented. I tried things like:

 

app.StructuredApplicationList

 

..and

 

var params = app.GetProps();
var index = GetPropIndex(params, Constants.StructuredApplicationList);
... something with params[index].propVal.ssval ...

 

I also tried Contants.XMLStructuredApplicationList which is also referenced in the docs. Nothing worked. I suspect it is not implemented. But I don't really know.

 

Russ

Votes

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
community guidelines
Community Expert ,
Oct 07, 2019 Oct 07, 2019

Copy link to clipboard

Copied

LATEST

Thanks Russ. Instead of worrying about the required structured application being loaded, I am basically doing this:

 

  1. Create a custom struct apps xml file on the fly with ExtendScript's XML object.
  2. Save this file to disk and open it with FrameMaker.
  3. Use FmDispatcher to read it into memory. Now I know that my custom struct app is available.
  4. Open the XML document that requires the custom struct app.
  5. After I am done processing my file, I read the default user structapps.fm file back into memory.

 

I have to do some more testing, but this looks like it will be a good solution. I am trying to avoid having my users update their structapps.fm file for some of my scripts. Here is the basic shell.

 

 

#target framemaker

var structapps, file, structfile, doc;

// Make a custom structapps file.
structapps = makeStructappsFile ("JMCC_AMM_TOC");
file = File (File ($.fileName).path + "/_structapps.xml");
// CP.saveXmlFile not shown.
structfile = CP.saveXmlFile (structapps, file);
// Read it into memory.
readApplicationDefinitions (structfile.fsName);

// Open the xml file that uses the custom structapps file.
// ... Process the resulting fm file ...

// Restore the default user structured applications.
file = (app.UserSettingsDir + "\\structapps.fm");
readApplicationDefinitions (file);

function makeStructappsFile (name) {
    
    var structapps, appfolder;
    
    appfolder = new File ($.fileName).fsName.replace (/[^\\]+$/, name + "\\");
    
    structapps = <StructuredSetup>
        <Version/>
        <XMLApplication>
            <ApplicationName>{name}</ApplicationName>
            <DOCTYPE>{name}</DOCTYPE>
            <DTD>{appfolder}{name}.dtd</DTD>
            <Template>{appfolder}{name}_Template.fm</Template>
            <ReadWriteRules>{appfolder}{name}_RW.fm</ReadWriteRules>
            <Entities>
                <Public>
                    <PublicID>{name}</PublicID>
                    <FileName>{appfolder}{name}.dtd</FileName>
                </Public>
            </Entities>
            <Stylesheets>
                <XSLTPreferences>
                    <PreProcessing>
                        <Stylesheet>{appfolder}{name}.xsl</Stylesheet>
                    </PreProcessing>
                </XSLTPreferences>
            </Stylesheets>
        </XMLApplication>
    </StructuredSetup>;
    
    return structapps;    
}

function readApplicationDefinitions (name) {
    
    var doc;
    
    doc = CP.getDocument (name, undefined, false);
    if ((doc) && (doc.ObjectValid () === 1)) {
        CallClient ("FmDispatcher", "ReadAppFile " + doc.id);
        if (doc.openedByScript === true) {
            doc.Close (true);
        }
        return true;
    }
}

 

Votes

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
community guidelines