Notational equivalent of Define list

Doug Easterbrook doug at artsman.com
Sat Apr 17 19:42:45 UTC 2021


ok.  so I see the use case….    

and the effect is that you are going to change a bunch of your code to keep on using $definelist to use this feature because of DML.

which i take to mean, you are going to change all the code and so the case is just what are you going to change it from and what are you going to change it to.

I have no skin in the game for this one other than some sort of academic interest

kelly’s one liner is based on name (not object type - $objtype), so its cool, but not quite generic.

  Do vLst.$define('acct')+vLst.$cols.$remove(vLst.$cols.$findname('seq’))


to make it generic, what about a helper routine that might do something like

do vLst.$define(‘acct’)
do helpermethod.$removeseq(vLst)




where $removeseq, while not a one liner, can iterate the columns and remove based on object type

eg. 

$removeseq has param pList (field ref)

and it does something like

# find the column names in the list of typoe ’seq'
calculate tempList as pList.$makelist($ref.$name,$ref.$objType,$ref.$objSubType)
do templist.$search(templist.$objtype=kSequence,ktrue,kfalse,ktrue,ktrue)

#. process selected lines
do templist.$first(0) returns #F
while ktrue
Do plist.$cols.$findname(templist.$name) Returns colref
Do plist.$cols.$remove(colref)
 do templist.$next(0,ktrue) returns #F
end while



yes, it is a custom routine … but becomes a clear one liner as to what you are removing and the code is readable.   plus it fixes the notion that you want to remove those columns that are of type kSequence (which may or may not be called ’seq’)



as I said, I’ve no skin in this one — you do it your way.

I like the clarity of a common method so that I can use the technique to remove anything.   it is quite explicit .. and more to the point, it is easily debugged — and avoids making assumptions on ‘what did we call that variable’….  that kind of stuff.

its for when you need to fix the code after a late night of philosophical discussions at the conference.



stay well — sounds like Ontario is having some problems with latest virus outbreaks.


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

> On April 17, 2021, at 8:44 AM, Grzegorz (Greg) Pasternak <gpasternak at cogeco.ca> wrote:
> 
> Since it is weekend and I am in the mood ;-)
> 
> Let me start with this DML command:
> 
>>> Define list {acct,-acct.seq}
> 
> I found this interesting as it allows you to define the list by ommitting specific file field from the list definition.
> It happens that in this case it is ommitting sequence number field that is burried somewhere in the middle of file class definition (note: one could argue to place the sequence number field at the very first place in the file class definition to satisfy the personal desire for order, but it happens that it is where it is).
> 
> This code is used with import data from the text file for the purpose of doing insert and/or update in the datafile.
> As we know, the sequence number must be unique.
> The source file can have the data but does not necessarily guarantees uniqueness of the sequence number value, as matter of fact the creating party doesn't have to care about it, only the actual data elements are needed.  I understand that you can stipulate the "empty" placeholder in the record, but that is an extra step to take and creates potential issue when the placeholder is forgotten.
> 
> Once the list is populated you can load from list into CRB and insert without regard to the seq number, Omnis will take care of it if it is not storing any value.  If however CRB stores the seq value and the value is also already used then the insert fails.  
> 
> Now, getting to your next question, why do I even care about DML if "everybody" is using SQL.  Well, as you know, being victim of its own success means that there are still apps out there that use DML technology, generate some cash that is hard to ignore, and the solution is fitting the needs.
> However, I just happen to work with this code on the SQL side as well.  The changes are made to DML Omnis code, go through the converter that generates SQL version of the master library code.  The file classes are used to generate schema classes that match the description of all fields used, including sequence number that is converted into long int and remains unique.  The import method remains the same as in DML, the source file is loaded into list, then records are inserted into database.  Since this particular solution is based on converted code the concept of CRB still remains valid (lists still defined from file class rather than table classes bound to schema classes).  
> 
> Anyway, having said all the above, I just found it interesting the use of minus <acct.seq> in Define list {acct, -acct.seq}  -  this is a rather obscure use of Define list.
> So I was just wondering if notational equivalent exists for that since I routinely use Do vLst.$define() and don't have to make the list current in reversible block anymore.
> 
> Hope this helps.
> 
> Greg
> 
> 
>> On Apr 16, 2021, at 9:04 PM, Doug Easterbrook <doug at artsman.com> wrote:
>> 
>> out of interest….   why do you need to do this.
>> 
>> its easy enough to ignore a column in a list.
>> 
>> 
>> 
>> Doug Easterbrook
>> Arts Management Systems Ltd.
>> mailto:doug at artsman.com
>> http://www.artsman.com
>> Phone (403) 650-1978
>> 
>>> On April 15, 2021, at 7:56 AM, Grzegorz (Greg) Pasternak <gpasternak at cogeco.ca> wrote:
>>> 
>>> I have sent this to support but maybe I get quicker response from some of you guys:
>>> 
>>> I can rewrite the following code:
>>> 
>>> Begin reversible block
>>> Set current list vLst
>>> End reversible block
>>> Define list {acct}
>>> 
>>> as:
>>> 
>>> Do vLst.$define('acct')
>>> 
>>> However, how do I rewrite this code:
>>> 
>>> Begin reversible block
>>> Set current list vLst
>>> End reversible block
>>> Define list {acct,-acct.seq}
>>> 
>>> =========
>>> 
>>> Note, the code I would like to re-write as "one liner" notational equivalent defines the list from file class by ommitiing the sequence field name.
>>> 
>>> Greg
>>> _____________________________________________________________
>>> Manage your list subscriptions at http://lists.omnis-dev.com
>>> Start a new message -> mailto:omnisdev-en at lists.omnis-dev.com 
>> 
>> _____________________________________________________________
>> Manage your list subscriptions at http://lists.omnis-dev.com
>> Start a new message -> mailto:omnisdev-en at lists.omnis-dev.com 
> 
> _____________________________________________________________
> Manage your list subscriptions at http://lists.omnis-dev.com
> Start a new message -> mailto:omnisdev-en at lists.omnis-dev.com 



More information about the omnisdev-en mailing list