• Global community
    • Language:
      • Deutsch
      • English
      • EspaƱol
      • FranƧais
      • PortuguĆŖs
  • ę—„ęœ¬čŖžć‚³ćƒŸćƒ„ćƒ‹ćƒ†ć‚£
    Dedicated community for Japanese speakers
  • ķ•œźµ­ ģ»¤ė®¤ė‹ˆķ‹°
    Dedicated community for Korean speakers
Exit
0

FrameMaker 2019: Extract literal string values from F_StringsT array

Community Beginner ,
Mar 24, 2022 Mar 24, 2022

Copy link to clipboard

Copied

I am trying to pull out the values from F_StringsT array but i am not getting exact string values as i want.

In my case i have a variable colorType of type F_StringsT and if i use following code it return values as specified -

StringT test = colorType.val[0]; In this case value of test is  0x0F19D690
and value returned by *colorType.val[0]; is "81 'Q'" (within double qoutes).

What i want to get back is literal string "QRH".

 

Any help would be greatly appreciated.

 

Thanks in advance.

 

Views

182

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 ,
Mar 24, 2022 Mar 24, 2022

Copy link to clipboard

Copied

I am not exactly sure about this, but your colorType array is likely an array of Color objects or ids. So test would be a Color object id and that Color object has a StringT FP_Name property. I program in ExtendScript so my syntax might not be correct but I am familiar with the FrameMaker API object model.

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 Beginner ,
Mar 24, 2022 Mar 24, 2022

Copy link to clipboard

Copied

F_StringsT colorType;
F_AttributesT attrs = F_ApiGetAttributes(docId, hleId);

if (attrs.len)
{
for (size_t i = 0; i < attrs.len; i++)
{

if (F_StrIEqual(attrs.val[i].name, COLOR_TYPE))
{
colorType = F_ApiCopyStrings(&attrs.val[i].values);
break;
}
}

StringT test = colorType.val[0];

 

This is the exact code and colorType is an array of attribute values. So i want to extract the exact value of attribute as how it is shown in framemaker.

for example ColorType  = "QRH" This is how it is in framemaker and what i want is QRH.

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 ,
Mar 24, 2022 Mar 24, 2022

Copy link to clipboard

Copied

OK, I see what you are doing. Here is how I do it with ExtendScript. You may be able to adapt it for the FDK.

function getAttributeValue (element, name) {
    
    var attrList = element.Attributes, i = 0;
    
    for (i = 0; i < attrList.length; i += 1) {
        if (attrList[i].name === name) {
            if (attrList[i].values[0] !== undefined) {
                return (attrList[i].values[0]);
            }
        }
    }
}

 

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 ,
Mar 24, 2022 Mar 24, 2022

Copy link to clipboard

Copied

LATEST

Here is a chunk of C code that I found on my old system:

VoidT F_ApiCommand(IntT command)
{
  F_ObjHandleT docId, defId;
  F_ElementRangeT erange;
  F_AttributesT attrs;
  UIntT i = 0;

  docId = F_ApiGetId(FV_SessionId, FV_SessionId, FP_ActiveDoc);
  erange = F_ApiGetElementRange(FV_SessionId, docId, FP_ElementSelection);
  attrs = F_ApiGetAttributes(docId, erange.beg.parentId);
  if(attrs.len >0) 
    for(i = 0; i <attrs.len; i++)
    {
      if(attrs.val[i].values.len > 0)
        F_Printf(NULL, "Attribute %d: %s = %s.\n", i, attrs.val[i].name, attrs.val[i].values.val[0]);
      else
        F_Printf(NULL, "Attribute %d: %s. =NOVALUE!\n", i, attrs.val[i].name);
    }
  F_ApiDeallocateAttributes(&attrs);

  F_ApiAlert("Attribute check complete.", FF_ALERT_CONTINUE_WARN);
}

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