Revision as of 09:15, 1 August 2014 editEdwardH (talk | contribs)Extended confirmed users3,690 edits Added {{unreferenced}}.← Previous edit | Revision as of 16:06, 8 August 2014 edit undoEdwardH (talk | contribs)Extended confirmed users3,690 edits Merged content to COBOL#Picture clause. See Talk:COBOL#Proposed merger of Picture clause.Next edit → | ||
Line 1: | Line 1: | ||
#REDIRECT ] | |||
{{R from merge}} | |||
{{unreferenced|date=August 2014}} | |||
{{R to section}} | |||
A '''picture clause''' is an element in ] that is used to describe a ], by using sample characters that indicate the item characteristics and size. | |||
== History == | |||
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. | |||
== 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 (<code>A-Z</code>, <code>a-z</code>, or blank) | |||
|- | |||
|bgcolor="#E0FFFF" align="center"| '''B''' | |||
|Blank (space) character | |||
|- | |||
|bgcolor="#E0FFFF" align="center"| '''CR''' | |||
|Sign indicator (<code>'CR'</code> if negative, blanks if positive) | |||
|- | |||
|bgcolor="#E0FFFF" align="center"| '''DB''' | |||
|Sign indicator (<code>'DB'</code> 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 symbol | |||
|- | |||
|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 <code>'0'</code> digit | |||
|- | |||
|bgcolor="#E0FFFF" align="center"| '''9''' | |||
|Numeric digit (<code>0-9</code>) | |||
|- | |||
|bgcolor="#E0FFFF" align="center"| '''/''' | |||
|Inserted <code>'/'</code> 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 (<code>'-'</code> if negative, <code>'+'</code> if positive) | |||
|- | |||
|bgcolor="#E0FFFF" align="center"| '''-''' | |||
|Sign (<code>'-'</code> if negative, blank if positive) | |||
|- | |||
|bgcolor="#E0FFFF" align="center"| '''$''' | |||
|Floating currency sign (blank for leading zeroes, <code>'$'</code> to the left of the most significant digit, otherwise digit <code>0-9</code>) | |||
|- | |||
|bgcolor="#E0FFFF" align="center"| '''*''' | |||
|Floating digit fill (<code>'*'</code> for leading zeroes, otherwise digit <code>0-9</code>) | |||
|} | |||
== Examples == | |||
Examples from COBOL. | |||
{| class="wikitable" border="1" | |||
|- bgcolor="honeydew" | |||
! Picture clause!! Data type!! Sample values | |||
|- | |||
||<code>PIC 999</code> ||3-digit number || 123, 005, 087, any number from 000 through 999 | |||
|- | |||
||<code>PIC S999</code> ||3-digit internally signed number || +123, −005, +087, any number from −999 through +999, sign is not displayed | |||
|- | |||
||<code>PIC +999</code> ||3-digit output signed number || +123, −005, +087, any number from −999 through +999, with sign displayed | |||
|- | |||
||<code>PIC ZZ9</code> ||3-digit number, leading zeros suppressed || 123, 5, 87, any number from 000 through 999 | |||
|- | |||
||<code>PIC A(8)</code> ||8-character alphabetic string || <code>"Fredrick"</code>, <code>"Fred "</code>, <code>"Fred Jr "</code>, any string of 8 alphabetic letters (may include spaces) | |||
|- | |||
||<code>PIC X(8)</code> ||8-character string || <code>"Smithson"</code>, <code>"O'Riley "</code>, <code>"Bon-Jovi"</code>, <code>"23Skidoo"</code>, any string of 8 characters (may include any valid character) | |||
|- | |||
|} | |||
== Footnotes == | |||
<references/> | |||
{{prog-lang-stub}} | |||
] | |||
] | |||
] |
Revision as of 16:06, 8 August 2014
Redirect to:
- From a merge: This is a redirect from a page that was merged into another page. This redirect was kept in order to preserve the edit history of this page after its content was merged into the content of the target page. Please do not remove the tag that generates this text (unless the need to recreate content on this page has been demonstrated) or delete this page.
- For redirects with substantive page histories that did not result from page merges use {{R with history}} instead.
- To a section: This is a redirect from a topic that does not have its own page to a section of a page on the subject. For redirects to embedded anchors on a page, use {{R to anchor}} instead.