byte Method

Class: Number

Description

This method instantiates a ByteString consisting of a single-byte. It can only be applied to Number instances that have a value less than 256.

Syntax

NumberObject.byte()

Parameters

none

Returns

A ByteString consisting of a single-byte

Throws

%GTM-E-DLRZCTOOBIG, if the method is applied to a Number instance with a value greater than or equal to 256.

When Became Available

Profile V7.0

Example

// NOTE:

// The example below generates the UTF-8 characters with code points 128 -

// 255. It is included for the sole purpose of demonstrating the use of the

// Number.byte() method. In general application programs that rely on a

// a certain character set will not be portable !

//

type literal Number UTFLEAD = 192

type literal Number UTFNEXT = 128

type Number ITER, FIRST, SECOND

type String UTF8()

 

for ITER = 128:1:255 do {

    set FIRST  = ITER \ 64 + UTFLEAD

    set SECOND = ITER # 64 + UTFNEXT

    set UTF8( ITER) = FIRST.byte() _ SECOND.byte()

}