Assigning values to virtuals in a grid


Avgerinos
 

Hi magicians

I 'm facing the following problem:

I have an online task with a grid displaying a table. There are 3 more columns which correspond to virtual-variables, with their contents calculated (by record) on the fly.
The calculation is based on some database statistic-processing. All 3 values are related, so I can have all 3 values in one database-stats run.

The solution I found so far to display these calculated values correctly on the grid, was to create a 3 functions, each calculating a value and assigning it to each virtual.
My problem is that since I use 3 functions, I end up executing the statistic processing 3 times (instead of 1) and this is the cause for slow grid-drawing and navigation.

Any ideas to improve?

Thanks in advance
Avgerinos


Keith Canniff
 

If the 3 values can be calculated on one stats run, why not return the value as 1 string (function return) with 3 delimited values in it (let's say they are number values in string form), then use strtoken and strtokenidx to parse out the 3 values into the virtual variable columns?

1 function call, 1 database stats pass, 3 returned values.

Keith

-----Original Message-----
From: main@magicu-l.groups.io <main@magicu-l.groups.io> On Behalf Of Avgerinos
Sent: Monday, August 13, 2018 9:03 AM
To: main@magicu-l.groups.io
Subject: [magicu-l] Assigning values to virtuals in a grid

Hi magicians

I 'm facing the following problem:

I have an online task with a grid displaying a table. There are 3 more columns which correspond to virtual-variables, with their contents calculated (by record) on the fly.
The calculation is based on some database statistic-processing. All 3 values are related, so I can have all 3 values in one database-stats run.

The solution I found so far to display these calculated values correctly on the grid, was to create a 3 functions, each calculating a value and assigning it to each virtual.
My problem is that since I use 3 functions, I end up executing the statistic processing 3 times (instead of 1) and this is the cause for slow grid-drawing and navigation.

Any ideas to improve?

Thanks in advance
Avgerinos


Avgerinos
 

Hi Keith,

My problem is not how to get 3 values from a single function call (this was answered yesterday in this group, and the solution  was similar to the one you suggest )

The problem is that these 3 values are different for each record. How can I execute the calculating-program (or function)  on record-fetch of each record?

Regards
Avgerinos

On 13/8/2018 4:10 μμ, Keith Canniff wrote:
If the 3 values can be calculated on one stats run, why not return the value as 1 string (function return) with 3 delimited values in it (let's say they are number values in string form), then use strtoken and strtokenidx to parse out the 3 values into the virtual variable columns?

1 function call, 1 database stats pass, 3 returned values.

Keith

-----Original Message-----
From: main@magicu-l.groups.io <main@magicu-l.groups.io> On Behalf Of Avgerinos
Sent: Monday, August 13, 2018 9:03 AM
To: main@magicu-l.groups.io
Subject: [magicu-l] Assigning values to virtuals in a grid

Hi magicians

I 'm facing the following problem:

I have an online task with a grid displaying a table. There are 3 more columns which correspond to virtual-variables, with their contents calculated (by record) on the fly.
The calculation is based on some database statistic-processing. All 3 values are related, so I can have all 3 values in one database-stats run.

The solution I found so far to display these calculated values correctly on the grid, was to create a 3 functions, each calculating a value and assigning it to each virtual.
My problem is that since I use 3 functions, I end up executing the statistic processing 3 times (instead of 1) and this is the cause for slow grid-drawing and navigation.

Any ideas to improve?

Thanks in advance
Avgerinos








Frederik Soete
 

Hi Avgerinos,

If your program has a return value, and you want to fetch the returned value per record, why not insert into your dataview a virtual with init expression "CallProg('...'PROG, ...)" ?

We use that technique lots of times ever since V9. E.g. with a vector for multiple returned values.

Op ma 13 aug. 2018 15:51 schreef Avgerinos <mento@...>:

Hi Keith,

My problem is not how to get 3 values from a single function call (this
was answered yesterday in this group, and the solution  was similar to
the one you suggest )

The problem is that these 3 values are different for each record. How
can I execute the calculating-program (or function)  on record-fetch of
each record?

Regards
Avgerinos

On 13/8/2018 4:10 μμ, Keith Canniff wrote:
> If the 3 values can be calculated on one stats run, why not return the value as 1 string (function return) with 3 delimited values in it (let's say they are number values in string form), then use strtoken and strtokenidx to parse out the 3 values into the virtual variable columns?
>
> 1 function call, 1 database stats pass, 3 returned values.
>
> Keith
>
> -----Original Message-----
> From: main@magicu-l.groups.io <main@magicu-l.groups.io> On Behalf Of Avgerinos
> Sent: Monday, August 13, 2018 9:03 AM
> To: main@magicu-l.groups.io
> Subject: [magicu-l] Assigning values to virtuals in a grid
>
> Hi magicians
>
> I 'm facing the following problem:
>
> I have an online task with a grid displaying a table. There are 3 more columns which correspond to virtual-variables, with their contents calculated (by record) on the fly.
> The calculation is based on some database statistic-processing. All 3 values are related, so I can have all 3 values in one database-stats run.
>
> The solution I found so far to display these calculated values correctly on the grid, was to create a 3 functions, each calculating a value and assigning it to each virtual.
> My problem is that since I use 3 functions, I end up executing the statistic processing 3 times (instead of 1) and this is the cause for slow grid-drawing and navigation.
>
> Any ideas to improve?
>
> Thanks in advance
> Avgerinos
>
>
>
>
>
>
>
>
>





Keith Canniff
 

You initiate the function call in the Init of the virtuals, so they become part of the dataview and automatically populate the grid.

-----Original Message-----
From: main@magicu-l.groups.io <main@magicu-l.groups.io> On Behalf Of Avgerinos
Sent: Monday, August 13, 2018 9:51 AM
To: main@magicu-l.groups.io
Subject: Re: [magicu-l] Assigning values to virtuals in a grid

Hi Keith,

My problem is not how to get 3 values from a single function call (this was answered yesterday in this group, and the solution was similar to the one you suggest )

The problem is that these 3 values are different for each record. How can I execute the calculating-program (or function) on record-fetch of each record?

Regards
Avgerinos

On 13/8/2018 4:10 μμ, Keith Canniff wrote:
If the 3 values can be calculated on one stats run, why not return the value as 1 string (function return) with 3 delimited values in it (let's say they are number values in string form), then use strtoken and strtokenidx to parse out the 3 values into the virtual variable columns?

1 function call, 1 database stats pass, 3 returned values.

Keith

-----Original Message-----
From: main@magicu-l.groups.io <main@magicu-l.groups.io> On Behalf Of
Avgerinos
Sent: Monday, August 13, 2018 9:03 AM
To: main@magicu-l.groups.io
Subject: [magicu-l] Assigning values to virtuals in a grid

Hi magicians

I 'm facing the following problem:

I have an online task with a grid displaying a table. There are 3 more columns which correspond to virtual-variables, with their contents calculated (by record) on the fly.
The calculation is based on some database statistic-processing. All 3 values are related, so I can have all 3 values in one database-stats run.

The solution I found so far to display these calculated values correctly on the grid, was to create a 3 functions, each calculating a value and assigning it to each virtual.
My problem is that since I use 3 functions, I end up executing the statistic processing 3 times (instead of 1) and this is the cause for slow grid-drawing and navigation.

Any ideas to improve?

Thanks in advance
Avgerinos