Cool Things About Table Classes

jmv jmvoegeli at bluewin.ch
Tue Aug 30 05:44:50 UTC 2022


Thanks Das.
That was very helpful.
Jean-Marc

> Le 29 août 2022 à 22:06, Das Goravani <goravanis at gmail.com> a écrit :
> 
> 
> I was going over the tech notes and noticed one about Object Classes verse Table Classes and gleaned the following from it.
> 
> I am not familiar with placing calls to methods as variables in an equation, but it can be done with Table Class methods
> 
> For example:
> 
> If myRow.$checkFields()
>    Do myRow.$insert()
>  Else
>    OK message "Data is not valid"
>  Endif
> 
> $checkFields would be just a simple method that would check the users input into the fields on the form or window, and would return a boolean True or False stating whether the input was acceptable to continue or not. 
> 
> Here the Table Class method myRow.$checkFields() is being called as if it is a variable. In fact it is it’s Return Value that is being read. So by putting a Quit Method Flag True or False method as the conclusion of your called method, you are setting up a boolean that can be read in an If statement as above. 
> 
> Here’s another example of using a Method where normally you’d think variable
> 
> Ok message "Could not load data: [myList.$getErrorText()]
> 
> $getErrorText()
> 
>  Quit method $cinst.$statementobject().$nativeerrortext()
> 
> Thus this is a way where methods become "get" functions for values that are found up inside the table class. 
> 
> Of course Table methods can be called in any Do statement like:
> 
> Do myRow.$myTableMethod() Returns myReturnField
> 
> Table Classes are either a row or a list. They ARE the row or list. Therefore $cinst refers to the row or list if you say $cinst inside a table class. 
> 
> If you say $cinst.$myMethodName() it will search inside it’s Table Class for that method name and run it. 
> 
> Table Classes have their own internal statement object which is derived from assigning the session object to the table class. Which is best done in the $construct of the Table SuperClass that all your table classes are linked to. 
> 
> Do $cinst.$sessionobject.$assign(tMySessionObject)
> 
> Once you’ve done that you can refer to the statement object that is inside the table class like this:
> 
> $cinst.$statementobject.$nativeerrortext (for example)
> 
> If you assign this internal statement object to a variable, then you can list the properties of the statement object including error text in the debugger (I think)
> 
> By referring to the statement object in this way, you are not placing a name in your code which can change rendering the code obsolete. 
> 
> The $definefromSQLClass() method has additional parameters which are the columns you want in your list. For example:
> 
> Do myList.$definefromsqlclass($tables.T_Address,'Name','Firstname','City','ADDRESS_ID')
> 
> That way, if you set up less than the total columns in the table, you are enhancing the speed of your app. Take just what is necessary whenever possible. When you do this, the built in table methods use only the fields you have specified and thus become fast methods too. You don’t need to write your own standard methods as much this way. 
> 
> $sqlerror() is a table method that is called upon SQL errors that occur in the table methods. You can override it and make any SQL error handler that you want. 
> 
> When you define from a Table Class, it’s construct is called at that defining instant. You can place things in construct that initialize your list or row such as this line
> 
> Do $cinst.$cols.ident.$excludefrominsert.$assign(kTrue)
> 
> You would also assign the session object to $cinst.$sessionobject
> 
> These can be put into the master table class in generic syntax so that they always apply
> 
> Each and every call to a Table Class construct that is under the super class will pass to the superclass and those few lines of code will be done thus instantiating all rows and lists with those things. 
> 
> 
> 
> 
> _____________________________________________________________
> 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