NetTalk Central

Author Topic: When to use what? Bruce?  (Read 5479 times)

Gregg Matteson

  • Jr. Member
  • **
  • Posts: 59
    • View Profile
    • Custom Program Solutions
When to use what? Bruce?
« on: July 05, 2007, 04:40:59 PM »
I use session variables to set local variables or form fields .

What I don't understand is, what is the p_web.SetValue(.. .  used for ? when do you use it and why? 

I realise the session variables are persistant across procedures . What's the difference between p_web.GetValue and p_web.RestoreValue ?

Certainly hope I'm not the only one that is confused about this.

Thank you very much,

Gregg
Kindest Regards,

Gregg Matteson

'Software that's actually easy to use'

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11179
    • View Profile
Re: When to use what? Bruce?
« Reply #1 on: July 06, 2007, 04:43:51 AM »
First RestoreValue:
This returns
a) The .GetValue (if it exists)
b) the .GetSessionValue (if it exists)
c) the "variable" value.

In that order.

It's typically used in the case where you want to do this:
if p_web.GetValue('x') exists then use the passed value, otherwise use the stored Session Value.

As to when you use stuff -ideally you should (almost) always be using the GetSessionValue.

The time to use RestoreValue is where you expect the item to possibly be passed as a parameter (in the URL or Post Data or cookie). If the parameter doesn't exist you want it to fall back on the Session Value.

Which is a vague answer I know -

Cheers
Bruce

Gregg Matteson

  • Jr. Member
  • **
  • Posts: 59
    • View Profile
    • Custom Program Solutions
Re: When to use what? Bruce?
« Reply #2 on: July 10, 2007, 08:04:35 AM »
Bruce,

Thanks that sort of helped.  Fortunately the pc app programming seems a bit boring in comparison so we'll just have to do a bit more tinkering.

Thank you for your time.

Gregg
Kindest Regards,

Gregg Matteson

'Software that's actually easy to use'

Rob Mikkelsen

  • Full Member
  • ***
  • Posts: 107
    • Yahoo Instant Messenger - flashpott
    • View Profile
    • Email
Re: When to use what? Bruce?
« Reply #3 on: July 13, 2007, 07:33:48 PM »
One place where I like to use the SetValue() command instead of the using the session queue is when I am writing source code to display HTML.  I design the HTML in an editor using hard values, then substitute the <!-- Net:V:Whatever --> in the code.  I clip the constructed HTML into pieces into the source HTML (which creates routines in the source), then before calling each routine I populate the value with p_web.SetValue('Whatever','This is the value to display'). 

It is quick to design the page, easy to populate (especially when looping through a table) and is not added to the session queue (and RAM overhead) until the user logs out since it disappears when the thread terminates.

Rob

Gregg Matteson

  • Jr. Member
  • **
  • Posts: 59
    • View Profile
    • Custom Program Solutions
Re: When to use what? Bruce?
« Reply #4 on: July 14, 2007, 04:15:44 AM »
Rob,

I don't recall any of the example apps showing this technique. If you have an example showing the use of this or would care to elaborate a bit more, I'd sure like to see it.

Thanks for your time,

Gregg Matteson
Kindest Regards,

Gregg Matteson

'Software that's actually easy to use'

Rob Mikkelsen

  • Full Member
  • ***
  • Posts: 107
    • Yahoo Instant Messenger - flashpott
    • View Profile
    • Email
Re: When to use what? Bruce?
« Reply #5 on: July 14, 2007, 08:32:51 AM »
Sure.  This is a pretty simple example, but I think it gets the point across.  Create the static page in your favorite HTML editor, then clip the sections and add it to the HTML tab on the source procedure.  This creates the routines that you call after setting the values.  If you want a different look, simply replace the HTML in the routines, keeping the <!-- Net:V:variables --> intact.

I am sure there are lots of different ways to get the same result, but this makes the HTML easier to manage.


[attachment deleted by admin]

Gregg Matteson

  • Jr. Member
  • **
  • Posts: 59
    • View Profile
    • Custom Program Solutions
Re: When to use what? Bruce?
« Reply #6 on: July 17, 2007, 07:41:07 AM »
Rob,

Thanks for the example. another way of looking at things.

To this point I've created the static pages in Dreamweaver CS3 using css. Then I add the <!-- Net:some procedure --> as needed. Will explore your approach as well.

Take care,

Gregg
Kindest Regards,

Gregg Matteson

'Software that's actually easy to use'