# PIC2D (Picture-to-Decimal)

## Syntax:

    PIC2D(picnum[,national][,synerrval])

## Arguments:

picnum
  the printable formatted number to be converted. The number must not exceed 256 bytes in length, including blanks and editing characters.
national
  a 3 byte string containing the characters to be used for the currency symbol, the decimal point, and the hundreds separator, respectively. The default national string is '$.,' (where the dollar sign is the currency symbol, the period is the decimal point character, and the comma is the hundreds separator). This string, if coded, must be exactly 3 bytes in length and cannot contain blanks or any of the other valid picture symbols.
synerrval
  indicates the value to be returned if a syntax error is detected. This argument can be used to handle normally occurring invalid data. For example, null strings.

## Module Name:

SWXPIC2D

## Service Description:

The PIC2D function is used to format "pretty printed" numeric data into the REXX decimal number format. Blanks and all characters other than numeric digits (0-9), the sign indictor, and the decimal point are stripped out in the result.

The recognized sign indicators are '+', '-', 'DB', and 'CR'. The 'DB' and 'CR' symbols produce a negative result. If more than one sign indicator is present, the last one scanned (working from left to right) will be used.

The decimal point character is identified using the second byte of the national argument (the default is a period). If necessary, this character is converted to the REXX decimal point character (always a period) before it is copied to the result. An error results if more than one decimal point is present in the picnum argument.

If no decimal digits are found in the picnum argument, a single zero is returned.

## Returned Information:

The PIC2D function returns the REXX decimal representation of picnum. If you CALL the PIC2D function, the returned value is contained in the RESULT special variable. The RC special variable is unchanged.

## Examples:

1. Call the PIC2D function to convert the picture formatted number in PICNUM. In this example, the roles of the comma and decimal point are reversed (French currency notation).

       picnum = 'f  1.792,42 CR'
       amount = pic2d(picnum,'f,.')
       /* amount = -1792.42 */

© Copyright 1998 by Open Software Technologies, Inc.