Chapter Five - PixieWeb Documentation:
PICKBASIC programs as backservers for "PixieWeb".
Example 5-1 : User Registration
Example 5-2 : Tech Support/Help Desk knowledge base.
"User Registration" and "Tech Knowledge Base" are web apps running our
website.
http://mail.thetotal.co.nz:7301
To collect information from users and write it into a multivalue database, you need to have a BASIC program to talk to your asp scripts.
For VB programmers we provide a "universal backserver" PX.BACKSRV which works behind the scenes to support Pixie functions like "RRead", "WWrite", "Delete" and "Release". Web and other Apps can then be written completely in VBSCRIPT, VB and other COM-aware languages eg JAVASCRIPT.
PICKBASIC programmers can work PICKBASIC on the PICK-etc server. This chapter gives 2 examples of such an approach.
The first example form "Userrego.htm", with of course its secure script partner "Userrego.asp", collects registration details from web visitors and adds them flagged as "Prospects" into our customers file.
The 2nd example in this chapter comes from my colleague Andrew Rowntree. Andrew keeps his database of system and hardware support info and diaries as items of html text in PICK D3 and uses a DATABASIC program to talk to a modified version of the asp scripts covered in Chapter 4.
PICKBASIC backservers are an effective way for PICKBASIC programmers to produce sophisticated interactive apps. Responses from PICKBASIC backservers can be more clearly defined and delimited than from TCL Queries, and it is easy to send clearly defined values in response to prompting from the WebServer. In the following 2 chapters, 6 and 7, we take this approach further with our "Field-by-Field Methods" for interaction with existing as well as new apps.
Example 5-1: User Registration
Step 1: Front End.
The above excerpt from "UserRego.htm" is HTML coded rather than being a picture, so the source code should be accessible to you eg by using your browser menu "View" option. Depending on your web connection, it may even function for real.
"UserRego.htm" talks to .asp script "UserRego.asp" which in turn talks to DATABASIC program "ProspectsRego". NOTE the use of <TX> and </TX> to mark start and end of transmission from the backserver program. Listing the asp script first:
<% '-- UserRego.asp
' ASP Visual Basic script to handle I/O
' to specially written PICKBASIC Program "ProspectsRego"
' via communications module PixieWeb.dll
' 981230 JPC Use of TCL "logto" with Session("Account")
'-- Check that passwords are confirmed
sPassword1 = Request.Form("Password1")
sPassword2 = Request.Form("Password2")
If sPassword1 <> sPassword2 Then
s = "<HTML><BODY>"
s = s & "<H2> ERROR in PASSWORD entry, your 2 inputs are not
the "
s = s & " same so please enter them again...</H2>"
s = s & "<P><A HREF=""../pixieinfo/UserRego.htm"">"
s = s & "Try again</A>"
s = s & "<P><A HREF=""../default.htm"">"
s = s & "Back to Total Home
Page</A></BODY></HTML>"
Response.Write s
ElseIf Len(sPassWord1) > 0 And Len(sPassWord1) < 5 Then
' The sPassWord is optional, but if they are going
to do
' it then they've gotta get it right!
s = "<HTML><BODY>"
s = s & "<H2>ERROR in sPassWord entry</H2>"
s = s & "<P><H3>If you are entering a password, "
s = s & "please make it at least 5 characters long</H3>"
s = s & "<P><A HREF = ""../pixieinfo/UserRego.htm"">"
s = s & "Tryagain</A>"
s = s & "<P><A HREF = ""../default.htm"">"
s = s & "Back to Total Home
Page</A></BODY></HTML>"
Response.Write s
Else
'-- 981219 JPC Adapt for major change to PixieWeb
Dim Pixie
Set Pixie = Server.CreateObject("PixieWMA.clsAgent")
Pixie.TimeOut = 8
Pixie.Port = 23
Pixie.Host = "127.0.0.1"
Call Pixie.Connect ("{AUTO}")
Call Pixie.ExecuteET("john", ":")
Call Pixie.ExecuteET("john", "<<< Pick Systems")
Call Pixie.ExecuteET("term mm-mon", ":")
Call Pixie.ExecuteET("echo off", ":")
'PICKBASIC backserver program makes use of
'D3 statement "TCLREAD" giving us a fast one-step conversation.
'
' Derive a Customer ID from the Email address
' eg for "john@thetotal.co.nz" the ID will be "thetotal"
' NOTE that ProspectsRego will generate an alternative
' eg "thetotal2" if this ID is already inuse.
sRego = Request.Form("Email")
' 981222 Cope with users entering Email addresses without @ and .
On Error Resume Next
sID = Mid(sRego, Instr(sRego, "@") + 1)
sID = Left(sID, Instr(sID, ".") - 1 )
On Error GoTo 0
If Err = 0 Then
' Build the command string
sRego = sID& "|" & sRego & "|"
sRego = sRego & Ucase(Request.Form("LastName") ) &
", "
sRego = sRego & Request.Form("FirstName") & "|"
sRego = sRego & Request.Form("Organisation") & "|"
sRego = sRego & Request.Form("Password1") & "|"
sRego = sRego & Request.Form("Addr1") & "|"
sRego = sRego & Request.Form("Addr2") & "|"
sRego = sRego & Request.Form("Addr3") & ", "
sRego = sRego & Request.Form("Country") & "|"
sRego = sRego & Request.Form("Phone") & "|"
sRego = sRego & Request.Form("Fax") & "|"
sRego = sRego & Request.Form("URL")
' Send the work through in one line
Call Pixie.ExecuteET("ProspectsRego " & sRego,
"</TX>")
End If
End If
If Pixie.State = "ERROR" Or Err > 0 Then
' See note below on where the HTML code can be pasted from.
s = "<HTML><BODY>"
s = s & "<H1> ERROR in database communication,"
s = s & " please try again...</H1>"
s = s & "<P><A HREF=""../pixieinfo/UserRego.htm"">"
s = s & "Try again</A>"
s = s & "<P><A HREF=""../pixieinfo/Default.htm"">"
s = s & "Back to PixieWeb active pages</A>"
s = s & "<P><A HREF=""../default.htm"">"
s = s & "Back to Total Home
Page</A></BODY></HTML>"
Response.Write s
Else
Call Step2
End If
Response.End
'
'=== END of "script level" ie "main" program ==============================
Sub Step2
' The response from Pick is now available from Pixie
sConfirm = Pixie.Response
' Now to Transmit this back to the user
' The output statements below come from creating the
' desired output in Microsoft "FrontPage" TM Editor and saving
' it as a first step file with a name like "UserRegoAsp.htm"
' You use this for the next step with our utility "PixieMassage"
' which splits the code into short lines, fits "Response.Write"
' at the start of each line and puts in the necessary double-lots
' of speech marks. You can then paste the result into your script
' or use the resulting file "userregoasp.txt" as the starting
' point for a script. The more efficient "s = s & " output below
' comes from a further search-and-replace operation.
iPos1 = Instr(sConfirm, "<TX>")
iPos2 = Instr(sConfirm, "</TX>")
If iPos1 > 0 And iPos2 > iPos1 + 5 Then
s = "<html><head><title>Registration
Results</title></head>"
s = s & "<body><p ALIGN=""CENTER""><font
size=""4"">Registration "
s = s & "Confirmed</font>" sCode = Mid(sConfirm, iPos1 + 4,
iPos2 - iPos1 - 4)
s = s & "<p ALIGN=""CENTER"">Your Customer Code with us is "
s = s & "<p ALIGN=""CENTER""><font size=""5"">" &
sCode & "</font>"
s = s & "<p ALIGN=""CENTER""><strong><a
href=""../utilities/jpclinks.htm"">"
s = s & "Welcome to our
Downloads</a></strong></p><hr>"
Else
s = "<html><head><title>Registration
Failed</title></head>"
s = s & "<body><p ALIGN=""CENTER""><font
size=""4"">"
s = s & "Registration failed: " & sConfirm &
"</font></p>"
s = s & "<P><A HREF=""../pixieinfo/UserRego.htm"">"
s = s & "Try again</A><hr>"
End If
s = s & "<a HREF=""../pixieinfo/default.htm"">PixieWeb "
s = s & "active pages</a> "
s = s & " "
s = s & "<a HREF=""../totproducts.htm"">Products</a> "
s = s & " "
s = s & " "
s = s & "<a HREF=""../totprices.htm"">Prices</a> "
s = s & " " s = s &
" "
s = s & "<a HREF=""../default.htm"">Back to home page</a>"
s = s & " </p><hr><font
SIZE=""1""><p> </font>"
s = s & "<font size=""4"">Pixie Partners, "
s = s & " Middle Floor, 2163 Great North Rd,<br> "
s = s & "New Lynn, Auckland,<br>P.O. Box 15865, "
s = s & "New Lynn,<br> Telephone:(09) 8209331, "
s = s & "Fax: (09) 8281406,<br> "
Response.Write s
End Sub
' END of UserRego.asp
%>
And here is the DATABASIC program "ProspectsRego":
001 * Program ProspectsRego, backserver for PixieWeb
002 * 12 OCT 1998 JPC John Calder, The Total Computer Co
003 * Handles user registration over the Internet
004 * Start by opening Cust files
005 OPEN "Cust" TO Cust ELSE
006 * Error handler
007 PRINT "<TX>ERROR! Registration file is not
available</TX>"
008 STOP
009 END
010 CMD = ""
011 TCLREAD sCommand
012 iPos = INDEX(sCommand, " ", 1)
013 sProspect = sCommand[iPos + 1, 99999]
014 CONVERT "|" TO Char(254) IN sProspect
015 * Declare variable rCust by dummy reference
016 rCust = ""
017 * rCust as dynamic array mirrors structure
018 * of file Cust and acts as file buffer,
019 * similar to "Fields" or "Types" in QB, VB random access files
020 * and with some similarity to "recordsets" hence my use of the
021 * "r" prefix for it.
022 * PICK dynamic array implicitly declared by use of <>
023 * Its behaviour seems to compare to the VB concept of a "collection"
024 rCust<26> = sProspect<2> ;* Email Address -> Del Addr
025 rCust<9> = sProspect<3> ;* Name -> Contact
026 rCust<1> = sProspect<4> ;* Organisation -> Customer Name
027 rCust<19> = sProspect<5> ;* Password -> Order References
028 * Multivalues handled much like 2-D arrays
029 rCust<2,1> = sProspect<6> ;* Addr1
030 rCust<2,2> = sProspect<7> ;* Addr2
031 rCust<2,3> = sProspect<8> ;* Addr3
032 rCust<7> = sProspect<9> ;* Phone
033 rCust<8> = sProspect<10> ;* Fax
034 rCust<71> = sProspect<11> ;* URL -> Addr
035 rCust<11> = "P" ;* Classification
036 rCust<13> = "INTERNET" ;* Branch
037 * Declare incrementor for unique ID if necessary
038 i = 2
039 bLoop = 0
040 sID = sProspect<1>
041 * READV reads the ENTIRE file for a match with sID !!
042 * More like an SQL SELECT than a single-record reading of values.
043 * All variables are dynamic arrays with Index=1 when used
044 * in code expressions with Index=0 reserved for use with
045 * file operations eg READ
046 LOOP
047 IF bLoop THEN EXIT
048 READV sTemp FROM Cust ,sID ,1 THEN
049 sID = sProspect<1>:i
050 i = i + 1
051 END ELSE
052 bLoop = 1
053 END
054 REPEAT
055 * The A0 attribute of files and dynamic arrays is the item ID
056 * or key and as such plays a vital role in the syntax
057 * of eg WRITE hence the ", sID" in the WRITE below.
058 WRITE rCust ON Cust, sID
059 PRINT "<TX>":sID:"</TX>"
060 END
END of EXAMPLE 1: User registration.
Example 5-2 : Tech Support/Help Desk knowledge
base.
Front end: "techsearch.htm" is adapted by Andrew Rowntree from
my "booksearch.htm" :
Andrew's script "TechSearch.asp" :
<html> <head> <title>Results of
Technote Search</title> </head>
<body>
<%
'-- Adapted from BookSearch.asp
'-- ASP Visual Basic script to handle I/O
'-- to direct TCL conversations with D3 via module PixieWMA.dll
'-- Includes code to add "Internet Style" front end
'-- to PICK ACCESS search engine
'-- 990216 ADR Adapt for our technotes database
'-- 981219 JPC Rewrite to match interface of the new .dll
Dim Pixie
Set Pixie = Server.CreateObject("PixieWMA.clsAgent") < BR > Pixie.TimeOut
= 8
Pixie.Port = 23
Pixie.Host = "127.0.0.1"
Call Pixie.Connect("{AUTO}")
Call Pixie.ExecuteET("john", ":")
Call Pixie.ExecuteET("john", "<<< Pick Systems")
Call Pixie.ExecuteET("term mm-mon", ":")
Call Pixie.ExecuteET("echo off",":")
sQueryRaw = Request.Form("Query") < BR > '-- Check
for dummy entry
If sQueryRaw = "" Then
s = "<H2> INCOMPLETE ENTRY, please try again with something typed
"
s = s & "into the search fields...</H2>"
s = s & "<P><A HREF=""../support/technotes.htm"">Try
again</A>"
s = s & "<P><A HREF=""../default.htm"">" < BR >
s = s & "Back to Total Home Page</A>" < BR >
Response.Write s< BR > Else< BR > '--
Note function Searchstring at end of this file
sQueryRaw = SearchString(sQueryRaw)
sQuery = "techsearch " & sQueryRaw
Call PickQuery(sQuery)
End If < BR > '=== END OF "Script-level" ie Main
Program ===========================
'
Sub PickQuery(sQuery)
'-- DEBUG with next line, remove comment mark to activate
'Response.Write "<P>DEBUG: Query sent to PICK is:<BR>" & sQuery
'-- Page Header
Response.Write "<table width=""100%"" border=""3"" "
Response.Write " bordercolor=""#800080"" cellpadding=""3""> "
Response.Write "<tr>"
Response.Write "<td width=""65%"" bgcolor=""#008080"" border=""0"">"
Response.Write "<font size=4 color=""#FFFFFF"">The Total Computer
Company</font></td>"
Response.Write "<td width=""35%"" bgcolor=""#008000"" align=right
border=""0"">"
Response.Write "<font size=4 color=""#FFFFFF"">Technote Search
Results</font></td>"
Response.Write "</tr></table>" < BR> s= "<p><font
size= ""4"">Clickon anyTechnote formore details, or "< BR> s= s
&"<a href= ""../support/technotes.htm"">Try another
Search</a></p>"< BR> Response.Write s < BR>
Response.Write "<hr>" < BR> '-- 990112 using
a table for improved presentation
Response.Write "<table border=""2"" bgcolor=""#FFFFFF"" width=""100%"" "
Response.Write " bordercolor=""#800080"" cellpadding=""3""> "
Response.Write "<tr>"
Response.Write "<td width=""15%"" bgcolor=""#008080""><font
color=""#FFFFFF"">ID Code</font></td>"
Response.Write "<td width=""70%"" bgcolor= ""#008080""><font color=
""#FFFFFF"">Title</font></td>"< BR> Response.Write
"</tr>" Call Pixie.Execute(sQuery, "</TX>")< BR>
CallPixie.ResponseCleanup sResponse= Pixie.Response< BR >
'-- DEBUG with next line, remove comment mark to activate
'Response.Write "<pre>DEBUG PRINT raw response:<BR>" &
sResponse & "</pre>"
iPos = 0
'-- SPECIAL DEBUG TRICK to help when authoring with
NotePad
' Uncomment statement x = 1000/0 to create an error. Then the browser debugger
will
' tell us its line number giving us a reference point for other line number
references.
' x = 1000/0
If Pixie.State = "ERROR" Then
s = "<H3>ERROR in database communication,"
s = s & " please try again ... </H3>"
s = s & "<P><A HREF=""../support/techsearch.htm"">"
s = s & "Try again</A>"
s = s & "<P><A HREF= ""../default.htm"">" < BR >
s = s & "Back to The TotalHome Page</A>" < BR >
Response.Write s< BR > '-- DEBUG with next
line, remove comment mark to activate
'Response.Write "<P>DEBUG - raw Response:<BR>" &
sResponse
Else
Do
n = iPos + 2
iPos = Instr(n, sResponse, vbCrLf) < BR >
'-- DEBUG with next line, remove
comment mark to activate
'Response.Write "<BR>DEBUG.PRINT: s = " & s &
"<BR> n = " & n & " : iPos =" & iPos
'-- Divide PICK BACKSERVER ACCESS response into its
separate lines
' This is a case of an ACCESS query being run remotely for
us by a
' backserver DATABASIC program. The result is "cleaner"
than a direct
' run in that there are no stray non-printing characters to
deal with,
' so Andrew's analysis below is a little more
straightforward than
' the code you see in my earlier examples
s = Mid(sResponse, n, iPos - n) i40x = Instr(s, "[40")
If i40x > 0 Then < BR >
'-- We have reached the
end of the output
Response.Write vbCrLf s = Mid(s, i40x + 5 )
Response.Write "Results: " & s < BR >
'-- typical example of
output is:
' "Results: 4 items listed out of 4644 items."
Exit Do
End If
'-- Split ACCESS
Response line into column values
' the spacing-across values come from test-running
' the ACCESS query on a terminal
sCodeDisplay = Left(s, 4) sCode = Trim(sCodeDisplay)
< BR > '-- "If" block validates
ACCESS response lines
If Len(sCode) = 4 Then sTitle = Trim(Mid(s, 5))
' Write table row
Response.Write "<tr>"
Response.Write "<td width=""15%"">" &
sCodeDisplay& "</td>"
'-- Use of GET technique
for drill-down
Response.Write "<td width =
""70%"">"<BR> Response.Write"<AHREF=""techsearch2.asp?ItemID="
& sCode & """>"
Response.Write """" & sTitle &
"""</A>"
Response.Write "</td>"
End If
Loop < BR > End If < BR> Response.Write
"</table></font>"
'-- Standard bottom-of-page
s = "<p>" s = s & "<a
HREF=""../pixieinfo/default.htm"">PixieWeb active pages</a>"
s = s &
" "
s = s & "<a HREF=""../utilities/jpclinks.htm"">Downloads</a>"
s = s &
" "
s = s & "<a HREF = ""../totproducts.htm"">Products</a>"< BR
> s = s &
" "<
BR > s = s & "<a HREF = ""../totprices.htm"">Prices</a>" s =
s & " "< BR > s = s &"<a HREF=
""../default.htm"">Back to home page</a></p><hr>"< BR
> Response.Write s < BR > End Sub< BR > '/End
of Sub OutputRoutine '-------------------------------------------------------
'
'-- Function to interpret search strings in "internet style" for ' use in PICK
ACCESS sentences
' Allows for AND and OR in search routine.
' Start by stripping any leading and trailing spaces and
' wrapping the string in PICK general purpose symbols "[ ... ]"
Function SearchString(s)
s = Trim(s)
'-- Filtering out any multiple spaces
iPos = 1
Do
iPos = Instr(iPos, s, " ")
If iPos = 0 then Exit Do
s = Left(s, iPos ) & Mid(s, iPos + 2)
Loop
'-- AND OR + in searches
iPos = 1
Do
iPos = Instr(iPos, s, " AND ", 1)
If iPos = 0 Then Exit Do
s = Left(s, iPos - 1) & "]""" & " AND " & """[" & Mid(s,
iPos + 5)
iPos = iPos + 5
Loop
iPos = 1
Do
iPos = Instr(iPos, s, "+")
If iPos = 0 then Exit Do
'/ Allow for spaces around the + sign
If Mid(s, iPos-1, 1) = " " Then j = 2 Else j = 1
If Mid(s, iPos+1, 1) = " " Then k = 2 Else k = 1
s = Left(s, iPos - j) & "]""" & " AND " & """[" & Mid(s,
iPos + k)
Loop
iPos = 1
Do
iPos = Instr(iPos, s, " OR ", 1)
If iPos = 0 then Exit Do
s = Left(s, iPos - 1) & "]""" & " OR " & """[" & Mid(s,
iPos + 4)
iPos = iPos + 4
Loop
' Treat unprocessed space, ie no speech marks either
side, as "OR"
iPos = 1
Do
iPos = Instr(iPos, s, " ", 1) < BR > If iPos = 0 then Exit
Do < BR > If Mid(s, iPos-1, 1) <> """" And Mid(s, iPos+1, 1)
<> """" Then < BR > s = Left(s, iPos-1) &
"]""" & " OR " & """[" & Mid(s, iPos+1) iPos = iPos + 4 < BR
> Else < BR > iPos = iPos + 1 < BR >
End If < BR > Loop < BR > SearchString = """[" & s &
"]""" < BR > End Function < BR > %> < BR >
</body> </html>
Typical result: The user input query was "print + pick"
Andrew's DATABASIC backserver program: "techsearch":
techsearch
001 Program Techsearch
002 ! Retrieve Technote details from technotes file.
003 ! Driven by Internet App using techsearch.asp
004 ! 16.02.99
005 ! Andrew Rowntree
006 TCLREAD sCommand
007 iPos = INDEX(sCommand, " ", 1)
008 sQuery = sCommand[iPos + 1, 9999]
009 sStatement = 'SORT ONLY technotes.index WITH a1 = '
010 sStatement = sStatement:sQuery
011 sStatement = sStatement: ' BY 1 code 1 (nsic'
012 CRT ""
013 EXECUTE sStatement
014 CRT "</TX>"
015 STOP
016 END
"Drill-Down" with asp script "Techsearch2.asp"
<html> <head> <title>Technote
Details</title> </head>
<body>
<%
'-- TechSearch2.asp
' 990218 ADR Adapt for technotes database
Dim Pixie
Set Pixie = Server.CreateObject("PixieWMA.clsAgent")
Pixie.TimeOut = 8
Pixie.Port = 23
Pixie.Host = "xxx.xxx.xxx.xxx"
Call Pixie.Connect ("user")
Call Pixie.ExecuteET("xxxxxxx", "<<< Pick Systems")
Call Pixie.ExecuteET("term mm-mon", ":")
Call Pixie.ExecuteET("echo off",":")
sItemID = Request.QueryString("ItemID")
s = "techdisp " & sItemID
Call Pixie.ExecuteET(s, "</TX>")
Call Pixie.ResponseCleanup
If Pixie.State = "ERROR" Then
s = "<H2> ERROR in database communication..."
s = s & "<P><CENTER>""" & Pixie.Response &
"""</CENTER>"
s = s & "<P><A HREF=""../support/technotes.htm"">Try
again</A>"
s = s & "<P><A HREF = ""../default.htm"">" < BR >
s = s & "Back to Total Home Page</A></H2>" < BR
> Response.Write s < BR > Else < BR > Call
OutputRoutine< BR > End If< BR > '---END OF
Script-level Program techsearch2 ------------------------
'
Sub OutputRoutine
'-- Output of results back from Pick
'-- Page Header
Response.Write "<table width=""100%"" border=""3"" "
Response.Write " bordercolor=""#800080"" cellpadding=""3""> "
Response.Write "<tr>" Response.Write "<td width=""50%""
bgcolor=""#008080"" border=""0"">"
Response.Write "<font size=4 color=""#FFFFFF"">The Total Computer
Company</font></td>"
Response.Write "<td width=""50%"" bgcolor=""#008000"" align=right
border=""0"">"
Response.Write "<font size=4 color=""#FFFFFF"">Technote Search
Details</font></td>"
Response.Write "</tr></table>"
Response.Write "<a href= ""../support/technotes.htm"">Tryanother
Search</a></strong></p>"< BR>Response.Write
"<hr>"<BR>Response.Write "<Pre>"<
BR>Response.Write"<font face= ""comic sansms"" size= 3>"< BR>
Response.Write Pixie.ResponseResponse.Write "</font></Pre>"<
BR> Response.Write "<hr>"< BR > '--
Standard bottom-of-page
' NOTE, deleted here to save on-screen repetition
End Sub
'-- End of Sub OutputRoutine
'== END of script techsearch2.asp ================================
%>
</body> </html>
DATABASIC backserver "techdisp" is called by techsearch2.asp
techdisp
001 Program Techdisp
002 ! Retrieve Technote details from technotes file.
003 ! Driven by Internet App using techsearch.asp
004 ! 16.02.99
005 ! Andrew Rowntree
006 TCLREAD sCommand
007 sItem = FIELD(sCommand, " ", 2)
008 EXECUTE "CT technotes detail.": sItem: " (ins"
009 CRT "</TX>"
010 STOP
011 END
END of Example 5-2 Techsearch
Next: Chapter 6 , IIS / PWS / IE / Pixie objects and entities eg "Session", "XDL", "IFR", "FBF"
Appendix: summarises PixieWeb object properties and methods.
Chapter 1 Chapter
2 Chapter 3
Chapter 4 ** Top **
Chapter 6 Chapter
7 Chapter 8
Appendix
Site Map