NetTalk Central

Author Topic: Question: Why NWS does not use Data as Clarion does?  (Read 4114 times)

jorgemir

  • Jr. Member
  • **
  • Posts: 71
    • View Profile
    • Email
Question: Why NWS does not use Data as Clarion does?
« on: May 18, 2009, 03:18:52 AM »
Hi. Sorry for my ignorance, but seems to me that would be so mucho easy to get into the data variables if we can simply use data as usual: Local and Global as in Clarion templates. p_web.GetValue(), p_web.SetSessionValue(), all this complex arrangement....Maybe template can use the data we put into Local-global Data and we users can forget about this?
I'm sure you have a good reason to do the way it does, but I can not understand. Could you please tell me? Maybe this way I can understand where use one and where use another?.
Thanks
Jorge

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11239
    • View Profile
Re: Question: Why NWS does not use Data as Clarion does?
« Reply #1 on: May 18, 2009, 05:49:00 AM »
Hi Jorge,

Global Variables:

A "Windows" program has one set of globals per user. In other words if 10 people run the program, there are effectively 10 exe's running, and each user has their own globals. What one user does does not affect what another user does.

In the web app, all 10 users are sharing the same exe. So if we just used globals then the things one user did would affect all the other users.

Local Variables:

A windows program opens a procedure, like a browse, and that procedure stays open for the life of the browse. ie for as long as the user can see it.

A web program opens the browse procedure, generates some html, then finishes. On the server the procedure is no longer running, even though the user continues to see it in the browser. If the user then makes some action - like clicking a Next button, a whole new request is sent to the server. A new thread starts, and the browse procedure is called again. One browse can end up running a dozen differet times, on different threads, performing different actions. Local variables would clearly be useless.

SessionValues are the web equivalent of "globals". They exist in scope across calls, and are "bound" to a particular via a SessionId. It doesn't matter if the user is logged in or not.

GetValues however are not really like Local variables. They're more like parameters. They are the values passed with that specific Web Request. They are not persistent. That's why you never _use_ a Value directly. Rather you copy it to the SessionQueue, using p_web.StoreValue, and then use the SessionQueue value.

Cheers
Bruce

jorgemir

  • Jr. Member
  • **
  • Posts: 71
    • View Profile
    • Email
Re: Question: Why NWS does not use Data as Clarion does?
« Reply #2 on: May 18, 2009, 03:56:55 PM »
Cristal clear. Thanks a lot for your answer, Bruce.
I need to get used to this, as I can not get the correct place to have the customer Id value and prime with it a new invoice.
Cheers.
Jorge

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11239
    • View Profile
Re: Question: Why NWS does not use Data as Clarion does?
« Reply #3 on: May 18, 2009, 09:54:06 PM »
Hi Jorge,

Explain a bit more what the users sees & does, and what you want to do as a result.

(Usually on a form the best place to prime stuff is the Priming Tab)

Cheers
Bruce

jorgemir

  • Jr. Member
  • **
  • Posts: 71
    • View Profile
    • Email
Re: Question: Why NWS does not use Data as Clarion does?
« Reply #4 on: May 19, 2009, 07:29:03 PM »
Exactly like the invoice that appears in accounting demo. I can not find where is the p_web.getvalue(Inv:id) primed. I see this statement at update invoice line, but I know it is coming from invoice browse. Where is it? Where at browse I can set the invoice number in order to get it stuffed at priming time when inserting a new invoice line? That is my problem right now, but eventually in any other place. Gee...I think I need to read the manual again !!! I'm so confused with all the new concepts revolving in this amazing tool. Anyway, I'm now getting results for my little crm application, but things like this are somehow showstoppers for me.
Thanks Bruce.
Jorge

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11239
    • View Profile
Re: Question: Why NWS does not use Data as Clarion does?
« Reply #5 on: May 19, 2009, 11:01:06 PM »
Hi Jorge,

The Invoice Number, in the Accounts demo, is an Auto-Numbered field. Thus it is primed automatically when the form is opened.

The Invoice Date field is also primed - This is done in the UpdateInvoices procedure, NetWebForm Settings button, Priming tab.

Cheers
Bruce