IT SOLUTIONS
Your full service technology partner! 
-Collapse +Expand
To/From Code
   ► KBTo/From GuidesReferenceCorel ParadoxData Structures  Print This     

Corel Paradox Data Structures

Array

Languages Focus

A data structure in which individual values (called elements or items) may be located by reference to one or more integer index variables, the number of such indices being the number of dimensions in the array.

Arrays can start with an index value of 0 or 1, sometimes referred to as 0 based or 1 based.

Corel Paradox:   Array[] type

Arrays in ObjectPAL use a 1-based subscript (also known as an index). Use [] with a subscript to refer to an element (i.e. MyArray[1], MyArray[2]).

The number of elements for a given array in ObjectPAL are either fixed or resizeable. Specify the size when you declare it for fixed. Use size() to get the number of elements, size() returns 0 if the array has no elements. Use setSize(), grow(), addLast(), etc. to add elements to an array.

Syntax Example:

var
  MyArray Array[4] String ;Fixed size array.
  i LongInt
endVar

MyArray[1] = "Mike"
MyArray[2] = "Lisa"
MyArray[3] = "Felicia"
MyArray[4] = "Nathan"

if MyArray.size() > 0 then
  for i from 1 to MyArray.size()
    msgInfo("", MyArray[i])
  endFor
endIf

The above example, is an example of a fixed size array in which you specified the size of the array when declared:

MyArray Array[4] String

Resizeable Arrays

With a resizeable array, you can set an initial size of the array and grow it as needed:

var
  MyArray Array[] String ;Resizeable array.
  i LongInt
endVar
  
MyArray.setSize(3)       ;Set initial size.
  
MyArray[1] = "Mike"
MyArray[2] = "Lisa"
MyArray[3] = "Felicia"
  
MyArray.setSize(4)      ;Reset size (truncates if you set smaller.)
MyArray[4] = "Nathan"
  
MyArray.Grow(1)         ;Add to the array with grow.
MyArray[5] = "Ingo"

if MyArray.size() > 0 then
  for i from 1 to MyArray.size()
    msgInfo("", MyArray[i])
  endFor
endIf



Linked Certification Question(s)

The following are practice certification questions with answers highlighted. These questions were prepared by Mike Prestwood and are intended to stress an important aspect of this KB post. All our practice questions are intended to prepare you generally for passing any certification test as well as prepare you for professional work.

Intermediate

1 Intermediate Level Question

Question #1: True or False?

An ObjectPAL array is 0-based, meaning, the first element has an index of 0.

Answer:
  • True
  • False
  • More Info

    Code:  ObjectPAL Array (Array[] type)




    Sales Website: www.prestwood.com Or visit our legacy sales site: 
    legacy.prestwood.com


    ©1995-2024 Prestwood IT Solutions.   [Security & Privacy]