A NEW TODAY IS DAWNING!

TB0016 - Printing any file from BuildPro

Number: TB0016

Availability: As of BuildPro 8.00, all users


Introduction

To print a report in html format without having to go via your browser you can use the SYSTEM *UI command. To see how to represent your BuildPro reports using a browser see technical bulletin TB0004. This command can be used not only to print html documents but also to print any file type which is known to windows, like text files for example.


Windows

To see what commands you can use you need to check the registered file types in Windows. to do this follow these steps:

  1. Click Start, point to Programs, and then click Windows Explorer.
     
  2. On the Tool menu, click Folder Options, and then click File Types.
     
  3. In the Registered file types box, click on the file type you want to know about, and then click Edit.
     
  4. The actions or commands that can be applied to that particular file type are listed in a box called actions:

NOTE: You can create your own actions here if you know the appropriate command to put in the Application used to perform action field by clicking on new. To see what the existing command for a given action is, double click the action or select the action and click on Edit.


BuildPro

To access these actions via BuildPro the syntax used is:

SYSTEM

 

SYSTEM You use the SYSTEM command to execute an operating system command or an external program written in a language other than BuildPro, from within BuildPro.
*UI Specifies that the command executes on the machine where the User Interface is executing. BuildPro Logic processing continues once the command has been initiated. This option is not supported when running in the background. E.g. by processes initiated by the BACKGRND command
*ACTION Defines the action to be initiated. The default action is "open". For further details see ShellExecute API in the Windows SDK and the Registry Editor program.
*WORKDIR Defines the working directory. The default working directory is unspecified. The working directory must be specified as a full path name.
dataref Refers to a data reference or variable which will hold the value of the action, working directory or file name.
atype This is the actual action to be performed (which can be hard coded) e.g. "open" or "print"
wdir This is the working directory which too can be hard coded e.g. C:\winnt\system32.

NOTE: If a working directory is not defined the the full path must be specified in filename.

The above syntax can be used from any process or function to perform a defined action on a known file type.
 

Examples

Here are some examples of different action you could perform using the SYSTEM *UI command in BuildPro:

  • SYSTEM *UI *ACTION="open" "C:\test.txt"
    This command will open the file test.txt using the default text editor (normally notepad).
     
  • SYSTEM *UI *ACTION="print" *WORKDIR="C:\" "test.doc"
    This command will print the file test.doc using the default editor for doc files (normally MS Word). It will look for the file in the C: root directory.
     
  • SYSTEM *UI *ACTION=V-command *WORKDIR=V-location V-filename
    This command will perform the action specified in the variable command on the file specified in the the variable filename default editor for these files. It will look for the file in the directory specified by variable location.
     
  • LENGTH V-action L-count
    SYSTEM *UI *ACTION= V-action[1,L-count] V-file
    When using variables of a given size BuildPro puts in spaces for the blank area in the variable. So if the variable V-action has a max of 10 characters and you put "open" in it it will actually pass "open " into the system. To bypass this the variable L-count and the command LENGTH is used to cut off the trailing spaces. V-file in this case will contain the full path along with the filename e.g.. C:\test.txt. A similar command with another count variable may be used for the V-file variable but is not essential as it does not affect the command but for the V-action variable it is essential.

A small application has been created using BuildPro to illustrate the use of these commands. It can be downloaded here. The source code has been included and can be installed by copying the file to the BuildPro\bin directory and running the command archive -xsv4f bpprint.tdy from the bin directory via a command (DOS) prompt.

This application works by entering the location and filename in the file name field and selecting an action like browse (which will open the file using the default editor or print which will print it in the same way. the print command will use the default printer of Windows. In Windows NT print will just print the file but in Windows 98 it will bring up the print dialogue box to select a printer and copies etc.

 

Report

 

The 'other action' command can be used to specify a different action to print or open like a personalized action. Some of the main errors you are likely to get which are generated by Windows are:
 

Execution Failed

 

This is if the file is not found in the location you specified.

Execution Failed
 

 

This is if the action specified is not known to Windows for that given file type.