Chapter 2 - PixieWeb Documentation:
ASP Scripting introduction
Toolkit - Editing ASP scripts, Microsoft Visual InterDev,
Microsoft Visual Basic.
Structure of our .ASP scripts: code and output.
Notes for UNIVERSE.
Output from .ASP scripts.
Example: Login
Example: StockSearch
As this project has led me more and more into ASP scripting, We have come to like it a lot as a way to work. Especially as we been able to package more and more of the procedures needed into the "Pixie" object. The way ASP scripts work in a WebServer system is remarkably like DATABASIC programs in a PICK D3 system and this similarity of modelling and form gives PICK programmers a head start with them. ASP scripts as used with PixieWeb are mini-programs or super-macros written in BASIC. You only need very simple tools to create them. We often use "Notepad" which is the simplest text processor, but you can also use "Word" taking care to identify your .asp files as "text". We've found after writing our first few that the rest flow on quickly by copying and adapting, and we hope that the ones we have given you here will work well as templates for you to do the same.
Chapter 7 offers an approach where you use a launcher with only 2 other scripts, already supplied in this package, as transmission device and container for Field-by-Field apps run almost completely from PICKBASIC programs.
At the time of writing, specialist ASP editing programs are starting to appear: eg Microsoft InterDev, Microsoft Visual Studio Environment and the script editor built into the beta of Frontpage 2000.
In my opinion, Microsoft Visual Interdev is an overly complex tool because it
suffers from being very tied to the "Microsoft Way" of database thinking ie
"Recordsets" etc and it therefore carries a lot of baggage that is
quite obscuring for us working with PICK etc.
We can squeeze good value out of it by running it in "Miscellaneous Files"
mode, ie using "file --> open" or right-clicking on the file listing of your
.asp script in Windows Explorer. This avoids creating or
defining a "project". So if you have InterDev on your computer
anyway, I recommend you use it, but at shutdown, close files one-at-a time and
that should avoid it trying to save a default project.
Microsoft Visual Basic 6 offers another approach called the "WebClass". This is a compiled machine language program run by the WebServer. WebClasses can use "PixieWeb" as a component object in much the same way as ASP scripts and the coding language and approaches are the same so the sample code given here still applies.
BUT Microsoft has now announced (early 2001) that WebClasses will be dropped from VB7.
HOWEVER, the WebClass is nothing more than a pre-digested version of something more general, the ActiveX .dll and if you are into VB6 you can write these to launch directly from an .asp script, then reference PixieWeb to gain all its benefits. VB6's big advantages here are the nice debugging environment, compiled machine code protecting confidential source code, and about double the efficiency of VBSCRIPT ASP.
NOTE that one of the main ideas behind VB6 WebClasses was the feeding out of HTM templates with detail manipulation via your code. But PixieWeb now has the FileGetText function which allows you to do the same thing within a simple script, or within your own ActiveX
HTML editors are a must for doing your user interfaces! My favourites would be: Microsoft Frontpage, Microsoft Word 2000 (good, straightforward, and you probably already have it or soon will). My favourite freebie is the one that comes with Netscape Navigator when you say yes to installing its optional extras.
Structure of our ASP scripts: Code and Output
VBSCRIPT Code is a variation on Microsoft Visual Basic. There is usually no END
statement in VBSCRIPT but when used in a WebServer context you have
"Response.End" available.
Note that we put our "main program", technically called "script-level
program" at the top of the listing rather than at the bottom as Microsoft
recommend. That's because we want the script file to start with an
overview of the whole process.
The following is a skeleton/overview with some use of comments and [pseudocode]:
<%
'-- Standard connection code
' NOTE that Pixie.Connect() and Pixie.ExecuteET()
' subroutine calls include an "expected text reply"
' argument which should be a small text sample from
' the end of an correct server response.
' eg when you first connect to PICK it asks for
' "user id:". UNIVERSE asks for "user name>"
' So by looking for "user" we have both covered
Dim Pixie
Set Pixie = Server.CreateObject("PixieWMA.clsAgent")
Pixie.ExecuteCompareMethod = 1 'case-insensitive end-of-tx testing
Pixie.Port = 23
Pixie.Host =
"127.0.0.1"
Pixie.TimeOut =
5 Call Pixie.Connect
("{AUTO}") <
BR
>
Call Pixie.ExecuteET("john", "password:") Call
Pixie.Execute("john", "<<< Pick Systems")
Call Pixie.Execute("echo off", ":")
sVariable = Trim(Request.Form("sVariable"))
If [sVariable validates as OK] Then
Call Step2(sVariable)
Else
Response.Write "<html><body>"
Response.Write "ERROR ..." '[Error feedback and advice]
Response.Write "</body></html>"
End If
'-- End of "Script Level" (ie main) program
'--------------------------------------------------------
Sub Step2(sVariable)
[Processing of sVariable into sCommand]
'eg
'sCommand = "SORT students BY surname WITH class = " _
' & sVariable & " surname firstname class (cn"
Call Pixie.Execute(sCommand, sExpectedEnd)
' eg Call Pixie.Execute( sCommand, Chr(0) & "[40" )
' NOTE the use of "[40" to cover both "[405]" when items are
' successfully found, and "[401]" when "no items present".
' The Chr(0) is thrown in by our PICK at the start of lines and
' is the kind of thing we discover with "PixiePeekaboo"
If Pixie.State = "TCL" then
'-- Get HTML template and substitute response into your
' placeholder
s = Pixie.FileGetText("c:\inetpub\wwwroot\myapp\mytemplate.htm")
s = Replace(s, "MYPLACEHOLDER", Pixie.Response)
Response.Write s
Else
Response.Write "<html><body>"
Response.Write "ERROR: ..." 'Error feedback and advice
Response.Write "</body></html>"
End If
End Sub
' End of Sub Step2
%>
Notes for UNIVERSE
Here is some asp code for login that is working well for us.
Set
Pixie = Server.CreateObject("PixieWMA.clsAgent")
Pixie.ExecuteCompareMethod = 1 'case-insensitive
end-of-tx testing
Pixie.TimeOut = 5
Pixie.Port = 23
Pixie.Host = "127.0.0.1"
Call
Pixie.Connect ("{AUTO}")
Call
Pixie.ExecuteET("john", ":")
Call
Pixie.ExecuteET("john", ":")
Call
Pixie.ExecuteET("testpxe1", ">")
Call
Pixie.ExecuteET("DATE.FORMAT ON", ">") 'to give
British date format
Call
Pixie.ExecuteET("PTERM ECHO OFF CASE NOINVERT", ">")
"UNIVERSE RetrieVe" compared to "PICK Access"
We have made "PICK Access" work for us as a method to build Web Queries with. We did have to wrestle with some odd output patterns but we now have reusable code that covers them all. The equivalent UNIVERSE query language "RetrieVe" is different enough to be a problem for us: mainly in the way it treats values which are longer than the allocated screen field width. PICK truncates, so 1 response = 1 line, but UNIVERSE wraps, and maybe we haven't delved deep enough into UNIVERSE yet but we have given up on "Retrieve" as a web query method and instead we do our UNIVERSE queries with backserver programs, with UNIVERSE SQL being useful for some direct queries producing short values that won't wrap.
UNIVERSE fans should therefore skip Chapter 4
Output from ASP Scripts
The Response.Write statement is obviously ASP's version of
"Print" etc. Output goes to the user's browser as if it was reading an HTML
file. This means that output can include sophisticated setting-out, links to
other relevant pages and artwork, but the code for that in its raw HTML state
looks quite cryptic. Fear not, you don't need to write any of that, although it
is surprising how many of us are getting comfortable with editing raw HTML
code, proof perhaps that one can get used to anything. There is a nicer
approach. You design the output you want with an HTML editor. We use
Microsoft Frontpage(TM) or Microsoft Visual InterDev in "miscellanous files"
mode.
Then, depending on how complex your output is, you can use one of these
methods:
Response.Write lines ready to paste into
your ASP script.
Response.Write "<td>sDescription</td>"
Response.Write "<td>"
Response.Write sDescription
Response.Write "</td>"
Response.Write
lines with a concatenating string variable that prints at the
end of the block, giving only one call to the Response object. eg:
s = "<p>The TOTAL Computer Company,"
s = s & "1<sup>st</sup> Floor, <br> "
s = s & "Van Leer Packaging House,"
s = s & "Clark Street, New Lynn, Auckland, <br> "
s = s & "P.O. Box 15865, New Lynn, <br>"
s = s & "Telephone:(09) 827 8775,"
s = s & "Facsimile: (09) 827 5899,<br>"
Response.Write s
FileGetText for reading files into a string
variable. It is especially useful when you then want to substitute values for
placeholders. A placeholder is text-to-replace written into the htm design file
to make it a template. eg:
'-- At start of entry script to App
Session("Folder") =
Request.ServerVariables("APPL_PHYSICAL_PATH")
'Some junior Webserver versions, eg PWS on Windows 9.x,
don't recognise
'the above line so need it spelled out to them literally with
'an alternative like the line below.
'Session("Folder") = "C:\InetPub\wwwRoot\PxLogin1\"
Response.Expires = -1 '
prevent caching
...
'-- then make your call like this ...
s = Pixie.FileGetText(Session("Folder") &
"mytemplate.htm")
s = Replace(s, "[--USERNAME--]", sUserName)
s = Replace(s, "[--ORDNO--]", sOrderNo)
Response.Write s
Example: Login1
This does: login-to-PICKetc, send a request, get a response.
The aim is to give you a quick start into getting a real result with a small
first app.
The PixieWeb default setup has placed this app in
C:\Program Files\PixieWeb\PxLogin1
You need to make PxLogin1 a web app. This is most easily done by copying
it into
C:\InetPub\wwwRoot\ then
declaring it as shown in Chapter 1.
For best effect, it needs resource folder \PxRes
also copied to wwwRoot
and setup with read permission.
PxRes - contains files to support all the
sample apps:
PxLogin1 - contains the active code of the app:
login.asp - login form
loginprocess.asp
- connection to PICK etc and send processing requests to MYAPP1
MYAPP1 - DATABASIC source code
You need to:
When you have this app setup, test it from "mmw.htm" running "via the Webserver" as a website visitor from outside your computer would be doing. In practice this means that you can not do a valid test just by double-clicking on "mmw.htm". You must type a complete reference into the browser address box. Or click on the prepared link below which has a good chance of covering your webserver setup:
http://127.0.0.1/PxRes/mmw.htm
Example: Stock Search
This is web app folder "PxSearch" installed initially in "C:\Program
Files\PixieWeb"
A working example of "StockSearch" is also running on our examples website
at: http://203.29.170.181:7301/PixieInfo/
If you do not have it going on your local webserver, you can run ours
as you refer to the following notes.
Picture of part of the user's screen:
User input into "PixieWeb"
Two elements are involved here:
Request.Form(variable_name
) statements where
Features of the example script
eg: A user inputs mitsumi + mouse
Within Function SearchString,
this processes to the following request for PICK etc
SORT prod WITH descr = "[mitsumi]" AND "[mouse]" BY descr descr
retail (cn
The user gets this result back (top only of user screen shown) :
Next: Chapter 3 which introduces improved presentation of responses and use of "PixieWeb" screen analysis (screen scraper) functions with legacy programs.
Appendix: summarises Pixie object properties and methods.
Chapter 1 ** Top **
Chapter 3 Chapter
4 Chapter 5
Chapter 6 Chapter
7 Chapter 8
Appendix
Site Map