TechTricks
Technical answers from the trenches 
 
 
 
 

     
   
Avoiding Style Sheet Problems
 
   
by Lance Leonard 
 Posted: 20 July 2000
 
   
 
 Applies to: Paradox 5.0 and later.
 
   
 
Audience: Beginner
 
       
   

Introduction

Paradox style sheets have tremendous potential. You can use them to provide a consistent and professional appearance between your forms and reports (collectively known as documents). They can reduce the amount of work associated with "boilerplate" code. Due to weaknesses in the way Paradox handles missing style sheets, however, they can also be a support nightmare. Because every Paradox document contains a style sheet reference, you may be affected by these weaknesses even though you do not specifically use style sheets in your Paradox development efforts.

Fortunately, the style sheet problem only occurs in a very limited set of circumstances. This article describes the causes of the problem, lists errors messages that appear when the problem surfaces, and provides strategies for avoiding the problem altogether.

Understanding the Problem

Two key configuration elements lead to style sheet problems:

  1. On the development machine, Paradox is installed on a drive other than C:.
     
  2. The affected documents are used on a computer that has a different drive configuration than the development machine.

For example, suppose you have Paradox installed on a hard disk (or partition) assigned to drive D: and that your users' systems assign D: to their CD-ROM drive. In this, and similar cases, you will encounter the style sheet problem because Paradox does not properly validate the location of a style sheet when trying to open it.

Many things can prevent a file from being opened. For example:

  • Another user or process may be using it.
     
  • The file may not exist.
     
  • The directory containing the file may not exist.
     
  • The drive might be entirely missing or unavailable.

Because of these and other potential problems, a lot of effort goes into designing robust file-handling mechanisms. By and large, Paradox handles most of these potential problems well.

For example, suppose you save a form using a custom style sheet on drive C: and later copy that to a computer that does not have that style sheet installed. When this happens, Paradox initializes style properties from the style sheet currently defined as that computer's default style sheet or to factory defaults, depending on the specific configuration of the target computer.

Unfortunately, Paradox doesn't adequately handle the "missing drive" problem. (To be fair to the original developers of the relevant code, Windows doesn't make this a trivial process. To effectively deal with this problem, you have to temporarily override Windows' default error handling processes, something that is not documented very clearly.)

Fortunately for us, however, it's very easy to fix style sheets problems and to avoid them.

Before getting carried away, please understand that the style sheet problem only appears when a) documents are saved using versions of Paradox installed on drives other than C: and b) these documents are later used in versions of Paradox installed on computers that have different drive mappings or configurations.

If you always install Paradox on drive C: or you never share your files with other users, then you will not encounter this problem.

Detecting the Problem

Because Paradox tries to handle missing style sheet by resorting to configuration or factory defaults, there isn't an "Invalid Style Sheet" error. Also, because the problem is related to a specific configuration, these errors can be difficult to reproduce. For example, a user may receive a "Cannot Interpret File" error when opening a form, but you may be to open it on your machine. This makes the style sheet problem more difficult to detect.

The following list summarizes the error messages that we've seen when encountering style sheet related problems:

  • "Can't Interpret File" when opening forms and reports
     
  • "Drive D: not ready" (note that the drive letter is usually a removable drive, such as a CD-ROM or a Zip disk, that doesn't contain a valid data disk)
     
  • GPF's (or equivalent) when clearing a filter.
     
  • GPF's (or equivalent) when exiting a form.
     
  • GPF's (or equivalent) when exiting Paradox.

Please understand that we're not saying that these messages always indicate a style sheet problem. However, we have run into cases where these messages were caused by style sheet problems. If you're trying to troubleshoot one of these errors, start by checking the style sheet associated with the document involved in the process that generates the error.

The clearest indication that you've got a style sheet problem appears when you check the style sheet currently associated with a document. If the Style Sheet dialog shows style sheets from a drive that doesn't currently exist on the computer you're using, you've got the problem.

To resolve it, save your document using an available style sheet.

Avoiding the Problem

Three key strategies can help avoid style sheet problems:

  1. Move Paradox's style sheets to Drive C: and configure Paradox to use the copies.
     
  2. Consistently re-save all documents using style sheets located on Drive C:
     
  3. Install style sheets on your user's computers.

Note: You can also avoid style sheet problems if you re-install Paradox to drive C:, however, that's not always an option, so we don't really consider it a valid strategy. Your mileage may vary, however. It's certainly the easiest and least expensive solution.

The following sections discuss each strategy in more detail.

Moving style sheets

As noted earlier, Paradox effectively handles missing style sheets if it can find the drive associated with the style sheets. Because of this, you can avoid the problem if you move your style sheets to a drive available to all users, e.g. C:.

To do this:

1. Create a target directory on a drive common to all your users. (We generally use C:\DATA\PXSTYLES.)

2. Locate the source directory currently containing your style sheets (*.FT and *.FP). The specific directory depends on the version of Paradox you're using and where you installed it. For example, if you've installed Paradox 9.0 to D:\DATA, this directory is D:\DATA\COREL\PARADOX\PDOXHOME.

3. Use Windows Explorer to copy all .FT and .FP files from the source directory and paste these into your target directory. (You can also use DOS commands, provided you aren't using long file names for custom style sheets.)

4. Update the Registry settings that tell Paradox which style sheets to use by default. For Paradox 9.0, the keys can be found in:

   HKEY_CURRENT_USER\Software\Corel\Paradox\9.0\Pdoxwin\Designer

Two settings are involved. ProtoFile contains the name of the default style sheet for forms and ProtoFilePrt is the default for reports. Carefully edit these to replace source path information with your target directory. Use care to preserve the specific filenames in these settings.

Note: If you have not manually edited your Registry before or have not backed it up recently, you should make a backup of your Registry before changing these settings.

Admittedly, this is an involved process, however, completing it prevents style sheet problems in new documents.

Re-saving Documents

Moving style sheets avoids problems with new documents, however, you also need to ensure that existing documents do not exhibit the problem. To do this, re-save them using your relocated style sheets.

If you have a large number of documents and you're using Paradox 8.0 or later, you can automate this process using ObjectPAL. For example, consider:

   strStyle = "c:\\data\\pxstyles\\default.ft"
   frm.load( ":forms:mainform.fsl" )
   if lower( fullName( frm.getStyleSheet() ) <> strStyle then
      frm.setStyleSheet( strStyle )
      frm.save()
   endIf

Note: For an example script for doing this for a directory and all subdirectories, see "Recursively Searching for Files."

Please note that you cannot change the style sheets of delivered documents. You need to change the document's source file and then re-deliver it.

Installing Style Sheets

If you are building Paradox applications for external clients or commercial distribution, you should consider using a commercial installation package to install your style sheets on the end-users' computers. This may reduce other problems affected by missing style sheets.

Alternatively, if you use a script to start your application, you can include code to verify that the Registry settings point to a valid set of style sheets.

We cannot say for certain if this helps or not. We started doing this when this issue affected our applications and we've not experienced any related problem reports since then. Your mileage may vary.

Note: If you are using the Paradox Distribution Expert (PDE) to create your installations, you will need to use an ObjectPAL-based approach to validate your end-users' machines. Sadly, the PDE offers few options for working with non-Paradox related configuration settings. If you are looking for a more robust solution, consider WISE for Windows Installer or InstallShield. (For the record, we prefer the former; we find the latter "annoying.")

Summary

While style sheets can be troublesome, the problems are easily solved. By re-saving your documents to use style sheets on drives common to all users and by configuring your development machine to avoid future problems, you can side-step the situation that causes style sheet problems.

Hopefully, Corel will address these issues in an upcoming release or service pack. Until then, we have to find ways of living with the problem. Once you understand the problem and its causes, you should be able to start exploring the benefits of using custom style sheets (which we'll examine in a future article).

Related Information:

 

       

Top

Feedback About Paradox Delphi Assorted Web Stuff
 
 
Copyright © 2000-2004, techtricks.com; All Rights Reserved.
Acknowledgements, Disclaimers, Terms and Conditions.
Article last updated on 31 May 2003

 

Other Sites: Paradox, Delphi, Perl, Web Stuff, and More


 

[- End -]