Topic
  • 3 replies
  • Latest Post - ‏2012-12-05T17:48:40Z by llandale
MF2G_qaus_qazah
MF2G_qaus_qazah
20 Posts

Pinned topic Create tables between objects

‏2012-12-05T05:55:50Z |

I want to create table(with specified contents) after each object in module where
(Object."IsRequirement" ==true) .I am able to create tables successfully but after first table creation it give me error:"Cannot create an object inside table"
How can I move my obj pointer of loop to the very next object of newly created table.My code is inserting each table after first table and is stuck into endless loop.

Object o =null
Module mod = current
Object objTable = null
bool isreq = false
for o in mod do
{
isreq = o."IsRequirement"
if(isreq === true)
objTable=(o,8,2)
// fill up table contents with certain attribute values
}
Updated on 2014-01-06T14:23:05Z at 2014-01-06T14:23:05Z by iron-man
  • SudarshanRao
    SudarshanRao
    39 Posts

    Re: Create tables between objects

    ‏2012-12-05T08:02:36Z  
    How are you looping through the table cells? If you are using the variable 'o', then that might lead to problems since it's used in the outer loop.
    Try this -

    Object o =null
    Module mod = current
    Object objTable, objRow, objCell
    bool isreq = false
    for o in mod do
    {
    isreq = o."IsRequirement"
    if(isreq == true)
    {
    objTable=table(o,8,2)
    // fill up table contents with certain attribute values
    for objRow in table(objTable) do
    {
    for objCell in row(objRow) do
    objCell."Object Text" = "Test"
    }
    }
    }
  • Tony_Goodman
    Tony_Goodman
    270 Posts

    Re: Create tables between objects

    ‏2012-12-05T10:39:00Z  
    How are you looping through the table cells? If you are using the variable 'o', then that might lead to problems since it's used in the outer loop.
    Try this -

    Object o =null
    Module mod = current
    Object objTable, objRow, objCell
    bool isreq = false
    for o in mod do
    {
    isreq = o."IsRequirement"
    if(isreq == true)
    {
    objTable=table(o,8,2)
    // fill up table contents with certain attribute values
    for objRow in table(objTable) do
    {
    for objCell in row(objRow) do
    objCell."Object Text" = "Test"
    }
    }
    }

    Better to use a skip list so that your object manipulation is outside of the loop
     

    Object o = null
    Module m = current
    Skip requirements = create
    bool isReq = false
    Object objTable = null
     
    for o in m do
    {
        isReq = o."IsRequirement"
            
            if (isReq)
            {
                    put(requirements, o, o)
            }
    }
     
    for o in requirements do
    {
            objTable = table(o, 8, 2)
    }
    


    Tony Goodman, www.smartdxl.com

    Updated on 2014-01-06T14:23:20Z at 2014-01-06T14:23:20Z by iron-man
  • llandale
    llandale
    2986 Posts

    Re: Create tables between objects

    ‏2012-12-05T17:48:40Z  

    Better to use a skip list so that your object manipulation is outside of the loop
     

    <pre class="javascript dw" data-editor-lang="js" data-pbcklang="javascript" dir="ltr">Object o = null Module m = current Skip requirements = create bool isReq = false Object objTable = null for o in m do { isReq = o."IsRequirement" if (isReq) { put(requirements, o, o) } } for o in requirements do { objTable = table(o, 8, 2) } </pre>


    Tony Goodman, www.smartdxl.com

    if (isDeleted(o) or table(o) or row(o) or cell(o)) continue

    I'd be tempted to store objects in natural order:
    • int Sequencer = 0
    • ..
      • put(requirements, Sequencer++, o)
    -Louie