m204 Appl Dev Guide

Download m204 Appl Dev Guide

Post on 29-Nov-2014

129 views

Category:

Documents

11 download

Embed Size (px)

TRANSCRIPT

Model 204

Application Development Guide

Version 7 Release 1.0

ADG71

Computer Corporation of AmericaCorporate Headquarters: 200 West Street 3rd Floor West Waltham, MA 02451 USA Phone: Fax: (781) 466-6601 (781) 466-6641 CCA International: First Floor, Edinburgh House 43-51 Windsor Road Slough, Berkshire SL1 2EE England Phone: Fax: +44-1753-472800 +44-1753-472888

Model 204 Application Development Guide Document Number ADG71 May 6, 2009 Copyright 19882009 Computer Corporation of America. All rights reserved. Printed in the United States of America. Access/204, Advantage/SQL, CCA Analytics, Connect , Dictionary/204, JDBC for Model 204, MP/204, MQ/204, PQO/204, and Workshop/204 are trademarks, and ACCOLADE, Imagine, MarketPulse, Model 204, and 204 are registered trademarks of Computer Corporation of America. IBM is a registered trademark of International Business Machines, Inc. Java and JDBC are registered trademarks of Sun Microsystems, Inc. Windows and .NET Framework are registered trademarks of Microsoft Corporation. Other trademarks and trade names are used to identify entities claiming the marks and names of their products and are hereby acknowledged. Any rights not expressly granted herein are reserved. Permission to use this technical documentation (the Document) retrieved from the Computer Corporation of Americas (CCA) server is granted, provided that (1) the copyright notice in the document appears on all copies, (2) use of this Document is for informational and noncommercial or personal and internal use only, and (3) no modifications are made to this Document. Use, duplication, or disclosure by the Government is subject to restrictions as set forth in subparagraph (c)(1)(ii) of the Rights in Technical Data and Computer Software clause at DFARS 252.227-7013. CCA makes no representations about the suitability of the information contained in the Document. THIS DOCUMENT IS BEING PROVIDED TO YOU AS IS ACCORDINGLY, CCA MAKES NO WARRANTY AS TO ITS ACCURACY OR ITS USE.CCA HEREBY DISCLAIMS ALL WARRANTIES AND CONDITIONS WITH REGARD TO THIS DOCUMENT, INCLUDING ALL IMPLIED WARRANTIES AND CONDITIONS OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT SHALL CCA BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF INFORMATION CONTAINED IN THIS DOCUMENT. Any use of the technical documentation or the information contained herein is at the risk of the user. This document may include technical or other inaccuracies or typographical errors. Changes are periodically added to this Document and CCA reserves the right to improve or make changes to the document at any time and without prior notice.

ContentsModel 204

Application Development GuidePrefaceAudience .................................................................................................................. vii Introducing Model 204 electronic documentation..................................................... vii Contacting CCA Customer Support ....................................................................... i-vii Notation conventions............................................................................................... viii

1 Model 204 Naming ConventionsIn this chapter......................................................................................................... 1-1 Model 204 filenames ................................................................................................... 1-2 Dataset names ............................................................................................................ 1-3 Procedure names........................................................................................................ 1-4 Fieldnames.................................................................................................................. 1-5 %Variables .................................................................................................................. 1-6 Statement labels ......................................................................................................... 1-7 Subroutines ................................................................................................................. 1-9 Simple subroutines................................................................................................. 1-9 Complex subroutines ............................................................................................. 1-9 Other naming convention considerations.................................................................. 1-10

2 Recommended Coding GuidelinesIn this chapter......................................................................................................... 2-1 Sample coding structure ............................................................................................. 2-2 Using comments ......................................................................................................... 2-3 Using commands ........................................................................................................ 2-4 Declaring %variables .................................................................................................. 2-5 Using $functions.......................................................................................................... 2-6 Using the IF statement ................................................................................................ 2-7 Formatting IF statements ....................................................................................... 2-7 Evaluating IF statements........................................................................................ 2-7 Using %variables in IF statements ......................................................................... 2-8 Using the computed JUMP TO............................................................................... 2-8 ELSE IF vs. ELSEIF ............................................................................................... 2-9 Finding records efficiently ......................................................................................... 2-11 Committing records ................................................................................................... 2-14 Releasing records ..................................................................................................... 2-15 Using the IN clause ................................................................................................... 2-16 Using lists.................................................................................................................. 2-17 Sorting records.......................................................................................................... 2-18Contents v

Using subroutines ..................................................................................................... 2-19 Using %variables In complex subroutines............................................................ 2-20 Using dummy strings in subroutines .................................................................... 2-20

3 Managing Record LockingIn this chapter......................................................................................................... 3-1 Locking conflict example ............................................................................................. 3-2 Types of record locks .................................................................................................. 3-3 Using ON units ............................................................................................................ 3-4 Using FIND AND RESERVE....................................................................................... 3-7 Coding RETRY counters............................................................................................. 3-8 Ensuring file integrity................................................................................................. 3-10 Controlling record locking problems.......................................................................... 3-12

Index

vi Model 204 Application Development Guide

PrefaceThis book describes naming conventions, and recommends coding guidelines and locking management strategies to help you solve the problems inherent in a multiuser environment. This manual is not designed to replace any manual in the Model 204 documentation set, but to provide a supplement that helps you produce clearer, faster applications. The information in this manual is not version-specific.

AudienceThis manual is for system managers, file managers, and application programmers, who want to develop Model 204 User Language code that is efficient, readable, and easy to maintain.

Introducing Model 204 electronic documentationModel 204 documentation includes other manuals to which you might want to refer. Each CD-ROM, titled Model 204 Documentation, contains the complete commercially released documentation for a particular version of Model 204. The document files are in portable document format (PDF) and compiled into a library so you can search all the documents at once for a word or phrase. You can download the manuals to a network server and view them, or view them directly from the CD-ROM. You can view and search an individual manual with any PDF reader, but to search the compiled library, you must download the free Adobe Acrobat Reader from the Adobe web site. Note: You may access the documentation online or print out copies, as needed. However, consistent with the terms of your license agreement, you may not copy