NetTalk Central
NetTalk Web Server => Web Server - Ask For Help => Topic started by: Keith on April 17, 2014, 01:23:21 PM
-
I'm glad that 'there is no such thing as a dumb question' :)
I have a standard Browse and Form. When I 'Change' a record I need to perform some calculations in a Routine on the Form before the Form is displayed. I actually need to do the same calculations when selecting 'Add' and I found the 'Pre-insert 3 End' point where I could 'do CalculateStuff' and that works fine.
Which embed point can I use to 'do CalculateStuff' - the session variables have to already be set up.
Thanks for help.
Keith
-
>> I'm glad that 'there is no such thing as a dumb question'
I think it was in 2004 when I ended a session with the phrase;
"There are no stupid questions. <pause>. Only stupid people. <laughter>
The stupid people are the ones who don't ask the questions."
In this case, I'm not sure I understand the question...
>> I actually need to do the same calculations when selecting 'Add' and I found the 'Pre-insert 3 End' point where I could 'do CalculateStuff' and that works fine.
yes, that's the correct place.
>> Which embed point can I use to 'do CalculateStuff' - the session variables have to already be set up.
This part I don't understand.
cheers
Bruce
-
Sorry Bruce, that was not explained at all!
What I meant to ask was what is the embed point to 'do CalculateStuff' when the Action is 'Change'? The Session Variables need to be set up for the Form.
As I said it works fine for 'Insert' where I pre-populate fields ( 'Pre-insert 3 End' ).
Thanks.
Keith
-
There's a PreUpdate routine which performs the equivalent when the form is in Change mode.
Remember to right-click and choose "source" when embedding. It allows you to view the code in context (which would have made this answer obvious I think).
cheers
Bruce
-
Hi Bruce
I added the 'do CalculateTimes' at the 'PreUpdate/3 End' embed point - specifically:
! End of "On Update : Form begins"
p_web.SetSessionValue('Playpen_CurrentAction',Net:ChangeRecord)
p_web.SetSessionValue('Playpen:Primed',0)
! Start of "Pre Update After Primes"
! [Priority 5000]
do calculatetimes
! End of "Pre Update After Primes"
However, the 'Times' were calculated incorrectly and the reason was that the session variables for the form fields were not set.
On my form I have a 'Calculate' button. When the user presses this button the 'CalculateTimes' routine is executed and many fields on the Form are reset to the new values. the user will typically do this many times noting changes in acceleration, speed and distance. Because the form fields can be changed with every request my routine first of all gets all of the current form field values e.g sce:PowerkW = p_web.gsv('sce:PowerkW').
This works fine if the action is 'Insert' but fails on 'Change' because it looks as if the session variables have not been set. For example the value of p-web.gsv('sce;PowerkW') is 0 but the value of sce;PowerkW is 220.
So, have I done something wrong at the embed point or is there something else I am missing.
Thanks
Keith
-
the file record is set there. You can use the fields directly, or move them into the session queue there with
p_web.FileToSessionQueue(Customers)
Cheers
Bruce
-
Bruce - beautiful. Thanks.
I see now that this is explained in 'The Book' under 'Manipulating the Session Queue Data' and had I read it properly in stead of skimming I would have known. I also would have saved myself more because within the routine I reload the session queue individually (p_web.ssv) for 71 fields.
Cheers
Keith