Searching Schemas

Kelly Burgess kellyb at montana.com
Wed Jan 27 11:28:09 UTC 2021


>Now what does it mean? 

The Do performs the expression, and discards the result (no Returns used).
The expression has two parts whose results are added together and ignored.

Part 1 defines a local list to return with matching schema names
> Do schemaList.$define(schemaName)

Part 2 is a sendall to all the schemas in the current library. (Udo's latest example also processes multiple libraries)
The sendall expression is in two parts whose results are added together and ignored.

Part 1 assigns the name of the current schema to a local, for use by the sendall in Part 2.
> +$clib.$schemas.$sendall(schemaName.$assign($sendallref.$name)

Part 2 is a sendall to all the current schema's columns ($ref.$objs), telling them to add their schema's name (assigned by the previous expression) to the schemaList, IF their name matches the pColumnName passed in.
>   +$ref.$objs.$sendall(schemaList.$add(schemaName),$ref.$name=pColumnName))

The $define and $assign expressions return true or 1.  The $sendall expressions return the count of objects the sendall acted on.  Those are the integers that are actually added together and ignored.

Adding expression results is a way to do several things at once.  Do name.$assign('Mike')+tea.$assign('Yes, please')+time.$assign(#T) Returns result --- will perform three assignments and return 3 in result, assuming all the $assigns return true.

Just beware of using things like $assign() inside a pick() because pick() executes all of its contained expressions before returning the indexed result, and that can perform assignments or methods you didn't expect would happen.

Kelly


> Quit method schemaList
> 
> Kelly
> 
>> On Jan 26, 2021, at 2:37 PM, Kelly Burgess <kellyb at montana.com> wrote:
>> 
>> Hi Dawid,
>> 
>> Here's another approach - pass in pColumnName, get a list back.  I'm still wondering if you could flatten all that into a one-liner with a $sendall...
>> 
>> Kelly
>> 
>> 
>> Do schemaList.$define(schemaName)
>> Do $clib.$schemas.$first() Returns schemaRef
>> While schemaRef
>> 	Do schemaRef.$objs.$findname(pColumnName) Returns colRef
>> 	If colRef
>> 		Do schemaList.$add(schemaRef.$name)
>> 	End If
>> 	Do $clib.$schemas.$next(schemaRef) Returns schemaRef
>> End While
>> Quit method schemaList
>> 
> 




More information about the omnisdev-en mailing list