ltannous
18th October 2002, 06:42
I have create a session that alows the user to insert values. There is a form field on the form that displays a calculated value.
The value does not appear calculated until the user selects the refresh option in the menu bar. How can I modify my script to refresh this value immedialey.

Current script for this is field

field.effic:
before.display:

effic = (newavg/totlhrs)*100

Paul P
18th October 2002, 07:19
Dear Itannous,

I think it's better if you calculate effic as soon as the newavg and totlhrs are available, instead of waiting for the calculation to be done just before displaying effic.

So, as soon as the newavg and totlhrs are available, do this

effic = (newavg/totlhrs)*100
display("effic")

Rgds,
Paul

ltannous
18th October 2002, 21:56
That worked to display the efficiency, but I tried the same display("") for the other variables in the script and again I have to refresh to see the new values. Here is the original script

form.1:
init.form:
get.screen.defaults()

field.totlhrs:
before.display:

if wteff809.stndhrs(3) > 0
and wteff809.stndhrs(2)> 0
and wteff809.stndhrs(1)> 0
then

totlhrs =(wteff809.stndhrs(1) + wteff809.stndhrs(2)+wteff809.stndhrs(3)-
wteff809.stdbrk(1)-wteff809.stdbrk(2)-wteff809.stdbrk(3))/3

endif

if wteff809.stndhrs(3) = 0
and wteff809.stndhrs(2)> 0
and wteff809.stndhrs(1)> 0
then

totlhrs =(wteff809.stndhrs(1) + wteff809.stndhrs(2)-wteff809.stdbrk(1)-wteff809.stdbrk(2))/2

endif

if wteff809.stndhrs(3) = 0
and wteff809.stndhrs(2)= 0
and wteff809.stndhrs(1)> 0
then
totlhrs = wteff809.stndhrs(1)-wteff809.stdbrk(1)
endif

field.newavg:
before.display:

if wteff809.newhrs(3) > 0
and wteff809.newhrs(2)> 0
and wteff809.newhrs(1)> 0
then

newavg = (wteff809.newhrs(1)+wteff809.newhrs(2)+wteff809.newhrs(3)-wteff809.newbrk(1)-
wteff809.newbrk(2)-wteff809.newbrk(3))/3
endif

if wteff809.newhrs(3) =0
and wteff809.newhrs(2) > 0
and wteff809.newhrs(1) > 0
then

newavg = (wteff809.newhrs(1)+wteff809.newhrs(2)-wteff809.newbrk(1)-wteff809.newbrk(2))/2

endif

if wteff809.newhrs(3) =0
and wteff809.newhrs(2) = 0
and wteff809.newhrs(1) > 0
then

newavg = wteff809.newhrs(1)-wteff809.newbrk(1)
endif

|field.effic:
|before.display:

effic = ((newavg/totlhrs)*100)-wteff809.noneff
display("effic")

zacharyg
18th October 2002, 22:03
try refresh() ...

Try using refresh() at the end of each before.display subsection.

Paul P
19th October 2002, 03:46
Dear Itannous,

Since totlhrs and newavg are calculated, display() must be called upon completion of their calculation. I also agree with you and wish that if we put the calculation in before.display section then Baan will automatically display the result afterwards, but unfortunately this is not always the case.

Rgds,
Paul

ltannous
20th October 2002, 06:46
I have tried all the reply's posted, but stiill the same problem. After a field has had the data inputted, the totlhrs is not refreshed immediately.

Is there a fuction I can write to add a refres button to the session?

evertsen
20th October 2002, 10:03
In Maintain Forms (ttadv3100m000) use the Maintain Form Buttons feature and under Other Buttons select option 7 (find.data).

lsatenstein
20th October 2002, 16:08
From what I understood in this thread, you want the display updated after performing the input.

Then try this.

field.xxx:
after.input:
| calculate new value for field newvalue (as example)
display("newvalue") | may have to do this twice
display("newvalue")

You can get an update immediately after leaving the field.

binoy000
21st October 2002, 11:44
If you are doing a display after some actions and trying to get the refreshed fields automatically, it should be linked to key field /
key field component in the form uniquely representing the line

For E.g
If the form is
====================
pono | item | Calc fig
01 | A | x*y
====================
The key field is pono (comp of key field)

In the cript you do this simpe

field.pono:
after.display: |NOTE THIS LINE
calculate_calc_fig()
display("calc_fig") |Repeat for all fields that are getting hanged
|in the calucalte_calc_fig()

function calculate_calc_fig()
{
Here you do all calcualtions required /Fetching of fields
etc
}

And there is no need of a Refresh function |


Regards,
Binoy