Dynamic-CD
Search : 
  Powered by FindinSite

ASP Documentation
Overview
• Introduction
• Getting started
• Dynamic-CD wizard
Passwords & Encryption
• Overview
• Example 1
• Example 2
Scripts
• The script language
• Script examples
• Database scripts
Technical details
• Applications
• Built-in objects
• Character Encoding
• Cookies
• Database CDs
• Development tips
• FAQs
• Future developments
• Global.asa
• Network support
• Object registration
• Resources
• ScriptingContext
• Server-side includes
• Sessions
• Technical limits
    
Development techniques

Introduction
This page contains some suggestions on how to go about your Dynamic-CD development. However, there is no one correct way to proceed.

Page
Contents
Web and CD versions
Set up appropriate directory structures
Build your web site
Choose a program editor
Get the documentation to hand
Build your database
Start writing scripts
Build and test your CD image
Development cycle


Web and CD versions
If your web site appears online and on a CD, then you must first decide how to manage both sets of information. It is most likely that your online web site will be the primary dataset and that your CD will be a snapshot or subset of your web site. For example, you may be able to prepare an order from a product database on the CD, but it only makes sense to process the order online.

You could decide that the Web and CD versions of your web site must be identical. You will have to check carefully that everything works in both situations. In particular, you must check that scripts and databases run OK.

Alternatively, your CD could be a subset of your online web site. However it is still possible for there to be common scripts. A script could only show certain links if it detects that it is running online.

If you use databases, then you will almost certainly have to move the database files into your CD image, and password-protect them in Access (in Menu Tools+Security). Your database scripts will need updating, at the very least to make sure that the database is opened from the correct location (see example).

It is quite likely that you will only want a stripped down database to appear in your CD image, eg the product information but not the customer information.

If your Web and CD site are different, then it is worth while automating the process of generating one from the other. If you web site is the main source, then write batch files and database conversion tools that allow you to generate the initial CD image easily whenever you need to start producing a CD snapshot of your web site. Make sure that any CD script files that you write are not overwritten accidentally by this process; perhaps save them first and copy them back in afterwards.


Directory Structures
To use Dynamic-CD you must have a copy of your web site on your hard disk. Here are two possible ways to structure your hard disk:

CD Web site Only

If you are creating a CD from scratch then this directory structure is suggested.
Project--- Source
--- Image
Start with a Project directory. Replace Project with the name of your project.

Create two sub-directories, Source and Image. Write your web site in the Source directory. Note that Project\Source can contain as many sub-directories as you want for your CD web site.

When ready for testing, run Dynamic-CD-Wizard, specifying Project\Source as the input directory, and Project\Image as the output CD image. You can test the CD image directly from the hard disk. When ready, you can burn a CD directly from the Project\Image directory.

When you run Dynamic-CD-Wizard it is best to save your settings in a project file. Save this file, eg Project.dcd in the Project directory. Do not save it in Project\Source or Project\Image.

Don't forget that the Project\Image directory is usually cleared completely each time a CD image is remade, so never work with files in this directory. Always edit web pages, images, scripts, etc. in the Project\Source directory and rebuild the CD image when you want to test your changes. Rebuilding and testing is quick to do in Dynamic-CD-Wizard - see later.

CD is a subset of an online web site

If you are creating an online and CD web site from scratch then this directory structure is suggested.
Project--- Online
--- Source
--- Image
--- Changes
Start with a Project directory. Replace Project with the name of your project.

Create sub-directories, Online, Source and Image, and sub-directory Changes if need be.

The Online directory is for your local copy of your online web site. If you want, copy or move your entire web site from its existing location to this directory. Alternatively, do not have an Online sub-directory, but work with your online web site in its existing location.

The Source directory is what you want to appear on your CD. You could simply copy the web site from Project\Online and start making any changes you need in Project\Source. Alternatively write a batch file to copy only the files that you need. This batch file might also call a database utility that creates a CD database as a subset of your online database. Put these tools in the Project directory.

When ready for testing, run Dynamic-CD-Wizard, specifying Project\Source as the input directory, and Project\Image as the output CD image. You can test the CD image directly from the hard disk. When ready, you can burn a CD directly from the Project\Image directory.

When you run Dynamic-CD-Wizard it is best to save your settings in a project file. Save this file, eg Project.dcd in the Project directory. Do not save it in a sub-directory.

If you are thinking of creating a CD from your online web site more than once, it is worth automating the process as much as possible, as described above. Now, suppose you want to keep any files that you have already changed in the Source directory. Do this by making a Changes directory. Your batch files should copy any changed files from Project\Source to Project\Changes before copying the main web site from Project\Online. Finally copy the changed files back from Project\Changes to Project\Source and check to see if these files need to be updated.


Build your web site
If you have not already done so, build your web site in the appropriate directory. If you are making an online version of the web site, make it in Project\Online. Otherwise make the CD Source in Project\Source.

For a simple project, you can view the web site in-situ without creating a CD image. However if you are using scripts, databases or password-protection, you will need to make a CD image with Dynamic-CD-Wizard to see the CD site in action.


Choose a program editor
You can develop your site using your usual web development tools. If you are writing scripts you may wish to get a suitable programming editor, such as the Microsoft Visual Studio tools. This will highlight your ASP code and possibly do syntax checking.

Note that you cannot do source code debugging with Dynamic-CD.


Get the documentation to hand
When you are writing scripts if it helpful to have all the documentation to hand. In particular you may want to refer to this information:
  • Dynamic-CD documentation web page
  • Microsoft VBScript Guide and Reference
  • Database programming: Microsoft ADO Guide
The Microsoft documentation is available online - follow the links on the Dynamic-CD resources page. The entire VBScript documentation can be downloaded from http://msdn.microsoft.com/scripting/vbscript/download/vbsdoc.exe. Alternatively subscribe to the Microsoft Developer Network (MSDN) Library that contains all the documentation on CD/DVD.


Build your database
If you have not done so already, build your database. Use Microsoft ACCESS® to create a .mdb file. Put it in the Project source directory somewhere - a sub-directory would be fine.

Remember that you cannot update your database from CD, so everything will be read-only from CD. There is no point in creating a Customer table because you will not be able to add anything to it. You will have to use other techniques to save information that you want to pass between pages on your CD, eg forms, cookies, the session object or a file. For example, use the  FileSystemObject  object to store information in a file in the current user's Windows temporary directory - obtained using  Request.ServerVariables( "WINDOWS_TEMP_DIR") .

If you really want to, you can copy your database onto the user's hard disk using  FileSystemObject , eg to the Windows temporary directory. Change the read-only file attribute to make the database updatable.

If your CD database is based on your online database, be careful if the two will be linked at some stage. Suppose, for example, that you build up an order using the CD database and then send the completed order to your online system. You must make sure that you use a safe way of linking order lines together. If you use an Access "Autoindex" ID to refer to a part number, say, then the ID in the CD database may not necessarily refer to the same part in the online CD if this changed at a later date. Instead, use a safe identifier such as a Part Number to link the two databases. (And do not forget to cope if a part is delete from online database!)


Start writing scripts
You are now ready to start writing scripts. Begin by copying some of the examples in the Dynamic-CD documentation - check that you can get them to run. Study them carefully so that you see how they work and how they are structured. Most folk start off with simple code, testing each routine as it is written to make sure that it works.
Server-side scripts
Remember that you are writing server-side scripts, so put all code in between
 <% ... %>  tags, eg:
<%
  rootPath = Request.ServerVariables( "ROOT_DIR")
  dbPath = rootPath + "\project.mdb"
  ' etc
%>
Don't write browser-side scripts
Remember NOT to use code like this by mistake:
 <script language="vbscript"> .. </script> 
because this is VBScript code that runs in the browser.

Comments
In VBScript, a comment is a line starting with an apostrophe  ' .

Program structure

To terminate a script at any point - after an error, or after processing is complete, call  Response.End . Note that a call to  Response.Redirect  also terminates a script

When scripts run
Just to make it clear, ASP scripts are only run once per request - that is, when a page request arrives from the user. If you want to use server side scripts to change the appearance of the page then a whole new page must be requested by the user.

You can also use browser-side scripts to do processing in the browser without contacting the server. While browser-side scripts can access the same object file system and database objects (when run in Internet Explorer with appropriate security permissions), it makes sense to keep all such interactions in one place - on the server.

Saving state information
For techniques allowing you to retain information from one page to the next, look at the saving state page.


Build and test your CD image
When you want to do a test run of your CD, use Dynamic-CD-Wizard to build a CD image. Initially you can test the CD image direct from your hard disk. Soon however it will be best to burn a real CD-R so that you can check that your CD runs correctly on other computers.

Start Dynamic-CD-Wizard. Click the "New" project button if necessary, and enter the name of your CD. Proceed through the rest of the wizard pages, following the instructions that are available by pressing the "Help" button. If you followed the earlier directory layout suggestions, then use Project\Source as the source directory and Project\Image as the image directory.

When you have got to the final page of Dynamic-CD-Wizard, click on the "Test on hard disk" button to start Dynamic-CD and display the CD startup file.

Do not exit from Dynamic-CD-Wizard. Instead, keep it open to make it easy to try updates to your site. Pressing the "Rebuild CD image" button remakes the CD image. A warning box is shown because the rebuild process first has to delete all the files and sub-directories in the CD image directory. When the CD image is rebuild, click on "Test on hard disk" to try out your latest version.


Development cycle
A development cycle is when you repeatedly change your site and test it.

You might be developing some script code. With each change you need to remake your CD image and restart Dynamic-CD. As described above, Dynamic-CD-Wizard makes it easy to do this. Leave Dynamic-CD-Wizard on the last wizard page (once you have built the CD image once). After each change, press the "Rebuild CD image" button to remake the CD image, and "Test on hard disk" to try out your latest version.

Note that you cannot do source code debugging with Dynamic-CD.


© Copyright 2000-2007 PHD Computer Consultants Ltd