Your full service technology partner! 
-Collapse +Expand
Search Paradox Group:

-Collapse +Expand Paradox To/From
-Collapse +Expand Paradox Store

Prestwood eMagazine

February Edition
Subscribe now! It's Free!
Enter your email:

   ► KBDesktop Data...Paradox & Ob...   Print This     
  From the August 2014 Issue of Prestwood eMag
Paradox & ObjectPAL:
ObjectPAL Array (Array[] type)
Posted 13 years ago on 3/29/2010
Paradox Code Snippet:
 A flashcard from our Paradox Flashcards Library
 A code snippet from our Paradox Code Snippets Page
 Tags: ObjectPAL , Array


Languages Focus: Array

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.

ObjectPAL Array

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:

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

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])

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:

  MyArray Array[] String ;Resizeable array.
  i LongInt
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])

More Info


Share a thought or comment...
Write a Comment...
Sign in...

If you are a member, Sign In. Or, you can Create a Free account now.

Anonymous Post (text-only, no HTML):

Enter your name and security key.

Your Name:
Security key = P147A1
Enter key:
Code Contributed By Mike Prestwood:

Mike Prestwood is a drummer, an author, and creator of the PrestwoodBoards online community. He is the President & CEO of Prestwood IT Solutions. Prestwood IT provides Coding, Website, and Computer Tech services. Mike has authored 6 computer books and over 1,200 articles. As a drummer, he maintains and has authored 3 drum books. If you have a project you wish to discuss with Mike, you can send him a private message through his PrestwoodBoards home page or call him 9AM to 4PM PST at 916-726-5675 x205.

Visit Profile

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.


1 Intermediate Level Question

Question #1: True or False?

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

  • True
  • False

  •  KB Article #102138 Counter
    Since 3/29/2010
    Go ahead!   Use Us! Call: 916-726-5675  Or visit our new sales site:

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