Topic
  • 4 replies
  • Latest Post - ‏2013-10-24T18:18:03Z by llandale
llandale
llandale
3035 Posts

Pinned topic VooDoo get attr value

‏2013-10-23T15:26:18Z |

Can one of you VooDoo folks please re-write these 2 functions to do the work with eval_, and thus save string table space?

  • Buffer e_bufAttr = create()    // local to following function
  • void AppendAttrValue(Object in_oReq, string in_NameAttr, Buffer upd_bufBody)
  • {   setEmpty(e_bufAttr) 
  •     probeRichAttr_(in_oReq, in_NameAttr, e_bufAttr, true)   // richText with OLE
        combine( upd_bufBody, e_bufAttr, 0) // append to output buffer
  • }   // end AppendAttrValue()

 

  • void  WriteBuffer(Stream in_strm, in_bufResults)
  • {   // write buffer to Stream
  •     in_strm << in_bufResults
  • }  // end WriteBuffer()

I'm pretty sure I want to build the Eval_ string for each just once; and then simply execute it.  If I build the string for each call then I'm wasting a lot of string table space.  That may require clever global "Object" and "String" and "Buffer" variables for the 1st, and glbal "Stream" and "Buffer" for the 2nd.

-Louie

  • Mathias Mamsch
    Mathias Mamsch
    2147 Posts

    Re: VooDoo get attr value

    ‏2013-10-23T18:38:45Z  

    I am pretty sure you do not need eval_ for either of those functions. I am not sure why you use probeRichAttr_ instead of just reading the attribute value, but I am pretty sure that is the only source of waste in your code. Note that string table space is global, so it does not matter if you put it in an eval_ statement.

    Regards, Mathias

  • llandale
    llandale
    3035 Posts

    Re: VooDoo get attr value

    ‏2013-10-23T18:52:10Z  

    I am pretty sure you do not need eval_ for either of those functions. I am not sure why you use probeRichAttr_ instead of just reading the attribute value, but I am pretty sure that is the only source of waste in your code. Note that string table space is global, so it does not matter if you put it in an eval_ statement.

    Regards, Mathias

    You say the string table is "global" for this instance of DOORS?  Run a wasteful script and all subsequent scripts are affected?

    Well, was about to post a request for eval_ to do richTextFragment, which is very much wasting lots of space in the code as it is string only not Buffer.

    • e_bufAttr  = richTextFragment(tempStringOf(e_bufAttr), "", true)

    -Louie

  • Mathias Mamsch
    Mathias Mamsch
    2147 Posts

    Re: VooDoo get attr value

    ‏2013-10-24T10:58:39Z  
    • llandale
    • ‏2013-10-23T18:52:10Z

    You say the string table is "global" for this instance of DOORS?  Run a wasteful script and all subsequent scripts are affected?

    Well, was about to post a request for eval_ to do richTextFragment, which is very much wasting lots of space in the code as it is string only not Buffer.

    • e_bufAttr  = richTextFragment(tempStringOf(e_bufAttr), "", true)

    -Louie

    As far as I know yes. However the string table is not a huge issue until you start to put huge amounts of data in it. In this case it will also accounts for some slowdown of your DOORS interpreter. For your example code with the richTextFragment I would say, the best way to go with would be to remove the start of the RTF yourself using a few regexps and a Buffer to avoid having to put the whole module RTF in the string table.

    Regards, Mathias

  • llandale
    llandale
    3035 Posts

    Re: VooDoo get attr value

    ‏2013-10-24T18:18:03Z  

    As far as I know yes. However the string table is not a huge issue until you start to put huge amounts of data in it. In this case it will also accounts for some slowdown of your DOORS interpreter. For your example code with the richTextFragment I would say, the best way to go with would be to remove the start of the RTF yourself using a few regexps and a Buffer to avoid having to put the whole module RTF in the string table.

    Regards, Mathias

    Wrote a function to perform richTextFragent in eval_, and yes it seems to have no advantage over the simple call.  Started 2 DOORS instances, the 1st did the eval_ and the other didn't.  Both show memory useage of the doors.exe (as per taskmanager) about the same.

    perhaps I did something wrong.

    -Louie

    // Test eval_ for "richTextFragment"
    /*
    */
    pragma runLim, 0
    Buffer plc_RTFrag_bufValue = null,
     plc_RTFrag_bufTemp = null
    string plc_TRFrag_DxlCode = null

    //*************************************************
    void RTFrag_Init()
    {
     plc_RTFrag_bufValue = create()
     plc_RTFrag_bufTemp = create()

     plc_TRFrag_DxlCode =
    " Buffer bufValue = (addr_ " (int addr_ plc_RTFrag_bufValue )")
     Buffer bufTemp  = (addr_ " (int addr_ plc_RTFrag_bufTemp) ")
     setempty(bufTemp)
     bufTemp  = \"\"
     
     bufTemp  += richTextFragment(tempStringOf(bufValue))
    //print \"In Eval, lengths = \" (length(bufValue)) \"\\t\" (length(bufTemp)) \"\\n\"
     setempty(bufValue)
     bufValue = \"\"
     combine(bufValue, bufTemp, 0) // Restore value back into original Buffer
    " // end string plc_TRFrag_DxlCode

    //print plc_TRFrag_DxlCode "\n"
    } // end RTFrag_Init()

    //*************************************************
    void RTFrag_Make(Buffer upd_buf)
    { // Perform "richTextFragment" on the contents of the Buffer
     // Use "eval_" to do so
     if (null plc_RTFrag_bufValue) then RTFrag_Init()

     setempty(plc_RTFrag_bufValue)
     combine(plc_RTFrag_bufValue, upd_buf, 0)
     string ErrMess = eval_(plc_TRFrag_DxlCode)
     if (not null ErrMess) print "Error: " ErrMess
     setempty(upd_buf)
     combine(upd_buf, plc_RTFrag_bufValue, 0)
    } // end RTFrag_Make()


    bool DoEval  = confirm("Do Eval??")
    //*************************************************
    void Test(Buffer upd_buf)
    {
    // print "From>>[" tempStringOf(upd_buf) "]\n"
     if (DoEval) //
     then RTFrag_Make(upd_buf)
     else upd_buf = richTextFragment(tempStringOf(upd_buf))
    // print "To>>  [" tempStringOf(upd_buf) "]\n"
    } // end Test()


    //*************************************************
    void Test(Buffer in_buf, int NumLoops)
    {
     int i
     Buffer bufOrig = create()
     Buffer bufTemp = create()
     combine(bufOrig, in_buf, 0)

     for (i=0; i<NumLoops; i++)
     {  fSetEmpty(bufTemp)
        combine(bufTemp, bufOrig, 0)
        Test(bufTemp)
        bufOrig += "{z}" // Make it a slightly longer string.
     }
     print "DoEval = " DoEval "\t Lengths:  " (length(in_buf)) "\t" (length(bufOrig)) "\t" (length(bufTemp)) "\n"
    }


    RTFrag_Init()
    Buffer buf = create()

    buf = "{\\rtf1\\ansi\\deflang1024 ReqSE_ReportAllocs.dxl v1.1\\par \\tab for CI \\i \\b xyz\\par \\i0 \\b0 \\par \\tab Generated  \\tab 2013-Oct-11\\par \\par \\pardXX\\par}"

    Test(buf, 50000)