For the applications developer S/Web provides a wealth of routines to make it easy to develop high quality web-based applications, but like with all journeys on the road to new development it all starts with a simple step.
The one fundamental concept to grasp is this - as a developer you are going to write a function that is callable from the Web and that will return HTML to the client that requested it. You don't need to concern yourself with who that client was, S/Web will handle that for you. You don't need to know which S/Web Server is processing your request -again that will be handled for you. All you need to do is return HTML. Simple or complex, embedded JavaScript or not it is still just HTML. You can call as many supporting routines from within your code as you want but at the end of the day you get a request in and you return HTML.
The way your program is going to be called from a web client is ultimately by the submission of a URL such as
http://localhost/scripts/sweb.dll/SWEB_HelloWorld
What this says is go to the server and tell S/Web to run the routine called SWEB_HelloWorld. Take what is returned and display it in the browser window.
Naturally this sort of thing can become a tad cumbersome so as a shortcut you can omit the SWEB - in this case the UL would like as follows :-
http://localhost/scripts/sweb.dll/HelloWorld
The same routine would still execute as S/Web automatically prepends the SWEB but there's a little less typing!
Now of course there are levels of complexity but in the first instance all you need to know about is that we have adapted an object based model and to return your first HTML document you must be aware of two system routines. These are
www_Set_Property and www_Exec_Method
So for our simple 'Hello World' example our S/Web Function would look as follows :-
Function SWEB_HelloWorld(Void)
call www_Set_Property('RESPONSE', 'TYPE', 'text/plain')
call www_Exec_Method('RESPONSE','SETCONTENT', 'HelloWorld', 1)
Return 0
As you can see we firstly set the type of the RESPONSE object to 'text/plain' to identify that this is not an HTML Document and we then use the www_Exec_Method routine to set the content of the response. The reason that we use a Method here rather than a Property is that with S/Web response content can be greater than 64 K so it is necessary to set it in stages!
[top]
