Revision as of 16:46, 20 February 2008 editLoadmaster (talk | contribs)Extended confirmed users, Pending changes reviewers, Rollbackers13,240 edits added {{compsci-stub}} tag← Previous edit |
Latest revision as of 02:33, 15 June 2017 edit undoTom.Reding (talk | contribs)Autopatrolled, Extended confirmed users, Page movers, Template editors3,888,592 editsm +{{Redirect category shell}} for multiple-{{R}} #Rs using AWB |
(25 intermediate revisions by 12 users not shown) |
Line 1: |
Line 1: |
|
|
#REDIRECT ] |
|
A '''picture clause''' is an element in ] that is used to describe a ] item, 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 characters, each of which represents a certain type of data item. The number of repeated characters indicates the size of the data item. |
|
|
Here are some examples (from COBOL) of picture characters and what they represent: |
|
|
|
|
|
{| width="80%" border="2" align="center" |
|
|
|- |
|
|
! Character |
|
|
! Description |
|
|
|- |
|
|
|align="center"| '''A''' |
|
|
|Alphabetic character (A-Z, a-z, or blank) |
|
|
|- |
|
|
|align="center"| '''B''' |
|
|
|Blank (space) character |
|
|
|- |
|
|
|align="center"| '''CR''' |
|
|
|Sign indicator ('CR' if negative, blanks if positive) |
|
|
|- |
|
|
|align="center"| '''DB''' |
|
|
|Sign indicator ('DB' if negative, blanks if positive) |
|
|
|- |
|
|
|align="center"| '''E''' |
|
|
|Floating-point exponent<ref name="extension">Non-standard extension provided by ] and others.</ref> |
|
|
|- |
|
|
|align="center"| '''G''' |
|
|
|Double-wide graphic/alphanumeric character<ref name="extension"/> |
|
|
|- |
|
|
|align="center"| '''P''' |
|
|
|Implied scaling digit (not displayed) |
|
|
|- |
|
|
|align="center"| '''S''' |
|
|
|Implied sign (not displayed) |
|
|
|- |
|
|
|align="center"| '''V''' |
|
|
|Implied decimal point (not displayed) |
|
|
|- |
|
|
|align="center"| '''X''' |
|
|
|Any character, alphabetic, numeric, or other symbols |
|
|
|- |
|
|
|align="center"| '''Z''' |
|
|
|Numeric digit, but leading-zero-suppressed (replaced by a blank when equal to zero) |
|
|
|- |
|
|
|align="center"| '''9''' |
|
|
|Numeric digit (0-9) |
|
|
|- |
|
|
|align="center"| ''',''' |
|
|
|Digit group separator<ref name="comma">The comma and decimal point can be switched for European use.</ref> |
|
|
|- |
|
|
|align="center"| '''.''' |
|
|
|Decimal point<ref name="comma"/> |
|
|
|- |
|
|
|align="center"| '''+''' |
|
|
|Sign ('-' if negative, '+' if positive) |
|
|
|- |
|
|
|align="center"| '''-''' |
|
|
|Sign ('-' if negative, blank if positive) |
|
|
|- |
|
|
|align="center"| '''$''' |
|
|
|Floating currency sign (blank for leading zeroes, '$' to the left of the most significant digit, otherwise digit 0-9) |
|
|
|- |
|
|
|align="center"| '''*''' |
|
|
|Floating digit fill ('*' for leading zeroes, otherwise digit 0-9) |
|
|
|} |
|
|
|
|
|
== Examples<ref>These examples are from COBOL.</ref> == |
|
|
{| border="1" |
|
|
|- bgcolor="honeydew" |
|
|
! picture clause!! data type!! sample contents |
|
|
|- |
|
|
||PICTURE IS 999 ||3-digit number || 123, 005, 087, any number from 000 through 999 |
|
|
|- |
|
|
||PICTURE IS S999 ||3-digit internally signed number || +123, -005, +087, any number from -999 through +999 |
|
|
|- |
|
|
||PICTURE IS +999 ||3-digit output signed number || +123, -005, +087, any number from -999 through +999, with sign displayed. |
|
|
|- |
|
|
||PICTURE IS ZZ9 ||3-digit number, leading zeros suppressed || 123, 5, 87, any number from 000 through 999 |
|
|
|- |
|
|
||PICTURE IS A(8) ||8-character alphabetic string || "Fredrick", "Fred ", any string of 8 alphabetic letters (may include spaces) |
|
|
|- |
|
|
||PICTURE IS X(8) ||8-character string || "Smithson", "O'Riley ", "Bon-Jovi", "23Skidoo", any string of 8 characters (may include spaces) |
|
|
|- |
|
|
|} |
|
|
|
|
|
== Footnotes == |
|
|
<references/> |
|
|
|
|
|
|
|
|
{{compsci-stub}} |
|
|
|
|
|
] |
|
|
] |
|
|
|
|
|
] |
|