System Building with APL + Win System Building with APL + Win A. Askoolum © 2006 Research Studies Press Limited . ISBN: 0-470-03020-8 www.it-ebooks.info RSP SERIES IN INDUSTRIAL CONTROL, COMPUTERS AND COMMUNICATIONS Series Editor: Professor Derek R. Wilson Concurrent Engineering – The Agenda for Success Edited by Sa’ad Medhat Analysis and Testing of Distributed Software Applications Henryk Krawczyk and Bogdan Wiszniewski Interface Technology: The Leading Edge Edited by Janet M. Noyes and Malcolm Cook CANopen Implementation: Applications to Industrial Networks Mohammad Farsi and Manuel Bernado Martins Barbosa J: The Natural Language for Analytic Computing Norman Thomson Digital Signal Processing: A MATLAB-Based Tutorial Approach John Leis Mathematical Computing in J: Introduction, Volume 1 Howard A. Peelle System Building with APL + Win Ajay Askoolum Multimedia Engineering: A Practical Guide for Internet Implementation A.C.M. Fong and S.C. Hui, with contributions from G. Hong and B. Fong www.it-ebooks.info System Building with APL + Win Ajay Askoolum Claybrook Computing Limited, UK John Wiley & Sons, Ltd Research Studies Press Limited www.it-ebooks.info Copyright © 2006 Research Studies Press Limited, 16 Coach House Cloisters, 10 Hitchin Street, Baldock, Hertfordshire, SG7 6AE Published by John Wiley & Sons, Ltd., The Atrium, Southern Gate, Chichester, West Sussex PO19 8SQ, England Telephone (+44) 1243 779777 Email (for orders and customer service enquiries): cs-books@wiley.co.uk Visit our Home Page on www.wiley.com This Work is a co-publication between Research Studies Press Limited and John Wiley& Sons, Ltd. All Rights Reserved. No part of this publication may be reproduced, stored in a retrieval system or transmitted in any form or by any means, electronic, mechanical, photocopying, recording, scanning or otherwise, except under the terms of the Copyright, Designs and Patents Act 1988 or under the terms of a licence issued by the Copyright Licensing Agency Ltd, 90 Tottenham Court Road, London W1T 4LP, UK, without the permission in writing of the Publisher. Requests to the Publisher should be addressed to the Permissions Department, John Wiley & Sons Ltd, The Atrium, Southern Gate, Chichester, West Sussex PO19 8SQ, England, or emailed to permreq@wiley.co.uk, or faxed to (+44) 1243 770620. Designations used by companies to distinguish their products are often claimed as trademarks. All brand names and product names used in this book are trade names, service marks, trademarks or registered trademarks of their respective owners. The Publisher is not associated with any product or vendor mentioned in this book. This publication is designed to provide accurate and authoritative information in regard to the subject matter cov- ered. It is sold on the understanding that the Publisher is not engaged in rendering professional services. If professional advice or other expert assistance is required, the services of a competent professional should be sought. Other Wiley Editorial Offices John Wiley & Sons Inc., 111 River Street, Hoboken, NJ 07030, USA Jossey-Bass, 989 Market Street, San Francisco, CA 94103-1741, USA Wiley-VCH Verlag GmbH, Boschstr. 12, D-69469 Weinheim, Germany John Wiley & Sons Australia Ltd, 42 McDougall Street, Milton, Queensland 4064, Australia John Wiley & Sons (Asia) Pte Ltd, 2 Clementi Loop #02-01, Jin Xing Distripark, Singapore 129809 John Wiley & Sons Canada Ltd, 22 Worcester Road, Etobicoke, Ontario, Canada M9W 1L1 Wiley also publishes its books in a variety of electronic formats. Some content that appears in print may not be available in electronic books. British Library Cataloguing in Publication Data A catalogue record for this book is available from the British Library ISBN-13 978-0-470-03020-2 (PB) ISBN-10 0-470-03020-8 (PB) Typeset in 10/12pt Times New Roman by Laserwords Private Limited, Chennai, India Printed and bound in Great Britain by TJ International, Padstow, Cornwall This book is printed on acid-free paper responsibly manufactured from sustainable forestry in which at least two trees are planted for each one used for paper production. www.it-ebooks.info T ABLE OF C ONTENTS Editorial Foreword xvii Preface xviii Acknowledgements xx Chapter 1 - System Building Overview 1 1.1 Why APL? 1 1.1.1 APL platforms 2 1.1.2 APL isolation 3 1.1.3 APL generations 3 1.2 Which APL? 4 1.2.1 APL: a renewed promise 5 1.2.2 The nature of APL GUI 5 1.2.3 The user interface 6 1.2.4 Design architecture 7 1.2.5 Component-based software 7 1.2.6 Multi-Language programming 8 1.3 The n-tier model 8 1.3.1 Presentation services tier 8 1.3.2 Business services tier 9 1.3.3 Data services tier 9 1.3.4 Tier demarcation 9 1.4 Prevailing design architecture 10 1.4.1 Client/Server computing 10 1.4.2 The multi-user client/server 10 1.4.3 Object Oriented Programming(OOP) 11 1.4.4 Collaborative processing 13 1.5 APL interface to components 14 1.5.1 Static (or early) binding 14 1.5.2 Dynamic (or late) binding 14 1.5.3 Object attributes 14 1.5.4 Object prefixes 14 1.6 Structured Query Language (SQL) 16 1.6.1 Relational Database Management System 16 1.6.2 SQL origin 17 1.6.3 SQL language 17 1.7 The Windows Registry 18 1.8 Regional settings 19 1.8.1 The GetLocaleInfo API call 20 1.8.2 API usage 20 1.9 Software development 22 1.9.1 Absence of design certification 22 1.9.2 Quality: the crucial measure 22 1.9.3 Version control 22 1.9.4 Customisation 23 1.10 APL and Windows API 23 1.10.1 Verifying API definitions 24 www.it-ebooks.info TABLE OF CONTENTS vi 1.10.2 Processing API memory pointers 24 1.10.3 Processing API call back 24 1.10.4 Processing API errors 25 1.11 The future challenge 25 Chapter 2 - Advanced APL Techniques 27 2.1 Removing legacy code clutter 28 2.1.1 Boolean scenario (BS) table 28 2.1.2 A simple task: copy a file 28 2.1.3 An API solution 29 2.1.4 An APL solution 29 2.1.5 The general BS case 31 2.1.6 Auto generating the BS table 32 2.1.7 Where to use BS tables? 32 2.2 Bit-wise Boolean techniques 34 2.2.1 BitEQV 34 2.2.2 BitIMP 35 2.2.3 BitAND 35 2.2.4 BitXOR 37 2.2.5 BitOR 37 2.2.6 BitNAND 37 2.2.7 BitNOR 37 2.3 Managing workspace variables 37 2.3.1 APL is not a relational data source 38 2.3.2 Fabricating a record set object 39 2.4 Generating test data 47 2.4.1 Dates 47 2.4.2 Integers 48 2.4.3 Floating point 48 2.4.4 Codes 49 2.4.5 String 49 2.4.6 Binary string 49 2.4.7 Numeric vector 50 2.4.8 Computations on generated data 50 2.5 APL+Win as an ActiveX Server 52 2.5.1 Dynamic properties and methods 52 2.5.2 Which class of APL+Win? 53 2.6 Debugging applications 55 2.6.1 The CSBlocks function 57 2.7 Functions with methods 60 Chapter 3 - Application Interface 61 3.1 Managing the hidden interface 61 3.1.1 Forcing a session to terminate 62 3.2 The user interface 63 3.2.1 Purpose of the user interface 64 3.2.2 Hierarchical and sequential 64 3.2.3 Invasive interaction 65 3.3 The user interface is the application 65 www.it-ebooks.info TABLE OF CONTENTS vii 3.3.1 Where is the interface? 66 3.3.2 Manage user expectations 66 3.3.3 The user interface as a tier 66 3.4 APL+Win design safeguards 67 3.5 Context sensitive help 67 3.5.1 Enabling a help facility in APL+Win 68 3.5.2 Tooltips and prompts 68 3.5.3 What's this help? 69 3.5.4 Help: WINHELP 70 3.5.5 Help: HTML 71 3.6 Help format as a user option 71 3.7 Application messages 72 3.7.1 The language and location of messages 72 3.7.2 Communicating runtime messages 73 3.8 User-defined properties of the system object 78 3.9 The scope of user documentation 78 3.9.1 Types of documentation 79 3.10 Designing menus 80 3.10.1 Auto-generation of the user interface 81 3.10.2 Validating an interface tree 82 3.10.3 Creating menus 83 3.11 Designing forms 86 3.11.1 Enumerating an existing interface tree 86 3.11.2 Resizing forms 92 3.12 Access control 93 3.12.1 File-based applications 94 3.12.2 Database applications 96 3.13 Empower the user 96 3.13.1 Prevent rather than trap errors 96 3.13.2 Validate user entries 96 3.13.3 Intrusive application messages 96 3.13.4 Work with platform features 96 3.13.5 Tools | Options 96 3.13.6 Navigation 96 3.13.7 System legacy 97 3.13.8 Functionality alone is not enough 97 3.14 Sales considerations 97 3.15 Application exit 98 Chapter 4 - Working with Windows 99 4.1 The APL legacy 99 4.1.1 Reinventing the wheel 100 4.2 Windows resources 101 4.3 API calls 101 4.3.1 Replacing APL code by API calls 102 4.3.2 API calls to simplify code 102 4.3.3 Formatting date and time 102 4.3.4 Using GetDateFormat and GetTimeFormat APIs 107 www.it-ebooks.info TABLE OF CONTENTS viii 4.3.5 APL+Win GetDateFormat 108 4.3.6 Fail safe date format translation? 110 4.4 The Windows Script Host (WSH) 111 4.4.1 Managing the Windows Registry 112 4.4.2 Writing using WScript Shell 112 4.4.3 Reading using WScript Shell 113 4.4.4 Deleting using WScript Shell 113 4.4.5 Writing using Registry API 114 4.4.6 Special folders 116 4.4.7 Environment variables 117 4.4.8 Setting/Reading environment variables 118 4.4.9 Deleting an environment variable 118 4.5 Creating a shortcut 119 4.5.1 Starting another application 120 4.6 Intelligent file operations with API calls 120 4.6.1 DeleteFile API 120 4.6.2 PathFileExists API 121 4.6.3 _lOpen API 121 4.6.4 _lClose API 121 4.6.5 Fail safe deletion status 122 4.7 Universal Naming Convention (UNC) 124 4.7.1 APL and UNC names 124 4.7.2 API calls for handling UNC 124 4.7.3 UNC dynamic mapping 124 4.7.4 Library/UNC mapping 126 4.8 Application configuration 127 4.9 Using INI files with APL 128 4.9.1 Location of the INI file 129 4.9.2 Name of section 129 4.9.3 Name of key 129 4.9.4 Limitations of INI files 129 4.9.5 Implementing the control mechanism 129 4.9.6 INI file: writing a key 130 4.9.7 INI file: reading a key 130 4.9.8 INI file: writing a section 131 4.9.9 INI file : emumerating the names of all sections 131 4.9.10 INI file: reading a section 131 4.9.11 INI file: enumerate names of all keys in a section 132 4.9.12 INI file: enumerate values of all keys in a section 132 4.9.13 Two more APIs 132 4.10 XML files for application configuration 132 4.10.1 The XMLINI function 133 4.10.2 Loading/Creating an XML file 133 4.10.3 XML file: writing a key 135 4.10.4 XML file: reading a key 137 4.10.5 XML file: deleting a key 137 4.10.6 XML file: writing a section 137 4.10.7 XML file: reading a section 138 www.it-ebooks.info TABLE OF CONTENTS ix 4.10.8 XML file: commenting a section 138 4.10.9 XML file: deleting a section 139 4.10.10 XML file: enumerate names of all sections 139 4.10.11 XML file: enumerate names of all keys in a section 140 4.10.12 XML file: enumerate values of all keys in a section 140 4.10.13 Saving an XML file 141 4.11 INI/XML comparative advantage 141 4.11.1 Converting INI to XML 141 4.12 The filing system 142 4.12.1 Identifying the filing system 142 4.12.2 The File System Object 143 4.13 Platform enhancements 144 Chapter 5 - The Component Object Model 145 5.1 Objects are global 145 5.2 APL+Win COM event handling 145 5.2.1 COM event arguments 147 5.2.2 Is RPC Server available? 150 5.3 The promise of COM development 151 5.4 Types of COM components 152 5.4.1 Application components 152 5.4.2 GUI components 153 5.4.3 'Silent' or 'slave' components 153 5.4.4 Custom component 153 5.4.5 Component visibility 153 5.5 Maintaining objects 154 5.6 APL+Win and ActiveX components 154 5.6.1 Platform components 156 5.6.2 Opaque APL syntax 157 5.6.3 Anatomy of the APL+Win syntax 157 5.6.4 Hierarchy of objects 157 5.6.5 Data incompatibilities 158 5.6.6 APL index origin 158 5.7 APL+Win post version 4.0 ActiveX syntax 159 5.7.1 Objects hierarchy using redirection 159 5.7.2 Redirection clutter 159 5.7.3 Dynamic syntax 160 5.7.4 Hierarchical syntax 161 5.7.5 Redirection or enumeration? 164 5.8 ActiveX typed parameters 169 5.8.1 Boolean parameters 169 5.8.2 Positional parameters 169 5.8.3 Passing object pointers 170 5.8.4 Typed data parameters 170 5.8.5 Passing selective named parameters 171 5.8.6 Rogue objects 172 5.9 Development environment features 173 5.9.1 User-defined properties 173 www.it-ebooks.info TABLE OF CONTENTS x 5.10 Using ActiveX asynchronously 174 5.10.1 Custom properties 175 5.11 Debugging components 176 5.11.1 VB for Application code 176 5.11.2 VB code 176 Chapter 6 - Mixed Language Programming 179 6.1 Application extension trade-offs 179 6.2 VB ActiveX DLLs 181 6.3 A sample ActiveX DLL project 181 6.3.1 The DLLFunctionsModule module 181 6.3.2 The DLLFunctions class 182 6.4 Using VBDLLINAPL.DLL 182 6.4.1 Syntax issues 183 6.4.2 Querying the events in VBDLLINAPL 183 6.4.3 Querying the properties in VBDLLINAPL 184 6.4.4 Querying the methods in VBDLLINAPL 185 6.4.5 XCurrencySymbol 186 6.4.6 XDateCompare 186 6.4.7 XDateScalar 187 6.4.8 XDateValid 188 6.4.9 XDaysOfWeek 189 6.4.10 XFindReplace 190 6.4.11 XGetAgeAttQ 190 6.4.12 XGetDatePart 191 6.4.13 XGetDateTime 191 6.4.14 XGetLocal 192 6.4.15 XGetTimeStamp 193 6.4.16 XMonthsOfYear 194 6.4.17 XNumberValid 195 6.4.18 XSpellDate 195 6.4.19 XStringCase 196 6.4.20 Getting help on syntax 197 6.5 Processing APL+Win arrays 197 6.6 Deploying ActiveX DLLs 198 6.6.1 Name and location 199 6.6.2 General availability 199 6.6.3 Updrading/Replacing ActiveX DLLs 200 6.6.4 ActiveX DLL coding for APL 201 6.7 Building a DLL for APL using C# Express 2005 202 6.7.1 Using the C# DLL 204 6.7.2 Deploying C# DLLs 205 Chapter 7 - Application Extension using Scripting 207 7.1 The APL/VBScript affinity 207 7.1.1 The VBScript built-in functions 208 7.1.2 Adding the Script Control 208 7.1.3 An algebraic expression evaluator 209 7.2 Error trapping 211 www.it-ebooks.info [...]... Sharing an APL+ Win object 222 7.5.2 Creating own instance of APL+ Win object 223 7.5.3 Processing simple numeric arrays 224 7.5.4 Passing arguments to built-in functions 228 7.6 Sharing with the APL Grid object 232 7.7 Concurrent sharing with the Script Control 233 7.8 APL+ Win and HTML 234 7.8.1 Creating/Displaying HTML file from APL+ Win ... component are prefixed with lowercase 'x', the methods with uppercase 'X' and for APL+ Win, the events need to be prefixed with 'onX' The 'x' and 'X' prefixes may be omitted in circumstances when doing so does not create a conflict with a like named native APL+ Win or APLX GUI method, property, or event Strictly speaking, the prefixes are not necessary unless the object and APL+ Win or APLX have like named... properties of controls APL+ Win and APLX share a common syntax and make all standard controls available via one system call (Œwi) providing access to all properties, methods, and events The five lines of code in the function executed—sequentially—in immediate mode produce the form shown in Figure 1-2 APL+ Win Hello World [1] [2] [3] [4] ’ HelloWorld;Œwself © System Building With APL+ Win Œwself„'HelloWorld'... platforms • APL2 000 (www .apl2 000.com) acquired APL* PLUS III from Manugistics and renamed it APL+ Win They continue to develop it for the Windows and other platforms IBM has placed TryAPL2 in the public domain: TryAPL2 is a cut-down secondgeneration APL Its IDIOMS workspace contains powerful second-generation APL idioms The original APL* PLUS/PC is also in the public domain as APL/ SE Several international APL. .. is without doubt easier with the availability of Windows resources in the workspace of a platform compliant APL Should APL developers adopt the credentials of the Windows platform—become compliant Windows citizens—and deliver the promise of rapid application development, APL delivers a renewed promise: it is the tool of choice for contemporary rapid software development, especially so APL + Win with. .. annually, keeping APL in the frame There is now a renewed opportunity for APL system development to fall into line with industry standards simply because APL itself is now in line with industry standards 1.1.2 APL isolation APL+ Win has its roots in APL* PLUS/PC which was first available in 1982 for personal computers—this product was ported from a mainframe version developed during the 1970's APL development... 293 9.6.5 APLServer class code 293 9.6.6 The APL server toolbar 297 9.6.7 The initial ActiveX server workspace 297 9.7 The EWA model in action 298 9.8 Transferring APL+ Win data to Excel 302 9.9 Automation issues 304 9.9.1 APL+ Win issues 304 9.10 Why use Excel with APL? 304 Chapter 10 - Working with Word ... compatibility with IBM's APL2 Core, or first generation, APL is consistent across APL interpreters from different vendors Vendors have implemented extensions to the language in their own unique way, including the way the standard Windows GUI is available The integration of COM support within the APL interpreter has established APL as a team player on the Windows platform: with this advancement, APL can use... collaborate with nor any system wide resources such as Windows Application Programming Interfaces (API); Windows APIs are a set of pre-programmed functions available on the Windows platform Contemporary APL is fully empowered to exploit platform resources, right out of the box The first generation APL developer had a pathway to any Disk Operating System (DOS) function either via dedicated APL system functions... on the Windows platform Currently, there are at least six competing commercial APL vendors with offerings for Windows, MAC OS, LINUX, UNIX, and mainframes: • IBM developed APL2 (www.ibm.com/software/awdtools /apl) for the mainframe and ported it to run virtually unchanged on a Windows PC This interpreter is also available for AIX and Sun Solaris www.it-ebooks.info System Building Overview 3 • APLX (www.microapl.co.uk /apl) . System Building with APL + Win System Building with APL + Win A. Askoolum © 2006 Research Studies Press Limited . ISBN:. with the Script Control 233 7.8 APL+ Win and HTML 234 7.8.1 Creating/Displaying HTML file from APL+ Win 236 7.8.2 Taking control of HTML content 238 7.8.3 APL+ Win and XML 239 Chapter 8 - Windows. 1 - System Building Overview 1 1.1 Why APL? 1 1.1.1 APL platforms 2 1.1.2 APL isolation 3 1.1.3 APL generations 3 1.2 Which APL? 4 1.2.1 APL: a renewed promise 5 1.2.2 The nature of APL