Theme:
v
APL+Win Training Pack 5

Error Handling in APL+Win & A Functions Lister & A General Multi-Purpose Printing Function

Download APL+Win Training Pack 5 (1237 K)
Download APL+Win Training Pack 5 Update (91 K)

The APL+Win Training SETUP5.ZIP file includes:

The Tip of the Month

The Tip of the Month is a new feature of the APL+Win Training Program. In each APL+Win Training Pack you will get a one or 2 pages APL+Win tip.

This time, you will learn how to launch your Internet browser and/or reach any Internet URL address directly from inside an APL+Win application.

Error Handling in APL+Win Applications

In this Training Pack you will learn how you can secure your APL+Win applications by adding nice error handling to them with minimum efforts.

With these error handling techniques, whenever an error occurs, the following form is displayed:

  • The Stop and Info buttons may be hidden with a .INI file parameter.

  • Clicking OK cleanly returns to the calling form.

  • Clicking Stop displays the error in the APL session as if there had not been any error handling.

  • Clicking Info displays more information about the error, as follows:

Errors are automatically saved in an ERRORS.SF file for later analysis. The above form allows navigation through the ERRORS.SF file in order to recall about past errors.

The error workspaces delivered with this Training Pack contain a small set of reusable utilities (4 utilities in ERRORMIN.W3 and 7 utilities in ERRORMAX.W3) which you can add to your APL+Win applications to install error handling into them.

Adding error handling is as simple as adding 3 small lines of code to your main application function and one label to each form function!

Printing your workspace functions

You will also learn how to nicely print one or more or all of your workspace functions.

You will learn how to write a stand-alone unique APL function to document your workspaces.

The function is called printfns and you will therefore be able to use it from any workspace, at any time, as long as you have installed the OBJECTS software described in our January 97 documents.

Example:

      )xload 51 windows
51 WINDOWS SAVED 07/14/1996 01:19:49
      $printfns 'Wforms Wtrace Wtree Wsize'

will result in the following listing:

where the top of first page, when zoomed looks like this:

The printfns WorkSpace DOCumentor offers the following features:

  • displays one, several of all functions from your workspace
  • displays headers and footers on each page
  • uses different fonts for headers/footers and for APL code
  • displays workspace name, time and date
  • displays Copyright, page number and calling function name
  • displays separation lines ending with function names for:
    • better readibility
    • easy thumbing through long listings to find a function
  • skip to next page if function does not fit on current page
  • lets you choose Portrait or Landscape printing

Solve most of your APL+Win printing problems

One of the most difficult things, albeit a basic need for almost every one, is printing under Windows.

In this Training Pack you will learn how to build and use a general Object Oriented printing utility which will help you produce Excel-quality reports with very little efforts. This utility called GuiPrint should solve most of your APL+Win printing problems.

For example, here is a report produced in Landscape mode from APL+Win with the GuiPrint utility:

The previous report is produced by the following simple APL function:

    ∇ test26;pos;S
[1]   ⍝∇ test26 -- Sample report n∘ 26
[2]   ⍝∇ Copyright (c) 1997 Eric Lescasse [23feb97]
[3]
[4]       GuiPrint'Invisible'
[5]       GuiPrint'DefaultFont' 'Arial' 14
[6]   pos←GuiPrint'Add' (2 2) Data5
[7]       GuiPrint'Border' 'thin' 'medium'
[8]       GuiPrint'ColWidth' (1↓⍳9) (1 6 1/5400 3800 4000)
[9]       GuiPrint('SelRef' 'B2:B4;I2:I3')('Border' 'no' 'no')
[10]      GuiPrint('SelRef' 'B5:B10;C2:H4;I4')('BackColor' 0 0 192)
[11]      GuiPrint('Font' 'Arial' 16)('Bold' 1)
[12]      GuiPrint('Sel' 2 3 2 8)('Align' 'across' 'nochange')
[13]      GuiPrint('Font' 'Arial Black' 18)('Italic' 1)('Bold' 1)
[14]      GuiPrint('Sel' 3 3 3 5)('Align' 'across' 'nochange')
[15]      GuiPrint('Font' 'Arial Black' 14)('Italic' 1)
[16]      GuiPrint('Sel' 3 6 3 8)('Align' 'across' 'nochange')
[17]      GuiPrint('Font' 'Arial Black' 14)('Italic' 1)
[18]      GuiPrint('Sel' 4 2 4 9)('Align' 'right' 'nochange')
[19]      GuiPrint'Sel' 5 3 10 9
[20]      GuiPrint'Format' 
[21]      GuiPrint'HLine' 'medium' (2) (3 8)
[22]      GuiPrint'HLine' 'medium' (4 9) (2 9)
[23]      GuiPrint'HLine' 'medium' (3) (3 9)
[24]      GuiPrint'VLine' 'medium' (2 10) (1 4 7)
[25]      GuiPrint('Margins' .9 1.1 2 1)('HCenter' 1)
[26]      S←⊂'\Uniware\APL Department'
[27]      S←S,⊂'\APL Sales\(First Semester 1996)'
[28]      S←S,⊂'\&D\&T'
[29]      GuiPrint'Header' (0 1 0 ssHeader S)
[30]      S←⊂'\Copyright ⍝ 1997 Eric Lescasse'
[31]      S←S,⊂,'\'
[32]      S←S,⊂'\Page &P/&N'
[33]      GuiPrint'Footer' (0 0 0 ssHeader S)
[34]      GuiPrint'Print' 0 
    ∇

This function is an example of how to use GuiPrint to directly submit a report with complex formatting to the printer. When you run test26, the only form displayed is one which shows the print job progress on your printer:

In the previous test26 function just change line 4 to [4] GuiPrint'Visible' and line 34 to [34] GuiPrint'Display' and you will have a chance to preview your report before printing, which is a great help when debugging reports:

In Chapter 11 you will learn how the general purpose GuiPrint function has been developed, using Formula One VBX to format data before printing and to print reports. Understanding how things work, you will be able to easily customize GuiPrint to fit your own needs by adding new methods to it.

With GuiPrint you will be able to:

  • program almost any report, as complex as it can be, in minutes,
  • perfectly align your column reports using proportional fonts
  • center headings above groups of columns
  • define column widths or let GuiPrint auto-determine the minimum column widths
  • use various fonts of any kind and any font attributes desired (bold, italic, underline, strikeout,...)
  • use various kinds of cell borders
  • use frames with various border types
  • draw horizontal and vertical lines or partial lines
  • perform complex numbers and dates formatting
  • automatically blank zeroes
  • use any font color and background color for any range of cells
  • define single or multi-line page headers and footers
  • use any kind of font and font size in your headers and footers
  • get automatic date, time, page number, total report pages on headers and/or footers
  • define print margins
  • horizontally and/or vertically center reports in the page
  • force page breaks anywhere desired
  • force reports to fit in the page (horizontally and/or vertically)
  • print in portrait or landscape mode
  • submit reports to printer directly with no form displayed
  • preview reports before printing
  • etc.

May we remind them to save all the utilities in their UCMDOBJ objects database.