NetTalk Central

Author Topic: Embed point in a NetWebForm  (Read 4351 times)

Keith

  • Sr. Member
  • ****
  • Posts: 306
    • View Profile
    • Email
Embed point in a NetWebForm
« 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
Clarion 10.0.0 build 12799
NetTalk 9.31
StringTheory 2.65
InsightGraphing 2.27

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: Embed point in a NetWebForm
« Reply #1 on: April 18, 2014, 01:15:20 AM »
>> 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


Keith

  • Sr. Member
  • ****
  • Posts: 306
    • View Profile
    • Email
Re: Embed point in a NetWebForm
« Reply #2 on: April 18, 2014, 02:13:50 PM »
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
Clarion 10.0.0 build 12799
NetTalk 9.31
StringTheory 2.65
InsightGraphing 2.27

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: Embed point in a NetWebForm
« Reply #3 on: April 18, 2014, 10:37:28 PM »
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

Keith

  • Sr. Member
  • ****
  • Posts: 306
    • View Profile
    • Email
Re: Embed point in a NetWebForm
« Reply #4 on: April 20, 2014, 12:53:52 AM »
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
Clarion 10.0.0 build 12799
NetTalk 9.31
StringTheory 2.65
InsightGraphing 2.27

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: Embed point in a NetWebForm
« Reply #5 on: April 21, 2014, 10:44:59 PM »
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

Keith

  • Sr. Member
  • ****
  • Posts: 306
    • View Profile
    • Email
Re: Embed point in a NetWebForm
« Reply #6 on: April 22, 2014, 01:23:07 PM »
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

Clarion 10.0.0 build 12799
NetTalk 9.31
StringTheory 2.65
InsightGraphing 2.27