IC5Notice: We have upgraded developerWorks Community to the latest version of IBM Connections. For more information, read our upgrade FAQ.
Topic
  • 4 replies
  • Latest Post - ‏2013-05-10T06:20:07Z by Adamarla
EHcnck
EHcnck
78 Posts

Pinned topic Eval_ (help needed)

‏2013-05-09T01:15:30Z |

Hello,

I'm getting an error when attempting to create the last column(dxl) was wondering what I'm overlooking; any help would be appreciated? Thank you.

-Jim

 

string EvalCode = "
void Metrics_Softdeleted_dxl()
{
    string viewName = \"Metrics_Softdeleted_dxl\"

    // delete existing columns
    Column c
    int i, n = 0
    for c in current Module do n++
    for i in 1:n do delete(column 0)

    // create columns
    i = 0

    c = insert column i++
    title(c, \"ID\")
    attribute(c, \"Object Identifier\")
    graphics(c)
    info(c)
    width(c, 50)
    justify(c, right)

    c = insert column i++
    title(c, \"Unit 1, 2, & 9 Lot 1, Lot 2, & Lot 3 Level 1 Hardware Requirements Specification\")
    main(c)
    width(c, 560)
    justify(c, left)

    c = insert column i++
    attribute(c, \"_Req Eval\")
    width(c, 160)
    justify(c, left)

    c = insert column i++
    attribute(c, \"_Req Type\")
    width(c, 160)
    justify(c, left)

    c = insert column i++
    attribute(c, \"_NC Req\")
    width(c, 160)
    justify(c, left)

    c = insert column i++
    attribute(c, \"_NC+ Req\")
    width(c, 160)
    justify(c, left)

    c = insert column i++
    attribute(c, \"_1E Req\")
    width(c, 160)
    justify(c, left)
    
    c = insert column i++
    title(c, \"Parent Object(s)\")
    dxl(c, \"// DXL generated by DOORS traceability wizard on 02 May 2013.\n// Wizard version 2.0, DOORS version 9.3.0.7\npragma runLim, 0\n/************************************\n    parsing\n*************************************/\nconst Regexp TempRegExp = regexp2 \".*/DIL/.*\"\n\nvoid showOut(Object o) {\n    Link l            = null\n    ModName_ otherMod = null\n    Object othero     = null\n    string disp       = null\n    Buffer s          = create () ; s = \"\"\n\n    for l in all(o->\"*\") do {\n        if(name(module(l)) == \"child2parent\"    ||\n           name(module(l)) == \"parent2child\"    ||\n           name(module(l)) == \"SDM\"            ||\n           name(module(l)) == \"See also\") continue\n        ModuleVersion otherVersion = targetVersion l\n        otherMod = module(otherVersion)\n        if (null otherMod || isDeleted otherMod) {delete otherVersion; continue}\n        othero = target l\n        if (null othero) {load(otherVersion,false)}\n        othero = target l\n        if (null othero) {delete otherVersion; continue}\n        if (isDeleted othero) {delete otherVersion; continue}\n        if (TempRegExp fullName(otherMod) \"\") {delete otherVersion; continue}\n        s += fullName(otherMod) \"\"\n        if (isBaseline(otherVersion)) {s += \" [\" versionString(otherVersion) \"]\"}\n        s += \"-\"\n        s += probeRichAttr_(othero,\"Absolute Number\", false) \"\"\n        s += \"\\\\tab \"\n        s += probeRichAttr_(othero,\"_Req Eval\", false) \"\"\n        s += \", \"\n        s += probeRichAttr_(othero,\"_Req Type\", false) \"\"\n        s += \"\\n\"\n        delete otherVersion\n    }\n    displayRich(\"\\\\pard \" tempStringOf(s))\n    delete s\n}\nshowOut(obj)\ndelete TempRegExp\n\")
    width(c, 800)
    justify(c, left)
    
    // module settings
    level(0)
    graphics(false)
    outlining(false)
    showTables(true)
    showDeletedObjects(true)
    showExplorer(current Module)

    // filtering
    Filter f = (attribute \"o_Metrics_Softdeleted_dxl\" == \"Accepted\")
    set(current Module, f)
    filtering on

    // save view
    save(view(viewName))
}

Metrics_Softdeleted_dxl()
"

string err = null
noError
    eval_ EvalCode
err = lastError
if (!null err) errorBox(err)

  • llandale
    llandale
    2960 Posts

    Re: Eval_ (help needed)

    ‏2013-05-09T15:03:10Z  

    It would help if you told us what the problem is.

    At first glance it does not seem to me you need to do this with "eval_".  But if you do, I point out that..

    • Attr-DXL code hard coded into another script needs to have double-quotes and slashes escaped.
    • Likewise for eval_ code

    Thus, attr-DXL hard coded into eval_ code that is hard coded needs to be double-escaped.  That is far too dificult for me to visualize so I cannot tell if you are actually doing that or not ... but it does not appear to me that you are doing that correctly.

    Perhaps assign your Attr-DXL to a variable, then print the contents of the variable and check it out.

    Another solution is to type in the Attr-DXL into a file, then have this script read the file and deploy it.

    -Louie

  • EHcnck
    EHcnck
    78 Posts

    Re: Eval_ (help needed)

    ‏2013-05-09T15:09:49Z  
    • llandale
    • ‏2013-05-09T15:03:10Z

    It would help if you told us what the problem is.

    At first glance it does not seem to me you need to do this with "eval_".  But if you do, I point out that..

    • Attr-DXL code hard coded into another script needs to have double-quotes and slashes escaped.
    • Likewise for eval_ code

    Thus, attr-DXL hard coded into eval_ code that is hard coded needs to be double-escaped.  That is far too dificult for me to visualize so I cannot tell if you are actually doing that or not ... but it does not appear to me that you are doing that correctly.

    Perhaps assign your Attr-DXL to a variable, then print the contents of the variable and check it out.

    Another solution is to type in the Attr-DXL into a file, then have this script read the file and deploy it.

    -Louie

    Hello,

    I thought using "Column" had memory issues meaning not being released; that's why I'm trying to use eval_? Thank you.

    -Jim

  • llandale
    llandale
    2960 Posts

    Re: Eval_ (help needed)

    ‏2013-05-09T15:26:36Z  
    • EHcnck
    • ‏2013-05-09T15:09:49Z

    Hello,

    I thought using "Column" had memory issues meaning not being released; that's why I'm trying to use eval_? Thank you.

    -Jim

    Are you creating 5K+ "Columns" in a single DXL?  If not don't worry about it.  I've got a script to copy Views and it creates LOTS of "Columns" in 1000 modules, and it runs fast enough.

    In any event, get it to work without "eval_", then add the extra levels of escaping and put it in eval_.

    -Louie

  • Adamarla
    Adamarla
    75 Posts

    Re: Eval_ (help needed)

    ‏2013-05-10T06:20:07Z  
    • EHcnck
    • ‏2013-05-09T15:09:49Z

    Hello,

    I thought using "Column" had memory issues meaning not being released; that's why I'm trying to use eval_? Thank you.

    -Jim

    I agree with Louie, don't worry about the "Column" leak unless it becomes a problem for you.

    It is a 'non-persistant' leak, so all is cleared up when the dxl ends. It is therefore of no real benifit to use eval_ in a script which does nothing before or after the eval_ call.

    1. The main code calls eval_
    2. The eval_ code runs an leaks 'Column'
    3. The eval_ ends and garbage collects 'Column'
    4. The main code resumes and ends

    vs

    1. The main code runs an leaks 'Column'
    2. The main ends and garbage collects 'Column'

    Also, noError before eval_ will not prevent runtime errors in the eval code. You could do this instead if you want:

    
    string s​Error = eval_("noError();\n" 
    EvalCode ";\nreturn_(lastError());")
    

    Adam

    Updated on 2013-05-10T06:20:49Z at 2013-05-10T06:20:49Z by Adamarla