complexUnpack Method

Class: String

Description

This method unpacks a packed string into its associated numeric value. This method handles packed data where the sign is on the left or there may be no sign. In addition, numbers may start and end in half-bytes.

 

This method is typically used for file conversions where data is provided in packed format. This method replaces the $$UNPACK2^%ZFUNC() function.

 

Packed data may appear in the following format:

 

NN NN NS

 

where N is a number from 0 to 9, and S is the sign (e.g., A/C/E/F for Positive; all other values for Negative).

Syntax

String.complexUnpack(Number length,Boolean signed,Boolean leftNib)

Parameters

length

The number of digits in the string to unpack, excluding the sign.

signed

An option that indicates whether the field being extracted may contain a - or + sign. Valid values are 0 (not signed) and 1 (signed).

leftNib

A code that indicates the starting point is the left (0) or right (1) half byte.

Returns

A modified string.

When Became Available

v7.0

Example

The following complexUnpack statement assigns the number 213372 to the numeric variable nUnpack.

type String sPacked

type Number nUnpack

set sPacked = "!31"

set nUnpack = sPacked.complexUnpack(6,0,1)