$loadcols $colcount

Martin Obongita martin.obongita at yahoo.com
Mon Apr 18 11:34:09 UTC 2022


 Hi Kelly,
I have incorporated this line in my code:  For fldLine from 1 to iSchemaCols.$linecount step 1
      If iSchemaCols.[fldLine].iIncludeCol    ## if this column is checked for export
        Calculate colName as iSchemaCols.[fldLine].iColName
        Do columns.$cols.$add(colName,kCharacter,kSimplechar)
      End If
  End For

If I place a breakpoint at line Do command, the list is not populating the colName column with data.What have I missed out?Note that I added a line: Do column.$define(colName) before the For loop
Also, I have an idea what these two command do.But, what is the difference between them?        Do columns.$cols.$add(colName,kCharacter,kSimplechar)
        Do columns.$addcols(colName,kCharacter,kSimplechar)

Rgds, Martin.



    On Monday, April 18, 2022, 11:07:34 AM GMT+3, Kelly Burgess <kellyb at montana.com> wrote:  
 
 Hi Martin,

> I could not figure out what you are trying to do in this line:
>  Calculate define as con("$definefromsqlclass('",tableName,"',columns,tSessionRef)")
>  Do outList.[define]

If you want to dynamically define a list, for example, it might be nice if you could

  Calculate cols as 'name,address,city,state,zipcode'
  Do peopleList.$define([cols])

But that doesn't work.  What does work is to include the notation verb in the string:

  Calculate cols as 'name,address,city,state,zipcode'
  Calculate define as con('$define(',cols,')')
  Do peopleList.[define]

So I was doing that, but with $definefromsqlclass().  Expanding the define variable produces

  Do outList.$definefromsqlclass('tPeople',columns,tSessionRef)

.. which allows me dynamic control over the table class name that I use in this generic export code.


> Is it possible to define a list from another list variable?

There's an old technique dating back to Omnis 5 or 7 that still works for ordinary lists, where you can use the Define list command and rather than supply a list of column fields, you can pass a list variable preceded by ^, and that will define a column for each list line, using the first list column as the name.

  Do colList.$define(colName)
  Do colList.$add('name')
  Do colList.$add('address')
  Do colList.$add('zip')
  Set current list dynamicList
  Define list {^colList}  ## dynamicList is now defined for name,address,zip

But I think the only way to do that for $definefromsqlclass() is by using the second parameter containing a row whose column names identify the subset of schema columns to use.  I think that you can also pass multiple column name parameters instead of a row, but I think you then lose the ability to pass any parameters through to your table class $construct.  So I use a row, or an empty second parameter if I want the complete set of the table's schema columns.  That way the session reference in the third parameter gets passed to my table superclass's $construct.

So if you're not interested in passing anything through to the table $construct, then you could adapt the define calculation above using $definefromsqlclass -

  Calculate define as con("$definefromsqlclass('",tableName,"',columns,tSessionRef)")

and instead of ending it with 'columns,tSessionRef' and building that columns row variable, you could just concatenate each of the user-selected columns onto the end, delimited by commas and closed with a ).

Kelly
_____________________________________________________________
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