Skip to main content
Participating Frequently
March 24, 2022
Question

FrameMaker 2019: Extract literal string values from F_StringsT array

  • March 24, 2022
  • 2 replies
  • 290 views

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.

 

    This topic has been closed for replies.

    2 replies

    Participating Frequently
    March 24, 2022

    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.

    frameexpert
    Community Expert
    Community Expert
    March 24, 2022

    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]);
                }
            }
        }
    }
    

     

    frameexpert
    Community Expert
    Community Expert
    March 24, 2022

    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.