Odd result in table class from Calculate #1 = $cinst.C2
Doug Easterbrook
doug at artsman.com
Thu Mar 6 15:40:20 UTC 2025
hi Mike
using 'C2' to refer to a column in a list works for me 100% in a table class. I’ve been using code that refers to columns using column notation shortcuts for years (in table classes.
so, to verify, I put some test code inside the $update of my table class where $cinst refers to a specific line that is being updated. The following code returned the value that I’d set the variable to in a window
Calculate #1 as $cinst.C4
the 'C4' has nothing to do with being a proper SQL keyword at all. C4 is akin to referencing the column of a cell in a spreadsheet. The current line is always assumed so that C4 means column 4.
I also wrote a quick test to check all columns to make sure that variable type did not affect things. Works fine for integer, boolean, char, dates, as I’m just looking across all the columns
For #2 from 1 to $cinst.$colcount
Calculate #S2 as $cinst.C[#2]
End For
I rather suspect, like Rudolf mentions, that the $cinst.$line is not set. you can inspect that using
Calculate #6 as $cinst.$line
A potential possibility is that the omnis IDE is getting confused on what $cinst means and you may need to have omnis reparse the line. $cinst usually refers to the data in the list associated with the query class.
but you can also do things like do $cinst.$callAMethod, where the $cinst refers to the current class. Maybe omins is confusted and you need to retype the line as the tokenization for $cinst is broken.
anyway, bottom line:
$cinst refers to the current data (list) that is associated with the query/schema that is associated with the table class
$cinst.Cx refers to column 'x' for the current line in the list and it works
Doug Easterbrook
doug at artsman.com
Phone (403) 650-1978
> On Mar 5, 2025, at 1:01 PM, Mike Rowan <mgrowan at fastmail.com> wrote:
>
> Hi Rudolf
>
> Yes, I've been caught by that one before, but it's not the problem here. Kelly pointed out that an Omnis keyword like C2 is not recognised within SQL, so you may need to use:
> $cinst.[$cinst.$cols.2.$name]
>
> Regards
>
> On Wed, Mar 5, 2025, at 5:08 PM, Rudolf Bargholz wrote:
>> Hi Mike,
>>
>> Could it be, that $cinst is a list, and you have not set a current line? I have had cases in DEV where a row variable did not have a current line, but this is not the norm. Never found a clear reason why this happened. Where it happens, I just set the row line to 1 to ensure a line is set.
>>
>> Regards
>>
>> Rudolf Bargholz
>>
>> -----Ursprüngliche Nachricht-----
>> Von: omnisdev-en <omnisdev-en-bounces at lists.omnis-dev.com> Im Auftrag von Mike Rowan
>> Gesendet: Dienstag, 4. März 2025 23:38
>> An: OmnisDev List - English <omnisdev-en at lists.omnis-dev.com>
>> Betreff: Re: Odd result in table class from Calculate #1 = $cinst.C2
>>
>> The moment I hit send I had this thought:
>>
>> Is it because the table class doesn't know whether $cinst is a row or a list ?
>>
>> On Wed, Mar 5, 2025, at 9:04 AM, Mike Rowan wrote:
>>> In my custom $update in my base table class I have the following
>>>
>>> Calculate lvRow as $cinst
>>> # works as expected, all columns have the expected value
>>>
>>> Calculate #1 as $cinst.$colcount
>>> # works as expected
>>>
>>> Calculate #2 as $cinst.C2
>>> # $cinst.C2 is an integer, but this results in 0, an incorrect result.
>>>
>>> Calculate #3 as lvRow.C2
>>> # works as expected.
>>>
>>> Why do the last two calculations give different results? A bit spooky?
>>>
>>> Mike Rowan
>>> Mobile: 0417 812 509
>>> Email: mgrowan at fastmail.com
>>> _____________________________________________________________
>>> Manage your list subscriptions at https://lists.omnis-dev.com
>>> Start a new message -> mailto:omnisdev-en at lists.omnis-dev.com
>>>
>>
>> Mike Rowan
>> Mobile: 0417 812 509
>> Email: mgrowan at fastmail.com
>> _____________________________________________________________
>> Manage your list subscriptions at https://lists.omnis-dev.com
>> Start a new message -> mailto:omnisdev-en at lists.omnis-dev.com
>> _____________________________________________________________
>> Manage your list subscriptions at https://lists.omnis-dev.com
>> Start a new message -> mailto:omnisdev-en at lists.omnis-dev.com
>>
>
> Mike Rowan
> Mobile: 0417 812 509
> Email: mgrowan at fastmail.com
> _____________________________________________________________
> 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