BBjAPI::copy

Description

In BBj 16.00 and higher, this method copies elements from a BBjVector to a BBj array. In BBj 20.30 and higher, this method can also copy from one BBj array to another.

Syntax

Return Value

Method

void

copy(BBjVector source, array target)

void copy(array source, array target)

Parameters

Variable

Description

source

A BBjVector or BBj array with values that are compatible with the target array.

target

An existing BBj array, specified as ARRAY[] or ARRAY[ALL].  Any array type (ARRAY[], ARRAY$[], ARRAY%[], or ARRAY![]) can be specified.

Return Value

None.

Remarks

This method copies elements sequentially from the source (vector or array) to the target array, starting at element 0, and ending when either the source or the target ends. Any null() values in the source are interpreted as the default value for the array ("" for string arrays, 0 for numeric and integer arrays, null() for object arrays). The copy will terminate with an error if it hits a source element that is not compatible with the target array. All elements before any error will be copied.

Example

rem ' BBjAPI::copy(BBjVector, array)

v! = bbjapi().makeVector()
for i = 0 to 10; v!.add(i); next i
rem ' null() elements are considered to be the array default value.
rem v!.set(5,null())

dim a[10],a$[10],a%[10],a![10]

bbjapi().copy(v!,a[])
print "a[]:",a[]

bbjapi().copy(v!,a$[])
print "a$[]:",a$[]

bbjapi().copy(v!,a%[])
print "a%[]:",a%[]

bbjapi().copy(v!,a![])
print "a![]:",a![]

rem ' BBjAPI::copy(array, array)

dim source$[3],target$[3]
source$[0]="the",source$[1]="quick",source$[2]="brown",source$[3]="fox"
print source$[]

bbjapi().copy(source$[],target$[])
print target$[]

ClosedVersion History

  • BBj 20.30: source parameter can be a BBj array as well as a BBjVector.
  • BBj 16.0: BBjAPI::copy added.

See Also

BBjAPI

BBjVector

Integer Variables and Arrays

DIM Verb

VECTOR() Function - Convert Array to Vector

See the BBj Object Diagram for an illustration of the relationship between BBj Objects.