Forums

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

Home Forum Omnis General Forum Calculate Row as List

  • Calculate Row as List

    Posted by Franco Maregotto on November 24, 2023 at 5:24 pm

    Ciao

    is there a quick way/trick to make Row just sqlclass_defined as iList, when iList has one or more lines but NO current line?

    This becomes annoying when I have to pass iList to a different method/windows receiving pRow. When I do this pRow is populated with the data of the first iList line, even if iList has no selected nor current line.

    I always have to set pList instead of pRow as receiver, then check if pList.$line=0 > Do Row.$clear()..

    Thank for any help!

    Franco

    Martin Obongita replied 6 months ago 5 Members · 4 Replies
  • 4 Replies
  • Dario L.

    Member
    November 24, 2023 at 5:28 pm

    I believe this is what you’re looking for:

    Do pRow.$copydefinition(pList)
  • Doug Easterbrook

    Member
    December 18, 2023 at 12:49 am

    why not call a function that refers to the list instead of passing a list to a row. It makes it far easier to process multiple items within the method being called and means you don’t have to move data arond

    eg .. suppose list has 18 rows, 4 selected.

    then you can do

    do list.$doMyMethod

    and then in $doMyMethod, you can

    if $cinst.$totc(#lsel)=0

    calculate pErrorMessage as ‘Select whatever rows you want to work on’

    quit method kfalse

    end if

    do $cinst.$first(ktrue) returns #F

    while flag true

    # do some things to the line in the list

    do $cinst.$next(0,ktrue) returns $F

    end while

    # we processed all selected lines in the list

    reasons:

    1) in the long run, far easier to simply act on one, or the selected set (or all, if you want) lines in the list.

    2) there isn’t any passing of list to row

    3) its far easier to keep the method within the table class so that other methods can use it. that way it can be used in many places

    4) it improves the opportunity to use inheritance

    5) the any updated values in the list ara available to the calling method so you can redraw the list on the window

    6) it gets rid of the need to define the row

    7) makes code cleaner and kind of forces you to put it in the right place

    8) lets you gang up multiple calls to process the list. eg

    do list.$editListContents (pErrorMessage) returns $F

    if flag false

    # oh boy, we had some errors, better display them

    quit method #F

    end if

    do list.$increaseSalary(10%)

    do list.$saveList

    hopefully that gives a germ on the idea.

    • Andreas Pfeiffer

      Administrator
      December 18, 2023 at 8:16 am

      Hi Doug,

      Excellent point!

      But I think if you want to call a method inside the list (which is great since it is encapsulated then) you would need to put that method into a table class where the list is derived from. Either the concrete class or it’s super class.

      Best,

      Andreas

    • Martin Obongita

      Member
      December 20, 2023 at 8:30 am

      Hi @Doug Easterbrook ,

      I’m following this discussion with interest. I have a similar challenge. I have created a datagrid in a subform to display list. The iDataList contained a variable column lIselected (Boolean) which I would then assign $ref.$selected as (kTrue). Multiple selection is allowed. Then pass this iDataList to the main form like this:-

      Do $cinst.$container().$getDataList(iDataList)

      This allows me to get the iDataList from the main form when I am in the second sub form for editing the selected row, like this:-

      Do $cwind.$getDataList Returns iDataList

      Is there a way I can get the iDataList from the first subform of displaying the list containing the selected rows without passing data around?

      I do apologize IF I have bombed the discussion. I could start a new thread IF this is the case.

      Kind regards

      Martin Obongita.

Log in to reply.