home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
High Voltage Shareware
/
high1.zip
/
high1
/
DIR8
/
123EXP.ZIP
/
EXPRTWK1.CLA
next >
Wrap
Text File
|
1994-01-07
|
32KB
|
746 lines
MEMBER('dcf')
exprtwk1 PROCEDURE
!******************************************************************************
! This sample program illustrates the method for exporting to a 1-2-3
! format spreadsheet file and a WYSIWYG format file (.FMT).
! The key routines to reference are:
! init_wks - Creates the spreadsheet file and sets up the
! initial header records
! write_BOF - Write the 123 "beginning of file" record
! def_window - Defines the spreadsheet window, the default formats
! and the default column widths
! set_widths - Sets the column widths
! write_label - Write a "label" cell (uses the write_cell ROUTINE below)
! write_real - Writes a real number cell (uses the write_cell ROUTINE below)
! write_int - Writes an integer number cell (uses the write_cell ROUTINE below)
! write_cell - Writes a cell (and displays the cell location on the
! statistics window).
! NOTE: The WYSIWYG formatting code is almost impossible to follow without
! having some understanding of how the .FMT file records are laid out.
! This is provided in the Lotus documentation.
! DISCLAIMER: I have not spent any time cleaning up this code. There are
! lots of calls to other functions and procedures that I have not removed.
! There are also references to global variables and files that I have not
! provided.
!******************************************************************************
!══════════════════════════════════════════════════════════════════════════════
! RED - 04/27/93
! This procedure is used to export the cash flow to a 1-2-3 spreadsheet
! file and a WYSIWYG .FMT formatting file.
!══════════════════════════════════════════════════════════════════════════════
stat_screen SCREEN WINDOW(13,44),PRE(sta),HUE(9,7)
ROW(12,2) PAINT(1,1),TRN
ROW(12,3) PAINT(1,40),HUE(8,0),TRN
ROW(4,4) PAINT(5,38),HUE(1,7)
ROW(1,2) PAINT(1,41),TRN
ROW(13,2) PAINT(1,41),TRN
ROW(1,1) PAINT(13,1),TRN
ROW(1,43) PAINT(13,2),TRN
ROW(3,43) PAINT(10,1),HUE(8,0),TRN
ROW(5,22) PAINT(1,18),HUE(0,7)
ROW(7,22) PAINT(1,7),HUE(0,7)
ROW(2,2) STRING('█▀{39}█')
ROW(3,2) REPEAT(6);STRING('█<0{39}>█') .
ROW(9,2) STRING('█─{39}█')
ROW(10,2) STRING('█<0{39}>█')
ROW(11,2) STRING('█▄{39}█')
ROW(4,4) STRING('┌─{15}╥─{19}┐')
ROW(5,4) REPEAT(2),EVERY(2);STRING('│<0{15}>║<0{19}>│') .
ROW(6,4) STRING('├─{15}╫─{19}┤')
ROW(8,4) STRING('└─{15}╨─{19}┘')
ROW(5,6) STRING('Lines Exported')
COL(30) STRING('of')
ROW(7,16) STRING('Cell')
COL(24) STRING(':')
msg ROW(3,4) STRING(38),HUE(0,7)
exp_cnt ROW(5,22) STRING(@N7),HUE(0,7)
max_cnt COL(33) STRING(7),HUE(0,7)
col ROW(7,22) STRING(2),HUE(0,7)
row COL(25) STRING(5),HUE(0,7)
esc_msg ROW(10,4) STRING('Press [Shift+Esc] to abort.'),HUE(8,7)
.
INCLUDE('wks_file.inc')
INCLUDE('wysiwyg.inc')
rec_cnt LONG
exp_cnt LONG
yr_no BYTE
year SHORT
cur_ptr LONG
total_line LONG ! This is the POINTER of the group total line record.
exp_tot_ttl BYTE ! If true, the total group heading needs to be exported.
! Set true whenever a group total is encountered, set
! off after the 1st sub-line for that group is exported
! (the group total title must be exported BEFORE the
! 1st sub-line for the group is exported). Used to
! determine if any sub-lines for the group were exported.
! If none were, the group total line is exported without
! the separator line and without the "Total" prefix.
lin_ndx BYTE
total_equity REAL
total_cap REAL
smry_amt REAL ! Summary and balance sheet amounts
ini_amt REAL,OVER(smry_amt)
fin_amt REAL
col_offset BYTE ! Balance sheet column offset (1=left (initial)
! column, 2=right (final) column)
range_row SHORT ! Bottom row of the initial, default print range
row_attrs GROUP,PRE(atb) ! Row attributes to use
row_height BYTE,DIM(300)
row_attr BYTE,DIM(300)
.
attr_idx SHORT
max_attr SHORT
sep_line BYTE
top_border BYTE ! # of rows in the Top border
!──────────────────────────────────────────────────────────────────────────────
CODE
DO init_stats
DO init_wks ! Initialize the worksheet, define the column
! layouts and write out the header info
DO exp_lines ! Export the line items
DO line_attrs ! Write out the line attributes
DO prt_settings ! Setup the WYSIWYG print settings
DO cleanup
mem:status = true ! Normal completion
RETURN
!───Routines───────────────────────────────────────────────────────────────────
init_stats ROUTINE
exp_cnt = 0
OPEN(stat_screen)
sta:max_cnt = LEFT(FORMAT(RECORDS(lineitem),@N7),SIZE(sta:max_cnt))
sta:row = 1
sta:col = 'A'
sta:exp_cnt = exp_cnt
init_wks ROUTINE ! Initialize the worksheet and define the column layouts
wks_filename = CLIP(prj:export_dir) & '\' & dcf:export_file
CREATE(wks_file) ! Create (or re-create) the file.
IF ERRORCODE()
err_msg('Unable to create the spreadsheet file.')
DO cleanup
RETURN
.
wyv:filename = wks_filename
wysifile(wyf:setup) ! Create (or re-create) the WYSIWYG file.
IF mem:status = false
DO cleanup
RETURN
.
DO write_BOF ! Write the spreadsheet beginning of file record
DO std_attr_tab ! Write out the standard .FMT attribute table record
DO def_window ! Define the spreadsheet window
DO set_widths ! Set the column widths
DO write_titles ! Write out the titles
DO write_hdrs ! Write out the column headings
wks:format = def_format
exp_lines ROUTINE ! Export the line items
sta:msg = 'Exporting the lines for ' & CLIP(dcf:id) & '...'
total_line = 0
exp_tot_ttl = 0
lin:dcf_id = dcf:id
lin:no = 0
lin:sub_no = 0
SET(lin:key,lin:key)
LOOP UNTIL EOF(lineitem)
NEXT(lineitem)
IF lin:dcf_id <> dcf:id
BREAK
.
exp_cnt += 1
sta:exp_cnt = exp_cnt
DO abort_check
IF lin:sub_no = 0
IF total_line ! Is there a group total line
DO exp_total ! to export?
. .
IF lin:hide_line ! Hide this line?
CYCLE ! Yes - don't export it
.
IF exp_tot_ttl ! Is there a pending total title?
DO total_title ! Yes - write the title line first
.
DO write_line ! Write out the line item info
.
attr_idx += 1 ! Format the bottom border
atb:row_height[attr_idx] = 7 ! Set line height
atb:row_attr [attr_idx] = wat:n_lr_wb[6] ! Normal w/ Left and right borders, wide bottom border
DO exp_id ! Export the id at the bottom
range_row = wks:row ! Save the most recent row for
! the print range
wks:row += 2
line_attrs ROUTINE ! Export the line formatting attributes
sta:msg = 'Exporting the formats for ' & CLIP(dcf:id) & '...'
max_attr = attr_idx
exp_cnt = 0
LOOP attr_idx = 1 TO max_attr
exp_cnt += 1
sta:exp_cnt = exp_cnt
IF atb:row_height[attr_idx] = 0
wys:row_height[wyv:cluster_row] = 14 ! Set to default height
ELSE
wys:row_height[wyv:cluster_row] = atb:row_height[attr_idx] ! Row height in points
.
IF wys:row_height[wyv:cluster_row] <> 14 ! Default height?
wys:row_attrs [wyv:cluster_row] = row_fix_hgt ! No - Mark row as having a non-default row height specified
.
wys:row_lumps [wyv:cluster_row] = 2 ! 3 LUMPs for every row
wys:col_count [wyv:cluster_lump] = 0 ! Column "A" (rel to 0!)
wys:attr_style[wyv:cluster_lump] = 0
wyv:cluster_lump += 1
wys:col_count [wyv:cluster_lump] = dcf:years ! The column count is relative to 0 so this will include the description column
wys:attr_style[wyv:cluster_lump] = atb:row_attr[attr_idx]
wyv:cluster_lump += 1
wys:col_count [wyv:cluster_lump] = 255 - (1 + dcf:years)
wysifile(wyf:row_end_lump) ! "Write" out the attribute cluster
.
exp_id ROUTINE ! Export the release # and DCF id at the bottom
wks:format = def_format
wks:label_prefix = ''''
wks:row += 1
wks:col = 1
wks:string = 'Release: ' & mem:version & ' Id: ' & dcf:id
DO write_label
attr_idx += 1 ! Format the line
atb:row_height[attr_idx] = 9 ! Row height in points
atb:row_attr [attr_idx] = wat:no_attr[5] ! Normal, smaller font
write_line ROUTINE ! Write out the line info
IF lin:method = mth:seperator ! Seperator line?
DO set_sep_line ! Reformat the previous line
EXIT
.
IF lin:method = mth:group_total ! Group total line?
total_line = POINTER(lineitem) ! Save the record pointer to export the
! titel and total numbers later
exp_tot_ttl = true ! We may need to export the title
EXIT
.
IF wks:row = max_123_rows ! Check for an overflow
err_msg('The spreadsheet is full. ' & |
CLIP(LEFT(FORMAT(max_123_rows,@N9))) & ' rows have been written.')
DO cleanup
mem:status = false
RETURN
.
wks:format = def_format ! Turn on cell protection
wks:label_prefix = '''' ! Left justify
wks:col = 1
IF lin:sub_no = 0 ! Don't indent main lines
wks:string = lin:desc
ELSE
IF total_line ! Is there a total line pending?
wks:string = ' ' & lin:desc ! Indent sub line descriptions
ELSE
wks:string = lin:desc
. .
DO write_label ! Export the description
DO set_attr ! Set the attributes for the line
IF lin:method = mth:title ! Don't export any numbers for a
wks:row += 1 ! title
ELSE
DO export_yrs ! Export the yearly amounts
.
total_title ROUTINE ! Export the current total title line
exp_tot_ttl = false
cur_ptr = POINTER(lineitem) ! Save pointer to current record
GET(lineitem,total_line) ! Reload the group total line item
wks:format = def_format ! Turn on cell protection
wks:label_prefix = '''' ! Left justify
wks:col = 1
wks:string = lin:desc ! Just export the description
DO write_label ! Export the total description
DO set_attr ! Set the attributes for the line
atb:row_height[attr_idx] = 21 ! Make line 50% taller
wks:row += 1
GET(lineitem,cur_ptr) ! Reload the current line
set_attr ROUTINE ! Set the attributes depending on what line we're on
attr_idx += 1
CASE lin:no
OF lno:oper_profit
atb:row_attr[attr_idx] = wat:b_lr[6] ! Bold
OF lno:pre_tax_inc
OROF lno:net_income
atb:row_attr[attr_idx] = wat:n_lrb[6] ! Normal w/ Left, right and bottom borders
OF lno:new_ltd
atb:row_attr[attr_idx] = wat:n_lr_db[6] ! Normal with double bottom
OF lno:available_cf
atb:row_attr[attr_idx] = wat:bs_lrb[6] ! Bold, shade, left, right and bottom borders
OF lno:pv_factor
atb:row_attr[attr_idx] = wat:n_lrb[6] ! Normal with bottom border
OF lno:pv_of_cash
atb:row_attr[attr_idx] = wat:bs_lr[6] ! Bold, shade
ELSE
atb:row_attr[attr_idx] = wat:n_lr[6] ! Default to Normal w/ Left and right borders
.
set_sep_line ROUTINE ! Set the underline attribute for the line above
! when a seperator line is encountered.
IF attr_idx > 0
IF atb:row_height[attr_idx] = 7 ! Is the previous line a total seperator?
EXIT ! Yes - no need to underline
.
CASE atb:row_attr[attr_idx] ! Be sure the previous line is underlined
OF wat:b_lr_wb [6]
OROF wat:n_lr_db [6]
OROF wat:bs_lr_wb[6]
OROF wat:b_lrb [6] ! Do nothing if already underlined
OF wat:b_lr [6] ! Bold?
atb:row_attr[attr_idx] = wat:b_lrb[6] ! Keep bold w/ Left, right and bottom borders
OF wat:bs_lr [6] ! Bold and shaded?
atb:row_attr[attr_idx] = wat:bs_lrb[6] ! Keep bold and shading w/ Left, right and bottom borders
ELSE
atb:row_attr[attr_idx] = wat:n_lrb[6] ! Normal w/ Left, right and bottom borders
. .
exp_total ROUTINE ! Export the total line for a group
cur_ptr = POINTER(lineitem) ! Save pointer to current record
GET(lineitem,total_line) ! Reload the group total line item
wks:col = 1
wks:format = def_format ! Turn on cell protection
IF NOT exp_tot_ttl ! Were any sub-lines exported?
atb:row_attr[attr_idx] = wat:n_lr_db[6] ! Yes - Change the formatting
! for the previous row to
! include a double line
wks:label_prefix = '"' ! Right justify
IF UPPER(SUB(lin:desc,1,6)) = 'TOTAL '
wks:string = lin:desc ! "Total" already there
ELSE
wks:string = 'Total ' & lin:desc ! Stick "Total" in front
.
ELSE ! No sub-lines printed -
wks:label_prefix = '''' ! Left justify
wks:string = lin:desc ! Just use the straight description
.
DO write_label
DO export_yrs ! Export the yearly amounts
attr_idx += 1
IF exp_tot_ttl ! Were any sub-lines exported?
atb:row_height[attr_idx] = 0 ! Set line height to the default
atb:row_attr [attr_idx] = wat:n_lr[6] ! No - don't use a bottom line
ELSE
atb:row_height[attr_idx] = 21 ! Taller line
atb:row_attr [attr_idx] = wat:b_lrb[6] ! Bold w/ Left, right and bottom borders
wks:row += 1 ! Open up an extra blank (seperator) line after
DO tot_sep_row ! Format it
.
GET(lineitem,cur_ptr) ! Reload the current line
total_line = 0 ! Clear the total line pointer
exp_tot_ttl = false ! and flag
export_yrs ROUTINE ! Export the year columns for the current line item
wks:col = 2 ! Always start in column "C"
LOOP yr_no = 1 TO dcf:years
DO set_lin_fmt ! Set the wks format for the current line
wks:real_no = lin:amount[yr_no]
DO write_real
wks:col += 1
.
wks:row += 1 ! Move down to the next line
write_BOF ROUTINE
sta:msg = 'Creating the spreadsheet for ' & CLIP(dcf:id) & '...'
CLEAR(wks:record) ! Initialize the spreadsheet record
wks:opcode = bof_op ! BOF op code
wks:version = ver_123_2 ! Set to Version 2.x
wks:length = 2 ! Record size (2 bytes)
ADD(wks_file,wks:length +4) ! Write the BOF record (length = data + op code + 123 length)
wysifile(wyf:std_init) ! Do the standard WYSIWYG file
IF mem:status = false ! initialization.
DO cleanup
RETURN
.
std_attr_tab ROUTINE ! Setup the attributes needed for this spreadsheet
CLEAR(wyv:fonts_to_use)
wyv:font_to_use[1] = 6 ! Use WYSIWYG fonts 6 (primary) and 5.
wyv:font_to_use[2] = 5
wysifile(wyf:std_attr) ! Make the standard attribute record for the fonts.
def_window ROUTINE ! Define the main spreadsheet window
CLEAR(wks:window1_info) ! Initialize the spreadsheet record
wks:opcode = window1_def ! Window #1 definition op code
wks:length = 32
top_border = 4 ! Set the #of rows that make up the top
! border. Allow for the fixed company
! and for up to 4 rows for column headers.
IF dcf:title <> '' ! Allow for optional DCF title
top_border += 1
.
LOOP lin_ndx = 1 TO 4 ! Allow for optional title lines
IF prj:header_line[lin_ndx] <> ''
top_border += 1
. .
wks:cursor_row = top_border ! Define the cursor row
wks:cursor_col = 2 ! and column
wks:top_row = top_border ! Define the total row
wks:title_rows = top_border ! Define the #of title rows
wks:cell_format = comma_0_dec ! Set the default numeric format
wks:w1_col_width = 9 ! Set the default column width
wks:screen_cols = 5
wks:screen_rows = 16
wks:br_width_row = 4 ! I'm not sure why these values work but
wks:br_width_col = 4 ! the spreadsheet won't load into 1-2-3
wks:window_width = 53 ! without them!
ADD(wks_file,wks:length +4) ! Write the definition record
set_widths ROUTINE ! Set the column widths
wks:opcode = col_width_op ! Set column width op code
wks:length = 3 ! 123 record length
wks:col_number = 0 ! Column "A" is a blank border
wks:col_width = 1
ADD(wks_file, 7)
wks:col_number = 1 ! "B" is the titles
wks:col_width = SIZE(lin:desc) + 2 ! Allow for indents
ADD(wks_file, 7)
! The yearly amount columns use the default column width of 9
set_lin_fmt ROUTINE ! Set the wks format for the current line
EXECUTE (lin:places +1) ! Set the format to use
wks:format = comma_0_dec
wks:format = comma_1_dec
wks:format = comma_2_dec
wks:format = comma_3_dec
wks:format = comma_4_dec
wks:format = comma_5_dec
wks:format = comma_6_dec
.
write_titles ROUTINE ! Write out the titles
sta:msg = 'Exporting the titles for ' & CLIP(dcf:id) & '...'
wks:label_prefix = ''''
wks:format = BAND(def_format,unprot_cell) ! Unprotect the title data
wks:row = 0 ! Start at the "home" position (B:1)
wks:col = 1
wks:string = UPPER(mem:company_name)
DO write_label ! Write the company name
max_attr = 1 ! Count the title lines written
hdr:dcf_ttl_lin = 0
LOOP lin_ndx = 1 TO 4
IF prj:header_line[lin_ndx] = '' ! Line defined?
IF hdr:dcf_ttl_lin ! No - has the DCF title been exported?
CYCLE ! Yes - don't do it again
ELSE
hdr:dcf_ttl_lin = lin_ndx ! No - export it
IF dcf:title = '' ! Don't export a blank line!
CYCLE
ELSE
wks:string = dcf:title
. .
ELSE
wks:string = prj:header_line[lin_ndx] ! Export the header line
.
max_attr += 1
wks:row += 1
DO write_label
.
wysifile(wyf:first_clustr) ! Setup the first WYSIWYG cluster
LOOP max_attr TIMES ! Set the format for the 1st six rows
wys:row_height[wyv:cluster_row] = 14 ! Row height in points (default)
wys:row_lumps [wyv:cluster_row] = 2 ! 3 LUMPs for this row (relative to 0!)
wys:col_count [wyv:cluster_lump] = 0 ! 1st column (rel to 0!)
wys:attr_style[wyv:cluster_lump] = 0
wyv:cluster_lump += 1
wys:col_count [wyv:cluster_lump] = 0
wys:attr_style[wyv:cluster_lump] = wat:b[6]
wyv:cluster_lump += 1
wys:col_count [wyv:cluster_lump] = 255 - 2
wysifile(wyf:row_end_lump) ! Finish the row and "write" the cluster
.
wks:row += 1
write_hdrs ROUTINE ! Write out the column headings
sta:msg = 'Exporting the headers for ' & CLIP(dcf:id) & '...'
wks:format = BAND(def_format,unprot_cell) ! Unprotect the column header cells
wks:label_prefix = '^' ! Center the column headers
wks:col = 1
wks:label_prefix = '"'
wks:string = 'YEARS'
DO write_label
wks:label_prefix = '^'
LOOP yr_no = 1 TO dcf:years ! Write out the year numbers
wks:col += 1 ! across the top
wks:string = '-' & yr_no & '-'
DO write_label
.
wks:row += 1 ! Next line
wks:col = 1
wks:label_prefix = ''''
wks:string = 'ITEMS'
DO write_label
wks:label_prefix = '^'
year = YEAR(dcf:date)
LOOP yr_no = 1 TO dcf:years ! Write out the years
wks:col += 1 ! across the top
wks:string = year
DO write_label
year += 1
.
wks:row += 2
! WYSIWYG formats for the column headers
wys:row_height[wyv:cluster_row] = 14 ! Row height in points (default)
wys:row_lumps [wyv:cluster_row] = 3 ! 4 LUMPs for this row
wys:col_count [wyv:cluster_lump] = 0 ! Column "A" (rel to 0!)
wys:attr_style[wyv:cluster_lump] = 0
wyv:cluster_lump += 1
wys:col_count [wyv:cluster_lump] = 0 ! "YEARS" title
wys:attr_style[wyv:cluster_lump] = wat:bs_lrtb[6] ! Shaded, bold with complete border
wyv:cluster_lump += 1
wys:col_count [wyv:cluster_lump] = dcf:years - 1 ! Year numbers columns
wys:attr_style[wyv:cluster_lump] = wat:bs_lrt[6] ! Shaded, bold w/ top, left and right borders
wyv:cluster_lump += 1
wys:col_count [wyv:cluster_lump] = 255 - (2 + (dcf:years - 1))
wysifile(wyf:row_end_lump)
wys:row_height[wyv:cluster_row] = 14 ! Row height in points (default)
wys:row_lumps [wyv:cluster_row] = 3 ! 4 LUMPs for this row
wys:col_count [wyv:cluster_lump] = 0 ! Column "A" (rel to 0!)
wys:attr_style[wyv:cluster_lump] = 0
wyv:cluster_lump += 1
wys:col_count [wyv:cluster_lump] = 0 ! "ITEMS" title
wys:attr_style[wyv:cluster_lump] = wat:b_lr_wb[6]
wyv:cluster_lump += 1
wys:col_count [wyv:cluster_lump] = dcf:years - 1 ! Years columns
wys:attr_style[wyv:cluster_lump] = wat:bs_lr_wb[6]
wyv:cluster_lump += 1
wys:col_count [wyv:cluster_lump] = 255 - (2 + (dcf:years - 1))
wysifile(wyf:row_end_lump)
CLEAR(row_attrs) ! Clear the row attributes
attr_idx = 0 ! Init the attribute row counter
DO tot_sep_row
tot_sep_row ROUTINE ! Setup a short, totals seperator WYSIWYG line
attr_idx += 1
atb:row_height[attr_idx] = 7 ! Set line height
atb:row_attr [attr_idx] = wat:n_lr[6] ! Normal w/ Left and right borders
wysi_small ROUTINE ! Write out the formatting for the "Release:" row
! with the smaller font (#5)
wys:row_height[wyv:cluster_row] = 9 ! Row height in points
wys:row_attrs [wyv:cluster_row] = row_fix_hgt ! Mark row as having a non-default row height specified
wys:row_lumps [wyv:cluster_row] = 3 ! 3 LUMPs for this row
wys:col_count [wyv:cluster_lump] = 0 ! Column "A" (rel to 0!)
wys:attr_style[wyv:cluster_lump] = 0
wyv:cluster_lump += 1
wys:col_count [wyv:cluster_lump] = 0
wys:attr_style[wyv:cluster_lump] = wat:no_attr[5] ! Normal, smaller font
wyv:cluster_lump += 1
wys:col_count [wyv:cluster_lump] = 255 - 2
wysifile(wyf:row_end_lump)
end_border ROUTINE ! WYSIWYG formatting the last line of the DCF
wys:row_height[wyv:cluster_row] = 7
wys:row_attrs [wyv:cluster_row] = row_fix_hgt
wys:row_lumps [wyv:cluster_row] = 2 ! 3 LUMPs for this row
wys:col_count [wyv:cluster_lump] = 0 ! Column "A" (rel to 0!)
wys:attr_style[wyv:cluster_lump] = 0
wyv:cluster_lump += 1
wys:col_count [wyv:cluster_lump] = dcf:years
wys:attr_style[wyv:cluster_lump] = wat:n_lr_wb[6] ! Normal w/ Left and right borders, wide bottom border
wyv:cluster_lump += 1
wys:col_count [wyv:cluster_lump] = 255 - (1 + dcf:years)
wysifile(wyf:row_end_lump)
prt_settings ROUTINE ! Setup the WYSIWYG print settings
wysifile(wyf:flush_clustr) ! Must flush out any pending cluster
! record before writing over the
! WYSIWYG record area.
CLEAR(wys:prt_settings)
! Print range:
wys:UpLeftCol = 2 ! C:10 is the upper left corner
wys:UpLeftRow = top_border
wys:LoRghtCol = wys:UpLeftCol + dcf:years - 1 ! Compute the rightmost column of the range
wys:LoRghtRow = range_row ! Last row of the DCF body
wys:RowUpLeftCol = 1 ! Border row range definition
wys:RowUpLeftRow = 0 ! B:1 to B:9
wys:RowLoRghtCol = 1
wys:RowLoRghtRow = top_border - 1
wys:ColUpLeftCol = 1 ! Border Column range definition
wys:ColUpLeftRow = top_border ! B:10
wys:ColLoRghtCol = 1
wys:ColLoRghtRow = top_border
wys:PaperSizeWid = 8500 ! Paper size is 8.5" x 11"
wys:PaperSizeLen = 11000
wys:MarginLeft = 500 ! 1/2" left and
wys:MarginRight = 500 ! right margins
wys:MarginTop = 1000 ! 1" top margin
wys:MarginBot = 500 ! 1/2" bottom margin
wys:print_flags = landscape_on ! Set to landscape
wysifile(wyf:prt_settings) ! Write the settings record
write_label ROUTINE ! Writes out the current label cell
wks:opcode = label_op ! Label op code
wks:string = CLIP(wks:string) & '<00>' ! Add the null terminator (using only '' doesn't work)
wks:length = 6 + LEN(CLIP(wks:string)) ! Record size = 6 bytes + the
! size of the string (with
! the null terminator!)
DO write_cell
write_real ROUTINE ! Writes out a real number cell
wks:opcode = floating_op ! Floating (real) op code
wks:length = 13 ! Total data length = cell format code(1 byte)
! + row (2 bytes)
! + col (2 bytes)
! + data (8 bytes)
DO write_cell
write_int ROUTINE ! Writes out an integer # cell
wks:opcode = integer_op ! Integer op code
wks:length = 7 ! Total data length = cell format code(1 byte)
! + row (2 bytes)
! + col (2 bytes)
! + data (2 bytes)
DO write_cell
write_cell ROUTINE ! Writes the current cell record
sta:row = wks:row + 1 ! Show the row written
IF wks:col < 26
sta:col = ' ' & CHR(65 + wks:col) ! Show the column letter(s) written
ELSE
col_offset = INT((wks:col - 1) / 25) ! Compute the group# (Ax,Bx,Cx,etc.)
sta:col = CHR(64 + col_offset) & | ! Display the group letter
CHR(64 + (wks:col - (col_offset * 25)) ) ! and the sub-group letter (AA,AB,AC,etc)
.
ADD(wks_file, 4 + wks:length) ! Write the cell record. Total bytes
! written = op code (2 bytes)
! + length (2 bytes)
! + data (x bytes)
abort_check ROUTINE
LOOP UNTIL NOT KEYBOARD() ! Look for keystroke
ASK ! Get keycode if there is one
IF (KEYCODE() = reject_key) OR | ! On Shift+Esc
(KEYCODE() = ctrl_esc) ! or Ctrl+Esc
BEEP
OPEN(msg_box); msg_text = 'Aborting. Just a moment...'
DO cleanup
disp_msg('The exporting was aborted as requested.')
mem:status = false
RETURN
. .
cleanup ROUTINE
DO write_EOF ! Write the end of file record
CLOSE(wks_file) ! Close the spreadsheet file
CLOSE(wys_file) ! Close the WYSIWYG format file
CLOSE(msg_box) ! Clear whatever message was displayed
sta:exp_cnt = exp_cnt ! Display the final record counts
sta:esc_msg = ''
write_EOF ROUTINE ! Write a standard 1-2-3 EOF record
wks:opcode = eof_op
wks:length = 0
ADD(wks_file, 4)
wysifile(wyf:eof) ! Write the WYSIWYG EOF record and close it