#! /usr/local/bin/apl --script ⍝ ******************************************************************** ⍝ wp_example_session.apl; Script to demonstrate how to use workspace wp. ⍝ Copyright (C) 2019 Bill Daly ⍝ 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 3 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, see . ⍝ ******************************************************************** )load 1 wp )copy_once 5 DALY/import )copy_once 5 DALY/export )copy_once 5 DALY/find_test_data )copy_once 5 FILE_IO sink←FIO∆mkdir_777 '/tmp/wp_test' t1←import∆file test_data,'/RestrAccts.txt' t2←wp∆init 'Acct 1320' t2←t2 wp∆setData t1 t2←t2 wp∆setHeading 'Sec. 202 Partners' 'Reserve for Replacements' 'Year Ended 12/31/2018' t2←t2 lex∆assign 'Author' 'amd' t2←t2 wp∆attr∆setQuadAttr 1 1 1 8,⊂lex∆from_alist 'class' 'colhead' t2←t2 wp∆attr∆setQuadAttr 2 3 22 8,⊂lex∆from_alist 'class' 'number' 'format' 'BM/(/N/)/CF12.2' ⍝ We need to place a line above the total, and a double line ⍝ below. Hence a new class for the style sheet. tr1←wp∆ssc∆init 'total' tr1←tr1 wp∆ssc∆assignProp 'border-top' 'solid 1pt black' tr1←tr1 wp∆ssc∆assignProp 'border-bottom' 'double 3pt black' tr1←tr1 wp∆ssc∆assignProp 'text-align' 'right' t2←t2 wp∆setStylesheet (wp∆getStylesheet t2) wp∆ss∆assignClass tr1 t2←t2 wp∆attr∆setQuadAttr 12 3 12 8,⊂lex∆from_alist 'class' 'total' 'format' 'M/(/N/)/CF12.2' ⍝ Create html file from t2 (wp∆html∆assemble t2) utf8∆write '/tmp/wp_test/test01_wp.html' ⍝ Create a plant ledger pl←wp∆init 'Plant Ledger' pl←pl wp∆setData import∆file test_data,'/plant_ledger.txt' pl←pl wp∆setHeading 'Bad Example, Inc.' 'Plant Ledger' '12/31/2018' pl←pl wp∆attr∆setQuadAttr 1 1 1 6,⊂lex∆from_alist 'class' 'colhead' pl←pl wp∆attr∆setQuadAttr 2 1 25 1,⊂lex∆from_alist 'class' 'number' 'format' 'I5' pl←pl wp∆attr∆setQuadAttr 2 4 25 4,⊂lex∆from_alist 'class' 'number' 'format' 'CF10.2' pl←pl wp∆attr∆setQuadAttr 2 5 25 5,⊂lex∆from_alist 'class' 'number' 'format' 'I3' pl←pl wp∆setInitialFlag 0 ⍝ Create file from pl (wp∆html∆assemble pl) utf8∆write '/tmp/wp_test/test02_wp.html' ⍝ Create a trial balance extb←wp∆init 'TB' extb←extb wp∆setHeading 'Example Sec 202 Housing' 'Trial Balance' '12/31/2018' extb←extb wp∆setData import∆file test_data,'/example_tb.txt' extb←extb wp∆attr∆setQuadAttr 1 1 1 3 ,⊂lex∆from_alist 'class' 'colhead' extb←extb wp∆attr∆setQuadAttr 2 3 182 3,⊂lex∆from_alist 'class' 'number' 'format' 'BM/(/N/)/CF14.2' extb←extb wp∆attr∆setQuadAttr 2 1 181 1,⊂lex∆from_alist 'class' 'number' 'format' 'I6' extb←extb wp∆attr∆setQuadAttr 182 3 182 3 ,⊂lex∆from_alist 'class' 'total' 'format' 'BM/(/N/)/CF14.2' extb←extb wp∆setStylesheet (wp∆getStylesheet extb) wp∆ss∆assignClass tr1 ⍝ Create a file from extb (wp∆html∆assemble extb) utf8∆write '/tmp/wp_test/test03_wp.html' ⍞←'Files test01_wp∆tml, test02_wp.html, and test03_wp.html are saved in /tmp/wp_test',⎕TC[3]