1、for Informations Systems - Programming Languages - Modules and Individual Character kNSI INCITS 113a-1989 (R2003) (formerly ANSI X3.113a-1989 (R1998): for Full Basic Input Developed by Where IT all begins ANSI X3.113a-1989 Supplement to ANSI X3 113-1 989 I American National Standard I for informatio
2、n systems - programming languages - modules and individual character input for full BASIC Approved July 26,1989 Secretariat: Computer and Business Equipment Manufacturers Association Page 1 of 14 pages 1. Introduction This Addendum is designed to promote the interchangeability of BASIC programs amon
3、g a variety of automatic for example, a module may provide for additional mathematical functions from which programs may access the ones needed and ignore the rest. Finally, modules could be used to add functional enhancements to BASIC; for example, a full GKS binding could be pro- vided to BASIC us
4、ing modules. 18.2 Syntax 1. program 2. module-part 3. module-def program-name-line? main-program = remark-line* module-def = module-line module-header procedure-part* (procedure-part I module-part)* remark-line* end-module-line ANSI X3.113a-1989 Page 6 of 14 pages 4. module-line 5. module-statement
5、6. module-name 7. module-header 8. module-header-line 9. public-line 10. public-statement 11. global-type 12. 13. 14. 15. 16. 17. 18. 19. 20. 21. 22. 23. 24. function-type sub-type picture-type share-line share-statement channel-type channel-list module-option-line module-option-statement end-module
6、-line end-module-statement type-declaration external-share-type 25. qualifred-id-list 26. qualifred-id 27. numeric-identifier 28. string-identifier 29. subprogram-name 30. picture-name 31. line 32. declaration-line 33. dim-line line-number module-statement tait MODULE module-name routine-identifier
7、(remark-line I public-line)* (remark-line I share-line)* module-header-line* remark-line I declaration-line I dim-line I module-option-line I block line-number public-statement tail PUBLIC global-type nweric-type I string-type l function-type I sub-type I picture-type ECTNCTION function-list PICRE p
8、icture-name-list line-number share-statement tail SHARE (global-type I channel-type) CHANNEL channel-list channel-number ( comma channel-number )* line-number module-option-statement tail MODULE option-statement line-number end-moduk-statement tail END MODULE external-share-type EXTERNAL (FUNCTION /
9、 SUB / PICTURE / NUMERIC / STRING) qualifred-id-list qualifred-id (comma qualifred-id)* module-name period (defrned-junction I routine-identifier I simple-nwneric-variable I simple-string-variable I formal-array) module-name period letter identifrer-character* module-name period letter identifrer-ch
10、aracte fl dollar-sign module-name period routine-identifier module-name period routine-identifrer public-line I share-line I module-line I module-option-line I module-header-line I end-module-line I dim-line I declaration-line line-number declaration-statement tail line-number dim-statement tail SUB
11、 sub-list A given identijer shall not appear more than once in the union of the public-statements, share-statements, declare-statements with the numeric-type, and the dimension-statements in the module-header of a given module- def. A given identijer shall not appear more than once in the union of t
12、he public-statements, share-statements, declare-statements with the string-type, and the dimension-statements in the module-header of a given module-def. A given identifier shall not appear more than once in the union of the public-statements, share-statements, and declare-statements with the functi
13、on-type in the module-header of a given module-def. A given identifier shall not appear more than once in the union of the public-statements, share-statements, and declare-statements with the sub-type in the module-header of a given module-def. ANSI X3.113a-1989 Page 7 of 14 pages A given identijer
14、shall not appear more than once in the union of the public-statements, share-statements, and declare-statements with the picture-type in the module-header of a given module-def. A given channel-number shall not appear more than once in the union of the share-statements with the channel- type in the
15、module-header of a given module-def. An identifier that appears in apublic-statement of a given module-def shall not also appear in an external-share- type in that module-def. A variable or routine whose identifier appears in apublic-statement shall be accessible: from the main-program, or from any
16、external-proc-def, or from any other module-def associated with the muin-program, provided that such main-program, external-proc-defs, or other associated module-defS shall contain a declare-statement with an external-shure-type containing a reference o that variable or routine. A variable or routin
17、e whose identifier appears in a public-statement or shure-statement shall be accessible from within the module-de$ including the module-header and all external-proc-defs in the module-de5 without further declaration. A channel-number that appears in a share-statement shall be accessible from within
18、the module-de$ including the module-header and all external-proc-defs in the module-def. A variable whose identifier, or a channel whose channel-number does not appear in either apublic-statement or share-statement shall be accessible only from within the module-header. A module-header shall contain
19、 at most one ANGLE option, at most one ARITHMETIC option, at most one COLLATE option, and at most one BASE option. If a module-header contains a MODULE OPTION statement of a given type, then no OPTION statement of that type may appear in the module-header or in any external-procedure in that module-
20、def. If an external-procedure in a module-def accesses a numeric share-identifier orpublic-identifier in that module- def, then the ARITHMETIC options of that external-procedure and the module-header shall be the same. If an external-procedure in a module-def accesses a string share-identifier or pu
21、blic-identifier in that module-def, then the COLLATE options of that external-procedure and the module-header shall be the same. A qualifred-id appearing in an external-share-type containing the keyword FUNCIION shall contain a dejned- function that refers to a defined-function that appears in apubl
22、ic-statement in the module-def named in the qualijied-id. A qualified-id appearing in an external-share-type containing the keyword SUB shall contain a routine-identijer that refers to a subprogram-name that appears in apublic-statement in the module-def named in the qualified-id. A qualified-id app
23、earing in an external-share-type containing the keyword PICTURE sha contain a routine- identijer that refers to apicture-name that appears in a public-statement in the module-defnamed in the qualified-id. A qualified-id appearing in an external-share-type containing the keyword NUMERIC shall contain
24、 a simple- numeric-variable or numeric formal-array that refers to a simple-numeric-variable or numeric array-name that appears in apublic-statement in the module-def named in the qualified-id. A qualifred-id appearing in an external-share-type containing the keyword STRING shall contain a simple- s
25、tring-variable or string formal-array that refers to a simple-string-variable or string array-name that appears in a public-statement in the module-def named in the qualified-id. i ANSI X3.113a-1989 Page 8 of 14 pages A qualified-id shall appear in an external-share-type in every program-unit in whi
26、ch the conesponding defined- function, subprogram-name, picture-name, numeric-identifier, or string-identifier is to be used. When not otherwise ambiguous, the module-name and period of a qualified-id appearing in a external-share-type may be omitted in sub- sequent uses of the corresponding defined
27、-function, subprogram-name, picture-name, nwneric-identifier, or string- identifier in a program-unit. The external-share-type containing the qualified-id shall occur in a lower-numbered line than any other reference to that identifier in aprogram-unit. A qualified-id that contains a formal-array sh
28、all be subsequently referred to using the Corresponding array-name (i.e., without the empty parentheses) in place of the formal-array. 183 Examples 2. (First example) 1000 MODULE stack 1020 PUBLIC FNCTION isempty$, isfull$ 1030 SHARE SUB inc, dec 1040 1050 LET maxdepth = 100 1060 LET pointer = O 107
29、0 1080 EXTERNAL SUB inc (x) 1090 LETx=x+l 1100 ENDSUB 1110 ! 1120 EXTERNAL SUB dec (x) 1130 LETX=X-l 1140 ENDSUB 1150 ! 1160 EXTERNAL SUB push (item) 1170 IF pointer = maxdepth then ,_- 2. (Second example) 1000 MODULE Common 1010 1020 PUBLIC STRING a.$ 1030 LET x,y,z = O 1040 LET a$ = “* 1050 END MO
30、DULE 23. EXTERNAL NU?vjERIC common.x, comrnon.y, common.z PUBLIC NUMERIC x, y, z EXTERNAL STRING common.a$ EXTERNAL SUB stack.push, stack.pop EXTERNAL FUNCTION stack.isfull$, stackisempty$ 18.4 Semantics Variables declared in public-statements, share-statements, dimension-statements, or declare-stat
31、ements (other than declare-statements with external-share-type), and simple-Variables appearing in the module-header shall be assigned, at program startup, implementation-defined values consistent with the policies of the implementation. The blocks contained in the module-header shall be executed be
32、fore any procedure or variable whose name appears in the public-statements of the module-header are accessed. Such blocks shall be executed at most once during the run of the program. Where the effect of statements at initialization may depend on the order of initialization of two or more modules in
33、 a program, as may occur with call-statements and function references (e.g., to RND), those effects are implementationdehed. Variables and arrays appearing in the share-statements of the module-header shall have their values preserved between invocations of the procedures contained in the module-def
34、. Variables declared in the public-statements of the module-header shall remain in existence between invocations of the procedures contained in the module-dtf, but may have their values changed inasmuch as they are accessible from outside the module-def. . Channels whose numben appear in the share-s
35、tatements of the module-header shall have their status preserved between invocations of the procedures within the module-def. That is, if the channel refers to an opened fie, then that channel shall remain opened until specrfically closed as a result of an action of an external-procedure contained i
36、n that module-dtf. Procedures within module-deji are external-procedures with respect to the scope of local variables and channels used within such procedures but not appearing as formal-parameters, except that ail variables and channels appear- ing in public-statements or share-statements in the sa
37、me module shaii be accessible from within such procedures. The scope of an OIWON that is not a MODULE OPTION is the external-procedure in which it is found, or, if it is in the module-header, the scope is the module-header. The scope of a MODULE OPTION is the entire module, including the module-head
38、er and all the external- procedures contained in the module- their existence does not in any respect preclude anyone, whether he has approved the standards or not, from manufacturing, marketing, purchasing, or using products, processes, or procedures not conforming to the standards. The American Nat
39、ional Standards Institute does not develop standards and will in no circumstances give an interpretation of any American National Standard. Moreover, no person shall have the right or authority to issue an interpretation of an American National Standard in the name of the American National Standards
40、 Institute. Requests for interpretations should be addressed to the secretariat or sponsor whose name appears on the title page of this standard. CAUTION NOTICE: This American National Standard may be revised or withdrawn at any time. The procedures of the American National Standards Institute requi
41、re that action be taken periodically to reaffirm, revise, or withdraw this standard. Purchasers of American National Standards may receive current information on all standards by calling or writing the American National Standards Institute. American National Published by American National Standards
42、Institute 11 West 42nd Street, New York, New York 10036 Copyright O1 987 by Information Technology Industry Council (ITI) All rights reserved. No part of this publication may be reproduced in any form, in an electronic retrieval system or otherwise, without prior written permission of ITI, 1250 Eye
43、Street NW, Washington, DC 20005. Printed in the United States of America ANSI X3.113-1987 American National Standard for Information Systems - Programming Languages - Full BASIC Secretariat Computer and Business Equipment Manufacturers Association Approved January 28, 1987 American National Standard
44、s Institute, Inc Abstract This standard presents the form for and the interpretation of programs written in the BASIC program- ming language for use on computers and information processing systems. (This Foneword is not part of American National Standard X3.113-1987.) Foreword This American National
45、 Standard specifies the form for and the interpretation of programs written in the BASIC programming languages for use on computers and information pro- cessing systems. Its purpose is to promote portability of BASIC programs for use on a vari- ety of machines. This standard was approved as an Ameri
46、can National Standard by the American National Standards Institute on January 28,1987. Suggestions for improvement of this standard will be welcome. They should be sent to the Computer and Business Equipment Manufacturers Association, 3 11 First Street, NW, Suite 500. Washington, DC 20001. This stan
47、dard was processed and approved for submittal to ANSI by the Accredited Stan- dards Committee on Information Processing Systems, X3. Committee approval of this standard does not necessarily imply that all committee members voted for its approval. At the time it approved this standard, the X3 Committ
48、ee had the following members: Edward Lohse, Chair Richard Gibson, Vice-Chair Catherine A. Kachurik, Administrative Secretary Organization Represented Name of Representative American Express. . D. L. Seigal Lucille Durfee (Alt) American Library Association. Paul Peters American Nuclear Society Gerald
49、ine C. Main D. R. Vondy (Alt) AMPIncorporated PatrickE.Lannan Edward Kelly (Alt) Association for Computing Machinery . Kenneth Magel Jon A. Meads (Alt) Association of the Institute for Certification of Computer Professionals Thomas M. Kurihara AT for example, interpreters or incremental or one-pass compilers. 1.2 Purpose. This standard is designed to promote the interchangeability of BASIC programs among a variety of automatic data processing systems. Programs conforming to this standard will be said to be written in American National Standard (ANS) BASIC. 1.3 Referenced