! sylk_demo.sqr - Demonstration program for sylk.sqc
! Copyright (C) 2004 Fastenal Company
!
! This program is free software; you can redistribute it and/or modify
! it under the terms of the GNU General Public License as published by
! the Free Software Foundation; either version 2 of the License, or
! (at your option) any later version.
!
! This program is distributed in the hope that it will be useful,
! but WITHOUT ANY WARRANTY; without even the implied warranty of
! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
! GNU General Public License for more details.
!
! You should have received a copy of the GNU General Public License
! along with this program; if not, write to the Free Software
! Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
!
! Author: Jim Womeldorf (jim.womeldorf@gmail.com)
! 2366 Siewers Spring Rd
! Decorah, IA 52101
!
! $Id: sylk_demo.sqr,v 1.6 2007/03/19 17:08:47 rayo Exp rayo $
!
! $Log: sylk_demo.sqr,v $
! Revision 1.6 2007/03/19 17:08:47 rayo
! updated jim's email address at his request.
!
! Revision 1.5 2004/07/23 21:06:20 rayo
! Added Jim's physical address
!
! Revision 1.4 2004/07/13 18:40:03 rayo
! fixed Jim's e-mail address
!
! Revision 1.3 2004/07/13 18:21:41 rayo
! added copyright notice
!
!
begin-program
do SYLK-Demo
end-program
#include 'sylk.sqc'
Begin-Procedure SYLK-Demo
! This procedure creates a nonsense spreadsheet for the purpose of demonstrating
! the use of the sylk include file routines.
! Any resemblance to a 'real' spreadsheet, living or dead, is purely coincidental :)
! The following is a list of the 'public' procedures which are designed to be called by an SQR.
! Sylk-Initialize-File($FileName, #FileNumber)
! Sylk-Close-File(#FileNumber)
! Sylk-Format-Cell-To-Date(#FileNumber, #Row, #Col, $DateFormat, $Justification)
! Sylk-Format-Cell-To-General(#FileNumber, #Row, #Col, $Justification)
! Sylk-Format-Cell-To-Number(#FileNumber, #Row, #Col, #Decimals, $CommasYN, $DollarsYN, $Justification)
! Sylk-Format-Cell-To-Percentage(#FileNumber, #Row, #Col, #Decimals, $Justification)
! Sylk-Format-Cell-To-Text(#FileNumber, #Row, #Col, $Justification)
! Sylk-Format-Column-To-Date(#FileNumber, #Col, $DateFormat, $Justification)
! Sylk-Format-Column-To-General(#FileNumber, #Col, $Justification)
! Sylk-Format-Column-To-Number(#FileNumber, #Col, #Decimals, $CommasYN, $DollarsYN, $Justification)
! Sylk-Format-Column-To-Percentage(#FileNumber, #Col, #Decimals, $Justification)
! Sylk-Format-Column-To-Text(#FileNumber, #Col, $Justification)
! Sylk-Format-Row-To-Date(#FileNumber, #Row, $DateFormat, $Justification)
! Sylk-Format-Row-To-General(#FileNumber, #Row, $Justification)
! Sylk-Format-Row-To-Number(#FileNumber, #Row, #Decimals, $CommasYN, $DollarsYN, $Justification)
! Sylk-Format-Row-To-Percentage(#FileNumber, #Row, #Decimals, $Justification)
! Sylk-Format-Row-To-Text(#FileNumber, #Row, $Justification)
! Sylk-Set-Cell-Font(#FileNumber, #Row, #Col, #Size, $BoldItalic)
! Sylk-Set-Column-Font(#FileNumber, #Col, #Size, $BoldItalic)
! Sylk-Set-Column-Width(#FileNumber, #Col, #Width)
!
! Sylk-Set-Row-Font(#FileNumber, #Row, #Size, $BoldItalic)
! Sylk-Write-Date(#FileNumber, #Row, #Col, $Date)
! Sylk-Write-Formula(#FileNumber, #Row, #Col, $Formula)
! Sylk-Write-Month-Year-Column-Headings(#FileNumber, #Row, #StartCol, #RepeatCols, $StartDate, $EndDate, $Format, :#NextCol)
! Sylk-Write-Number-Suppress-Zero(#FileNumber, #Row, #Col, #Number)
! Sylk-Write-Number(#FileNumber, #Row, #Col, #Number)
! Sylk-Write-Text(#FileNumber, #Row, #Col, $Text)
! Sylk-Column-Number-To-Alpha(#ColumnIn, $YNColAbsolute, :$ColumnOut)
! Sylk-Get-Margin-Formula($CostCell, $PriceCell, :$Formula)
! Sylk-Get-Margin(#Cost, #Price, :#Margin)
! Sylk-Get-Safe-Division-Formula($Dividend, $Divisor, :$Formula)
! Sylk-Get-Worksheet-Filename($BaseFileName, #ProcessInstance, #WorksheetNumber, :$WorksheetFileName)
! Sylk-Row-Number-Column-Number-To-Alpha(#RowIn, $YNRowAbsolute, #ColumnIn, $YNColAbsolute, :$RowColumnOut)
!:)(::)(::)(::)(::)(::)(::)(::)(::)(::)(::)(::)(::)(::)(::)(::)(::)(::)(::)(::)
Let $FileName = 'sylk_demo.xls' !I give files the XLS extension so Excel automatically opens them.
Let #FileNumber = 1
! To open a file for writing, call Sylk-Initialize-File.
! Multiple files can be opened at the same time.
Do Sylk-Initialize-File($FileName, #FileNumber)
Let #Col = #Col + 1
Let $Justification = 'L'
Do Sylk-Format-Column-To-Text(#FileNumber, #Col, $Justification)
Let #Width = 8
Do Sylk-Set-Column-Width(#FileNumber, #Col, #Width)
Let #Col = #Col + 1
Let $DateFormat = 'd-mon-yyyy' !must be one of the formats specified in the include file
Let $Justification = 'R'
Do Sylk-Format-Column-To-Date(#FileNumber, #Col, $DateFormat, $Justification)
Let #Width = 10
Do Sylk-Set-Column-Width(#FileNumber, #Col, #Width)
Let #Col = #Col + 1
Let #Decimals = 2
Let $CommasYN = 'Y'
Let $DollarsYN = 'Y'
Let $Justification = 'R'
Do Sylk-Format-Column-To-Number(#FileNumber, #Col, #Decimals, $CommasYN, $DollarsYN, $Justification)
Let #Width = 12
Do Sylk-Set-Column-Width(#FileNumber, #Col, #Width)
Let #Col = #Col + 1
Let #Decimals = 4
Let $Justification = 'R'
Do Sylk-Format-Column-To-Percentage(#FileNumber, #Col, #Decimals, $Justification)
Let #Width = 20
Do Sylk-Set-Column-Width(#FileNumber, #Col, #Width)
!HEADINGS
Let #Row = 1
Let #Size = 12
Let $BoldItalic = 'BI'
Do Sylk-Set-Row-Font(#FileNumber, #Row, #Size, $BoldItalic)
Let #Col = 1
Let $Text = 'TEXT'
Do Sylk-Write-Text(#FileNumber, #Row, #Col, $Text)
Let #Col = #Col + 1
Let $Text = 'DATE'
Do Sylk-Write-Text(#FileNumber, #Row, #Col, $Text)
Let #Col = #Col + 1
Let $Text = 'NUMBER'
Do Sylk-Write-Text(#FileNumber, #Row, #Col, $Text)
Let #Col = #Col + 1
Let $Text = 'PERCENTAGE'
Do Sylk-Write-Text(#FileNumber, #Row, #Col, $Text)
!DATA
Let #Row = 2
Let #Col = 1
Let $Text = 'Hello'
Do Sylk-Write-Text(#FileNumber, #Row, #Col, $Text)
Let #Col = #Col + 1
Let $Date = '20040401'
Do Sylk-Write-Date(#FileNumber, #Row, #Col, $Date)
Let #Col = #Col + 1
Let #Number = 25.1234567
Do Sylk-Write-Number-Suppress-Zero(#FileNumber, #Row, #Col, #Number)
Let #Col = #Col + 1
Let #RowIn = #Row
Let $YNRowAbsolute = 'N'
Let #ColumnIn = #Col - 1
Let $YNColAbsolute = 'N'
Do Sylk-Row-Number-Column-Number-To-Alpha(#RowIn, $YNRowAbsolute, #ColumnIn, $YNColAbsolute, $RowColumnOut)
! show '$RowColumnOut ' $RowColumnOut
Let $Formula = '= ' || $RowColumnOut || ' / 100'
! show '$Formula ' $Formula
Do Sylk-Write-Formula(#FileNumber, #Row, #Col, $Formula)
! Each file must be closed properly to signal Sylk that the end of the file has been found
Do Sylk-Close-File(#FileNumber)
End-Procedure ! SYLK-Demo