NetTalk Central

Author Topic: NetWebSource procedure vs Source procedure  (Read 7747 times)

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11183
    • View Profile
NetWebSource procedure vs Source procedure
« on: June 08, 2009, 10:59:36 PM »
There seems to be some confusion about the difference between the NetWebSource procedure, and the normal Clarion source procedure type. The goal of this post is to remove that confusion.

Firstly, it should be noted, that a NetTalk serve is a normal Clarion procedure. As such you're perfectly able to create, and call, normal source procedures. If you want to use p_web method calls in the procedure then set the Prototype/Parameters of the source procedure to
(NetWebServerWorker p_web)

** You should use a Source procedure whenever you want to create reusable code, but code which does not explicitly send any HTML to the browser **

A NetWebSource procedure is exactly the same as a normal Clarion source procedure, except that it assumes that the result of this procedure is text to send to the browser. In other words, a NetWebSource is where you create re-usable code that will (usually) send something to the browser when it is called.

** You should use a NetWebSource _only_ when you plan to send stuff to the browser.

Cheers
Bruce

spot1701

  • Jr. Member
  • **
  • Posts: 77
    • View Profile
Re: NetWebSource procedure vs Source procedure
« Reply #1 on: June 09, 2009, 03:16:20 AM »
So is there any problem/overhead with using a netwebsource procedure for reusable code that  needs to access the session queue but does NOT need to send anything to the browser?
Thanks

Bryan

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11183
    • View Profile
Re: NetWebSource procedure vs Source procedure
« Reply #2 on: June 10, 2009, 10:01:55 PM »
Hi Bryan,

yes there is a problem. The problem is that there is generated code in the procedure that explicitly sends a packet to the browser. If this is called out-of-place it may result in effects you were not expecting.

So if you _do_ use a NetWebSource like this, then right-click, view source, examine your code in context, and make sure you RETURN before the packet is sent.

However this is a hack, and does not allow for possible future changes to the netwebsource template. It would be better to change to a Source if this is all you are doing. You can still access the Session Queue using the parameters I mentioned above.

You can change the template type for a procedure via the IDE menu. (Change Template Type.)

Cheers
Bruce