passing row()

Doug Easterbrook doug at artsman.com
Thu Jul 28 15:43:24 UTC 2022


hi Martin.

Like Ben, ee pass rows around as parameters.

whether you want to use the calculate before you pass back the row, or not, is a matter of your personal practice.

i.e. is this better

Calculate lRow as row(lVar1,lVar2,lNum1,lNum2)
Quit method lRow

than 

Quit method row(lVar1,lVar2,lNum1,lNum2)


no,  not really.



this is an ancillary thought.   One things omnis doesn’t provide for you is the ability to create rows with dynamic content.

example

the input to a method might be a row with Var1,Var2 and perhaps other variables, that you might not know about)

you might want to pass back Var1,Var2 (and perhaps other variables) PLUS two new variables (or replace existing variables in the row)

the theory is that parameters can be passed down the call sequence.    (its done often in python.



if such is the case - yopu want to add your return variables to an existing row, the the FIRST option is better.


eg.

if condition 1 is true then
  Calculate lRow as row(lVar1,lVar2,lNum1,lNum2,lDate1,ldate2)
else
 TMobjs.$makeParameterRow()
end if

Quit method lRow




now, thats a lot of conditional stuff to make dynamic rows…...



for those of you who use TMObjs (freely available external) to construct rows, you can create rows dynamically by concatenating two rows and/or adding variables to an existing row.  makes the above easier

eg

TMobjs.$makeParameterRow()
calculate lRow as TMobjs.$makeParamRow(‘lVar',lVar2,’lNum1’,lNum2)
if condition 1 then
 # append variables to an existing row
  calculate lRow as TMobjs.$makeParamRow(lrow,'lDate1',ldate2)
end if


that kind of thing.



since we do that a fair bit to pass a row of parameters onwards, we prefer the first approach.





Doug Easterbrook
Arts Management Systems Ltd.
mailto:doug at artsman.com
http://www.artsman.com
Phone (403) 650-1978

> On Jul 28, 2022, at 4:53 AM, Martin Obongita via omnisdev-en <omnisdev-en at lists.omnis-dev.com> wrote:
> 
> Hi ALL,
> I have another issue similar to global variables and best practice.I see programmers store variables in a row before passing them over.
> For example:
> 
> Calculate lRow as row(lVar1,lVar2,lNum1,lNum2)
> 
> Quit method lRow
> 
> 
> Why not simply pass the variables as a row this way?Quit method  row(lVar1,lVar2,LlNum1,lNumb2)
> I hope I am not jamming the list with unnecessary stuff.
> Kind regards,Martin Obongita.
> _____________________________________________________________
> Manage your list subscriptions at https://lists.omnis-dev.com
> Start a new message -> mailto:omnisdev-en at lists.omnis-dev.com 



More information about the omnisdev-en mailing list