Find answers, ask questions, and connect with our
community all around the world.

Home Forum Omnis General Forum Nested lists/rows not being properly initialized?

  • Nested lists/rows not being properly initialized?

    Posted by Dario L. on October 1, 2018 at 9:36 am

    Hi all,
    Please have a look at this little chunk of code:
    ;iRow is an undefined Row variable
    Do iRow.$cols.$add("List";kList)
    Do iRow.$cols.$add("Row";kRow)
    This way I can create a list and a row within a list variable. This works without problems.
    Now I want to define the inner list and row just created:
    Do iRow.List.$cols.$add("Field1";kInteger;k32bitint)
    Do iRow.Row.$cols.$add("Field2";kCharacter;kSimplechar;20)
    But the result is not as expected, that is the columns are not being created.
    Now while playing around I’ve noticed something a little strange: if I inspect the iRow variable (via right click), the inner Row and List fields are present but shown as “Empty”.
    Now if I just highlight the “Empty” field with a mouse click, then switch the highlight to another field, it automatically changes to “Not Empty”.
    At this point, if I try to rerun the two lines of code above, they work properly and the columns appear.
    So, from what I can understand, if an inner row/list is “Empty” I cannot further define it, it seems like the field is there, but not fully initialized. The only way I found to make it work is to use the Calculate statement before doing anything else to the inner list/row.
    Calculate iRow.List as lList ; lList is a generic local list variable
    Do iRow.List.$cols.$add("Field1";kInteger;k32bitint) ;Now this works as intended
    This is kind of a workaround, the only problem is that I get a list with columns but I rather want an empty list to be defined at a later stage, so I’m wondering if there is a better way to handle this behavior, that is changing the state from “Empty” to “Not Empty” via code, not by mouse click.
    I’m on Omnis Studio v8.1.5
    Thank you in advance

    Dario L. replied 5 years, 4 months ago 2 Members · 3 Replies
  • 3 Replies
  • Dario L.

    October 1, 2018 at 9:54 am

    errata corrige: “This way I can create a list and a row within a row variable”

  • simonep

    October 4, 2018 at 2:48 pm

    Hi Dario,
    my workaround for your code problem:
    To init List
    Do iRow.List.$assign(list())
    To init Row
    Do iRow.Row.$assign(row())
    Do iRow.Row.$define()
    Row must re-defined by $define() because row() function initialized it with one column with name C1
    Enjoy your code.
    Simone P.

  • Dario L.

    October 8, 2018 at 1:24 pm

    Thanks for the answer,
    So I was right, the rows can’t be initialized implicitly when created as list/row fields.
    Thank you for your workaround, I came up with something similar so I think it could be a good idea to post it along with yours:
    Clear list (Hash lists) ;; better safe than sorry
    Do iRow.$cols.$add("ID";kInteger;k32bitint)
    Do iRow.$cols.$add("listValues";kList) ;; list field - still to be initialized
    Calculate iRow.listValues as #L8 ;; manual initialization
    Do iRow.listValues.$cols.$add("Data";kRow)

Log in to reply.