Revision as of 12:37, 23 August 2009 editPcap (talk | contribs)Pending changes reviewers, Rollbackers18,285 edits →Footnotes: {{PL-stub}}← Previous edit |
Latest revision as of 02:33, 15 June 2017 edit undoTom.Reding (talk | contribs)Autopatrolled, Extended confirmed users, Page movers, Template editors3,890,632 editsm +{{Redirect category shell}} for multiple-{{R}} #Rs using AWB |
(15 intermediate revisions by 9 users not shown) |
Line 1: |
Line 1: |
|
|
#REDIRECT ] |
|
A '''picture clause''' is an element in ] that is used to describe a ], by using sample characters that indicate the item characteristics and size. |
|
|
|
|
|
|
|
{{Redirect category shell|1= |
|
== History == |
|
|
|
{{R from merge}} |
|
The picture clause was first used in the ] (Commercial Translator) language developed by ] of ] in 1957. In 1959, it was incorporated into the original definition of ]. Since then, many other programming languages have copied this feature. |
|
|
|
{{R to section}} |
|
|
}} |
|
|
|
|
|
|
] |
|
== Formatting == |
|
|
A picture clause is made up of various format characters, each of which represents a certain portion of the data item. Each format character can be repeated or followed by a repeat number, which specifies the number of times the format item occurs in the data item. Some examples (from COBOL) are: |
|
|
|
|
|
{| class="wikitable" width="80%" |
|
|
|- bgcolor="#F0F0F0" |
|
|
! Character |
|
|
! Description |
|
|
|- |
|
|
|bgcolor="#E0FFFF" align="center"| '''A''' |
|
|
|Alphabetic character (A-Z, a-z, or blank) |
|
|
|- |
|
|
|bgcolor="#E0FFFF" align="center"| '''B''' |
|
|
|Blank (space) character |
|
|
|- |
|
|
|bgcolor="#E0FFFF" align="center"| '''CR''' |
|
|
|Sign indicator ('CR' if negative, blanks if positive) |
|
|
|- |
|
|
|bgcolor="#E0FFFF" align="center"| '''DB''' |
|
|
|Sign indicator ('DB' if negative, blanks if positive) |
|
|
|- |
|
|
|bgcolor="#E0FFFF" align="center"| '''E''' |
|
|
|Floating-point exponent<ref name="extension">Non-standard extension provided by ] and others.</ref> |
|
|
|- |
|
|
|bgcolor="#E0FFFF" align="center"| '''G''' |
|
|
|Double-byte (]) graphic/alphanumeric character<ref name="extension"/> |
|
|
|- |
|
|
|bgcolor="#E0FFFF" align="center"| '''N''' |
|
|
|Double-byte (DBCS) character<ref name="extension"/> |
|
|
|- |
|
|
|bgcolor="#E0FFFF" align="center"| '''P''' |
|
|
|Implied scaling digit (not displayed) |
|
|
|- |
|
|
|bgcolor="#E0FFFF" align="center"| '''S''' |
|
|
|Implied sign (not displayed) |
|
|
|- |
|
|
|bgcolor="#E0FFFF" align="center"| '''V''' |
|
|
|Implied decimal point (not displayed) |
|
|
|- |
|
|
|bgcolor="#E0FFFF" align="center"| '''X''' |
|
|
|Any character, alphabetic, numeric, or other symbols |
|
|
|- |
|
|
|bgcolor="#E0FFFF" align="center"| '''Z''' |
|
|
|Numeric digit, but leading-zero-suppressed (replaced by a blank when equal to zero) |
|
|
|- |
|
|
|bgcolor="#E0FFFF" align="center"| '''0''' |
|
|
|Inserted '0' digit |
|
|
|- |
|
|
|bgcolor="#E0FFFF" align="center"| '''9''' |
|
|
|Numeric digit (0-9) |
|
|
|- |
|
|
|bgcolor="#E0FFFF" align="center"| '''/''' |
|
|
|Inserted '/' character |
|
|
|- |
|
|
|bgcolor="#E0FFFF" align="center"| ''',''' |
|
|
|Inserted digit group separator<ref name="comma">The comma and decimal point can be switched for European use.</ref> |
|
|
|- |
|
|
|bgcolor="#E0FFFF" align="center"| '''.''' |
|
|
|Inserted decimal point<ref name="comma"/> |
|
|
|- |
|
|
|bgcolor="#E0FFFF" align="center"| '''+''' |
|
|
|Sign ('-' if negative, '+' if positive) |
|
|
|- |
|
|
|bgcolor="#E0FFFF" align="center"| '''-''' |
|
|
|Sign ('-' if negative, blank if positive) |
|
|
|- |
|
|
|bgcolor="#E0FFFF" align="center"| '''$''' |
|
|
|Floating currency sign (blank for leading zeroes, '$' to the left of the most significant digit, otherwise digit 0-9) |
|
|
|- |
|
|
|bgcolor="#E0FFFF" align="center"| '''*''' |
|
|
|Floating digit fill ('*' for leading zeroes, otherwise digit 0-9) |
|
|
|} |
|
|
|
|
|
== Examples<ref>These examples are from COBOL.</ref> == |
|
|
{| class="wikitable" border="1" |
|
|
|- bgcolor="honeydew" |
|
|
! picture clause!! data type!! sample contents |
|
|
|- |
|
|
||PIC 999 ||3-digit number || 123, 005, 087, any number from 000 through 999 |
|
|
|- |
|
|
||PIC S999 ||3-digit internally signed number || +123, -005, +087, any number from -999 through +999 |
|
|
|- |
|
|
||PIC +999 ||3-digit output signed number || +123, -005, +087, any number from -999 through +999, with sign displayed. |
|
|
|- |
|
|
||PIC ZZ9 ||3-digit number, leading zeros suppressed || 123, 5, 87, any number from 000 through 999 |
|
|
|- |
|
|
||PIC A(8) ||8-character alphabetic string || "Fredrick", "Fred ", any string of 8 alphabetic letters (may include spaces) |
|
|
|- |
|
|
||PIC X(8) ||8-character string || "Smithson", "O'Riley ", "Bon-Jovi", "23Skidoo", any string of 8 characters (may include any valid character) |
|
|
|- |
|
|
|} |
|
|
|
|
|
== Footnotes == |
|
|
<references/> |
|
|
|
|
|
{{PL-stub}} |
|
|
|
|
|
] |
|
|
] |
|
|
|
|
|
] |
|