Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

array & loop 1

Status
Not open for further replies.

TeamGD

IS-IT--Management
Feb 18, 2001
69
AU
Why does the following formula produce the value 0 for all records? It should display 0.5

whileprintingrecords;

numbervar g;
numbervar array h := [1, 0.5, 0.75, 0.25, 0.666, 0.333];
numbervar counter;

for counter := 1 to 2 do
(
redim preserve h[counter];

g := h[counter];
);

g
 
It is because on the first loop, you are resizing your array to 1 member, that has a value of 1. On the second loop you are adding a second member with no value assigned. Mike
If you're not part of the solution, you're part of the precipitate.
 
Thanks ... I misunderstood what redim did. I now understand.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top