Home | News | Project page | Download | About | << Back
Server Side Scripting
Visual Basic Script and HTML code are combined in the same document having an SSC extension. We proudly call this PIASe scripting. To indicate server-side script you must use the <% and %> script block tag's. To indicate the insertion of a result from a PIASe expression into the HTML you must use the <%= and %> insertion tag's. When you start writing script you always begin with an block / insertion start tag (<% or <%=) and you end the script with an block / insertion end tag (%>).
A simple example:
<% Text = "Hello world" %> <html> <head> <title><%= Text %></title> </head> <body> <p><%= Text %></p> </body> </html> |
The script that's inside the script-tags will be evaluated at server-side and is never visible to the client. The blue marked HTML and the result of the two insertion tag's will be sent to the client. In the first tag the variable Text is assigned with the text "Hello world". The content of the variable is then inserted as the title of the document (second tag) and finally inserted as part of the body (third tag).
The client would see this as the source of the received document:
<html> <head> <title>Hello world</title> </head> <body> <p>Hello world</p> </body> </html> |
PIASe
PI (The initial name of the server CORE project) Active Script engine. This engine translates your server side script into code blocks that can be processed by Visual Basic Scripting. If you have CORE hands-on we'll assure you that PIASe is where you need to be to program a standard HTTP server just the way you want.
And indeed, It looks like ASP but it is not. In fact, it's Visual Basic Scripting for Windows, a VB6 preprocessor and a VB6 function library hooked together and named PIASe. No matter what level you're coding in, as long as it is VB you will have the ability to understand and change not only server side scripts but also the server itself!
PIASe script before preprocessing...
<html> <head> <title>Conditional building</title> </head> <body> <p>A If/Then:</p> <% SomeVal = 1234 Test = 2 If Test = 1 Then %> <p>Block one <%= SomeVal %></p> <% ElseIf Test = 2 Then %> <p>Block two <%= SomeVal %></p> <% Else %> <p>Block three <%= SomeVal %></p> <% End If %> <p>A For/Next:</p> <% For N = 1 to 10 If N > 4 Then %> <p>N = <%= N %></p> <% End If Next %> </body> </html> |
And after preprocessing...
'#PIASe: 1.0 '#dep: C:\SourceForge GNU OpenSource\DS\www\Page01.ssc; 19-12-2005 1:38:53
Dim Index Sub Main( PrePrepIndex ) Index = PrePrepIndex Out Index, "<html> " & vbCrLf '#inf:1 C:\SourceForge GNU OpenSource\DS\www\Page01.ssc Out Index, "<head> " & vbCrLf '#inf:2 C:\SourceForge GNU OpenSource\DS\www\Page01.ssc Out Index, "<title>Conditional building</title> " & vbCrLf '#inf:3 C:\SourceForge GNU OpenSource\DS\www\Page01.ssc Out Index, "</head> " & vbCrLf '#inf:4 C:\SourceForge GNU OpenSource\DS\www\Page01.ssc Out Index, "<body> " & vbCrLf '#inf:5 C:\SourceForge GNU OpenSource\DS\www\Page01.ssc Out Index, "<p>A If/Then:</p> " & vbCrLf '#inf:6 C:\SourceForge GNU OpenSource\DS\www\Page01.ssc '#inf:7 C:\SourceForge GNU OpenSource\DS\www\Page01.ssc SomeVal = 1234 '#inf:8 C:\SourceForge GNU OpenSource\DS\www\Page01.ssc Test = 2 '#inf:9 C:\SourceForge GNU OpenSource\DS\www\Page01.ssc If Test = 1 Then '#inf:10 C:\SourceForge GNU OpenSource\DS\www\Page01.ssc Out Index, " " & vbCrLf '#inf:11 C:\SourceForge GNU OpenSource\DS\www\Page01.ssc Out Index, "<p>Block one " Out Index, SomeVal Out Index, "</p> " & vbCrLf '#inf:12 C:\SourceForge GNU OpenSource\DS\www\Page01.ssc '#inf:13 C:\SourceForge GNU OpenSource\DS\www\Page01.ssc ElseIf Test = 2 Then '#inf:14 C:\SourceForge GNU OpenSource\DS\www\Page01.ssc Out Index, " " & vbCrLf '#inf:15 C:\SourceForge GNU OpenSource\DS\www\Page01.ssc Out Index, "<p>Block two " Out Index, SomeVal Out Index, "</p> " & vbCrLf '#inf:16 C:\SourceForge GNU OpenSource\DS\www\Page01.ssc '#inf:17 C:\SourceForge GNU OpenSource\DS\www\Page01.ssc Else '#inf:18 C:\SourceForge GNU OpenSource\DS\www\Page01.ssc Out Index, " " & vbCrLf '#inf:19 C:\SourceForge GNU OpenSource\DS\www\Page01.ssc Out Index, "<p>Block three " Out Index, SomeVal Out Index, "</p> " & vbCrLf '#inf:20 C:\SourceForge GNU OpenSource\DS\www\Page01.ssc '#inf:21 C:\SourceForge GNU OpenSource\DS\www\Page01.ssc End If '#inf:22 C:\SourceForge GNU OpenSource\DS\www\Page01.ssc Out Index, " " & vbCrLf '#inf:23 C:\SourceForge GNU OpenSource\DS\www\Page01.ssc Out Index, "<p>A For/Next:</p> " & vbCrLf '#inf:24 C:\SourceForge GNU OpenSource\DS\www\Page01.ssc '#inf:25 C:\SourceForge GNU OpenSource\DS\www\Page01.ssc For N = 1 To 10 '#inf:26 C:\SourceForge GNU OpenSource\DS\www\Page01.ssc If N > 4 Then '#inf:27 C:\SourceForge GNU OpenSource\DS\www\Page01.ssc Out Index, " " & vbCrLf '#inf:28 C:\SourceForge GNU OpenSource\DS\www\Page01.ssc Out Index, "<p>N = " Out Index, N Out Index, "</p> " & vbCrLf '#inf:29 C:\SourceForge GNU OpenSource\DS\www\Page01.ssc '#inf:30 C:\SourceForge GNU OpenSource\DS\www\Page01.ssc End If '#inf:31 C:\SourceForge GNU OpenSource\DS\www\Page01.ssc Next '#inf:32 C:\SourceForge GNU OpenSource\DS\www\Page01.ssc Out Index, " " & vbCrLf '#inf:33 C:\SourceForge GNU OpenSource\DS\www\Page01.ssc Out Index, "</body> " & vbCrLf '#inf:34 C:\SourceForge GNU OpenSource\DS\www\Page01.ssc Out Index, "</html> " & vbCrLf '#inf:35 C:\SourceForge GNU OpenSource\DS\www\Page01.ssc Out Index, " " & vbCrLf '#inf:36 C:\SourceForge GNU OpenSource\DS\www\Page01.ssc Out Index, "" End Sub |
The Visual Basic script above will be cached and can now be executed to produce the server output by calling server class module functions. Note that this conversion is not visible to the script programmer.
Below, The actual VB6 code fragment of the CORE procedure WWWRequest that is responsible for running the preprocessed Visual basic scripts.
iLoopCounter = 0 Do While ttsWSconnection(Index).RunScript <> "" iLoopCounter = iLoopCounter + 1 frmHomeWebmaster.PSC(Index).Reset frmHomeWebmaster.PSC(Index).AddObject "PiWS", clsPWwebserver, True frmHomeWebmaster.PSC(Index).AddObject "PiUDP", clsPWUdpLib, True frmHomeWebmaster.PSC(Index).AddObject "PiFW", clsPWfirewall, True frmHomeWebmaster.PSC(Index).AddObject "PiFIO", clsPWfileio, True frmHomeWebmaster.PSC(Index).AddObject "PiBase64", clsPWBase64, True frmHomeWebmaster.PSC(Index).AddObject "PiURLenc", clsURLenc, True frmHomeWebmaster.PSC(Index).AddObject "PiDateTime", _ clsPWdatetime, True frmHomeWebmaster.PSC(Index).AddObject "PiSession", _ clsPWsession, True frmHomeWebmaster.PSC(Index).AddObject "PiCommon", _ clsPWcommon, True frmHomeWebmaster.PSC(Index).AddObject "PiGlobal", _ clsGlobalMem, True frmHomeWebmaster.PSC(Index).AddObject "PiEncryption", _ clsEncryption, True frmHomeWebmaster.PSC(Index).AddObject "PiUsers", _ clsPWusers, True frmHomeWebmaster.PSC(Index).AddObject "PiHttpProxy", _ clsPwHttpProxy, True frmHomeWebmaster.PSC(Index).AddObject "PiIcmp", _ clsPwIcmp, True frmHomeWebmaster.PSC(Index).AddObject "PiCustom", clsPwIcmp, True frmHomeWebmaster.PSC(Index).AddObject "PiHex", clsHex, True sScriptFile = ttsWSconnection(Index).RunScript ttsWSconnection(Index).RunScript = "" clsPWfileio.LoadFile _ sScriptCode, _ tssProgInfo.PiRoot & sScriptFile, _ lLoadScriptError, _ True If left(sScriptCode, 5) = "<sfw>" Then sScriptCode = EncSfwFile(tssProgInfo.PiRoot & _ sScriptFile, sScriptCode) End If sScriptCode = PrePrep(Index, tssProgInfo.PiRoot & sScriptFile, _ sScriptCode, bIsPrepped, PrepErr, _ sPrepErrMsg) If PrepErr <> 0 Then Error PrepErr End If If bIsPrepped Then clsPWfileio.SetCache _ clsPWfileio.InFileCache(tssProgInfo.PiRoot & sScriptFile), _ tssProgInfo.PiRoot & sScriptFile, _ sScriptCode, _ True End If If lLoadScriptError = 0 Then frmHomeWebmaster.PSC(Index).AddCode sScriptCode End If frmHomeWebmaster.PSC(Index).Run "Main", Index If sScriptFile = ttsWSconnection(Index).RunScript Then 'Script recursion Error 5 Exit Do End If If iLoopCounter > 16 Then Error 5 Exit Do End If Loop
|
PIASe, VBS, VB6... This is our VB6 solution to create a server that is able to run dynamically and interatively server side scripts. It's up to you to make good use of the service.
Do you want to join and help us with the PIASe project to improve it? Write us a note.
Download
<< Back
|