Errors that occur when addressing arrays

Fixed-size arrays

In PowerBuilder, referring to array elements outside the declared size causes an error at runtime; for example:

int test[10]

test[11]=50    // This causes an execution error.

test[0]=50     // This causes an execution error.

int trial[5,10]

trial [6,2]=75  // This causes an execution error.

trial [4,11]=75  // This causes an execution error.

Variable-size arrays

Assigning a value to an element of a variable-size array that is outside its current values increases the array’s size. However, accessing a variable-size array above its largest assigned value or below its lower bound causes an error at runtime:

integer li_stock[ ]

li_stock[50]=200

			// Establish array size 50 elements.

IF li_stock[51]=0 then Beep(1)  

			// This causes an execution error.

IF li_stock[0]=0 then Beep(1)   

			// This causes an execution error.