COBOL Programming O Palgrave Master Series

COBOL Programming O Palgrave Master Series

Mastering COBOL Programming o Palgrave Master Series Accounting Geography Accounting Skills German Advanced English Language Global Information Systems Advanced English Literature Human Resource Management Advanced Pure Mathematics Information Technology Arabic Internet Basic Management Italian Biology Java British Politics Management Skills BusinessCommunication Marketing Management Business Environment Mathematics C Programming Microsoft Office C++ Programming Microsoft Windows, Novell Chemistry NetWare and UNIX COBOL Programming Modern British History Communication Modern European History Modern United States History Computing Modern World History Counselling Skills Networks Counselling Theory Organisational Behaviour Customer Relations Pascaland Delphi Programming Database Design Philosophy Delphi Programming Physics Desktop Publishing Practical Criticism Economic and Social History Psychology Economics Shakespeare Electrical Engineering Social Welfare Electronic and Electrical Calculations Sociology Electronics Spanish Employee Development Statistics English Grammar Strategic Management English Language Systems Analysis and Design English Literature Team Leadership Fashion Buying and Merchandising Theology Management Twentieth Century Russian History Fashion Styling Visual Basic French World Religions www.palgravemasterseries.com Pa(grave MasterSeries SerIesStandln. Order ISBN 978-0-333-69343-4 (outsideNorth America only) Youcan receivefuture titles in this series as they are published by placinga standing order. Pleasecontact your bookselleror, in case of difficulty, write to us at the address below with your name and address, the title of the series and the ISBN quoted above. Customer ServicesDepartment, Macmillan DistributionLtd Houndmills, Basingstoke, Hampshire RG21 6XS, England Mastering COBOL o Progra......ing Second edition Roger Hutty Head ofComputer Science Department School ofComputing Sciences De Montfort University Leicester and Mary Spence Senior Lecturer Department ofInformation Systems School ofComputing Sciences De Montfort University Leicester Series Editor Timothy Davies Computer Consultant palgrave e Roger Hutty 1990. Roger Hutty and Mary Spence 1997 All rights reserved. No reproduction, copy or transmission of this publication may be made without writt",n permission. No paragraph of this publication may be reproduced, copied or transmitted save with written permission or in accordance with * the provisions of the Copyright, Des igns and Patents Act 1988, or under the terms of any licence permitting limited copying issued by the Copyright licensing Agency, 90 Tottenham Court Road. London wn 4LP. Any person who does any unauthorised act in relation to this publication may be liable to criminal prose<:ution and civil claims for damages. The authon hav!! asserted their rights to be identified as the authors of this work in accordance with the Copyright, Designs and Patents Act 1988. First edifion 1983 Reprinted five times Second edition 1997 Publisned by PALGRAVE Houndmills, 8asingstoke, Hampmire RG21 6XS and 175 Fifth Avenue, New York. N. Y. 10010 Companies and representatives throughout the world PALGRAVE is the new global academic imprint of St. Martin's Press LLC Scholarly and Reference Division and Palgrave Publishers Ltd (formerly Macmillan Press ltd). ISBN 978-0-333-68106-0 ISBN 978-1-349-14327-6 (eBook) 001 10.1057/9781349143276 This book Is printed on paper suitable for recycling and made from fully managed and sustained forest sources. A catalogue record for this book is available from the 8ritish Library. " 10 9 8 7 6 5 4 3 10 09 08 07 06 05 04 03 02 oContents Preface to the Second Edition xiii Acknowledgements xv List ofFigures xvi Part I NUCLEUS and SOURCE TEXT MANIPUlATION modules 1 COBOL programming fundamentals 1 1.1 COBOL computer systems 1 1.2 COBOL 85 programs 5 1.2.1 A simple COBOL program 5 1.2.2 General structure of a COBOL program 5 1.2.3 General structure of a line of COBOL code 7 1.2.4 Use of upper or lower case for code 8 1.2.5 Use of the full stop (or period) 8 1.3 Program development 9 1.4 The IDENTIFICAnON DIVISION 13 1.5 The ENVIRONMENT DIVISION 14 1.6 Chapter summary 15 1.7 Practical 16 2 DATA and PROCEDURE DIVISION fundamentals 17 2.1 The DATA DIVISION 17 2.2 Data item descriptions 18 2.2.1 Data names 18 2.2.2 The PICTURE clause 19 2.2.3 Data item level numbers 20 2.2.4 Data name qualification 22 2.2.5 The VALUE clause 23 2.2.6 Level 88 condit ion names 24 2.2.7 The USAGE clause 25 2.2.8 FILLER data names 26 2.2.9 Reference modification 26 2.2.10 The REDEFINES clause 27 2.3 The PROCEDURE DIVISION 28 2.4 Literals and figurative constants 30 2.5 The DISPLAY statement 31 Contents V 2.6 COBOL syntax format 33 2.7 The MOVE statement 33 2.7.1 To set a data item to a value 33 2.7.2 To copy one data item to another 35 2.7.3 To edit and unedit data 36 2.7.4 To copy many items at a time 36 2.7.5 To change between USAGEs 37 2.8 The INmALIZE statement 37 2.9 Chapter summary 38 2.10 Practical 39 3 Numbers and the SUBTRACT statement 42 3.1 ADD statement variations 42 3.1.1 ADDing several numbers 42 3.1.2 The GIVING option 44 3.2 Fractional numbers 46 3.2.1 The V PICTURE 46 3.2.2 The P PICTURE 47 3.2.3 The . PICTURE 48 3.3 Signed numbers 50 3.3.1 The S PICTURE 50 3.3.2 The + and - PICTUREs 52 3.3.3 The CR and DB PICTUREs 53 3.4 The SUBTRACT statement 54 3.5 The ROUNDED option 56 3.6 The SIZE ERROR option 57 3.7 Chapter summary 61 3.8 Practical 62 4 The MULTIPLY, DIVIDE and COMPUTE statements, further data editing 64 4.1 The MULTIPLY statement 64 4.2 The DIVIDE statement 65 4.2.1 The basic DIVIDE statement 66 4.2.2 The REMAINDER option 66 4.3 The arithmetic statements together 67 4.4 The COMPUTE statement 70 4.4.1 The basic COMPUTE statement and arithmetic operators 70 4.4.2 Order of precedence of the arithmetic operators 71 4.4.3 The ROUNDED and SIZE ERROR options 72 4.4.4 Example program, using exponentiation 72 4.5 Zero suppression using Z and * 74 4.6 Insertion pictures , B 0 / and $ 75 4.7 Floating pictures $ + - 76 4.8 The currency symbol and the decimal point 77 4.9 Chapter summary 78 4.10 Practical 79 5 The IF, GO TO and EVALUATE statements 81 5.1 The IF statement 81 5.2 Simple conditions 84 5.2.1 Relation conditions 84 vi Contents 5.2.2 Sign conditions 85 5.2.3 Class conditions 86 5.2.4 Condition name conditions 87 5.3 Nested IF statements 88 5.4 The NEXT SENTENCE and CONTINUE phrases 91 5.5 Complex conditions 92 5.5.1 Conditions with OR 92 5.5.2 Conditions with AND 93 5.5.3 Conditions with NOT 94 5.5.4 Abbreviated conditions 94 5.5.5 Conditions with both AND and OR 95 5.5.6 Conditions with level 88s 95 5.5.7 General rules when mixing AND, OR, NOT 96 5.6 The GO TO statement 96 5.7 The EVALUATE statement 97 5.7.1 Simple EVALUATE 98 5.7.2 Extended EVALUATE 99 5.7.3 Use of TRUE, FALSE and level88s 102 5.8 Statements and sentences 104 5.9 Collating sequences 105 5.10 Date and time 106 5.10.1 ACCEPTing the date and time 107 5.10.2 Determining the century 109 5.10.3 Date comparisons, age calculations. etc 109 5.10.4 Leap year checks 110 5.10.5 Converting day of week and month to words 111 5.10.6 Converting to a 12-hour clock 111 5.11 Chapter summary III 5.12 Practical 112 6 PERFORMing 114 6.1 Modular programming 114 6.1.1 Using the PERFORM statement to organise a program 114 6.1.2 Using the PERFORM statement to reduce duplication of code 116 6.2 PERFORM ... TIMES 117 6.2.1 The basic statement 117 6.2.2 The statement with in-line coding 119 6.2.3 The statement with out-of-line coding 120 6.3 PERFORM ... UNTIL 121 6.3.1 The statement with in-line and out-of-line coding 121 6.3.2 The WITH TEST BEFOREIAFfER options 123 6.4 PERFORM ... VARYING 124 6.4.1 The basic statement 124 6.4.2 The WITH TEST BEFORE!AFfER options 126 6.4.3 Using the loop data item in the loop 126 6.4.4 Using a condition that does not reference the loop data item 128 6.5 The PERFORM stack 129 6.6 PERFORM ... THRU and EXIT 131 6.7 Data validation 133 6.7.1 Validation of data type 133 6.7.2 Validation of ranges or specific values 135 Contents vii 6.7.3 Complex validations 137 6.8 The PERFORM procedure structure 138 6.9 Debugging 140 6.10 Chapter summary 141 6.11 Practical 142 7 Lists 144 7.1 List definition 144 7.2 List input and output 146 7.3 List calculations 148 7.3.1 Calculating the average of a list of numbers 148 7.3.2 Calculating the standard deviation 149 7.3.3 Finding the highest and lowest entries 151 7.4 Sorting 152 7.5 Lists of lists 154 7.6 INDEXED BY 156 7.7 The AFTER phrase 158 7.8 Lists with VALUEs 158 7.9 Chapter summary 160 7.10 Practical 161 8 Tables 164 8.1 Table definition 164 8.2 Table searching 166 8.2.1 Searching for a unique entry 166 8.2.2 Searching for non-unique entries 168 8.3 Sorting tables 169 8.4 Look-up tables 171 8.5 The SEARCH statement 174 8.5.1 Searching for a unique entry 174 8.5.2 Searching for non-unique entries 175 8.5.3 SEARCH ALL and ordered tables 177 8.6 A table example 178 8.7 Initialising tables 183 8.8 Chapter summary 184 8.9 Practical 184 9 String manipulation 186 9.1 The STRING statement 186 9.1.1 Eliminating spare characters 187 9.1.2 The OVERFLOW phrase 189 9.1.3 The POINTER phrase 190 9.2 The UNSTRING statement 191 9.2.1 Dividing a simple string 192 9.2.2 The DELIMITED BY phrase 192 9.2.3 The DELIMITER, COUNT, POINTER, TALLYING and OVERFLOW phrases 193 9.3 The INSPECT statement 196 9.3.1 The TALLYING phrase 196 9.3.2 The REPLACING phrase 199 9.3.3 Using TALLYING and REPLACING together 200 9.3.4 The CONVERTING phrase 200 viii Contents 9.4 Chapter summary 202 9.5

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    18 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us