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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Array Display

Status
Not open for further replies.

satinsilhouette

Instructor
Feb 21, 2006
625
I haven't writtne an array display in about 5 years, but need to now. I am getting an error on the counter in the declare formula and in the populate formula for the counter_myfield:

Declare formula:
Whileprintingrecords;
global stringvar array my_array;
global numbervar counter_myfield:=0;
Redim my_array[n];

Populate:
whileprintingrecords;
global numbervar counter_myfield:= counter_myfield +1;
global stringvar array my_array;
prov_array [counter_myfield]:= {?fieldname};

Display:
whileprintingrecords;
global stringvar array my_array;
Join(my_array, ", ")

I know this is pretty simple stuff, but cobwebs are keeping me from remembering something key here.



Thanks so much!
satinsilhouette
 
Don't think its the counter_myfield

Its your Redim my_array[n];

You have not declared n

Replace n with a number

Ian
 
Cannot replace n with a number because I don't know the number.

Thanks so much!
satinsilhouette
 
Okay so I need to find how many make up the array - so I have a distinct count included, but I get an error on this saying it needs to be an integer between 1 and 1000.


Whileprintingrecords;
global stringvar array my_array;
global numbervar n := distinctcount(my_array);
global numbervar counter_myfield:=0;
Redim my_array[n];

Thanks so much!
satinsilhouette
 
An array can have up to 1000 elements, just define as big as you think it will need to be.

Unfortunately that will probably mean you can not use join(), as you will have excess elements. You will need to use a Do Loop to break the array down and concatenate string elements.

Ian
 
Why are you using these variables? It looks like you are just trying to display the values for a multi-value string parameter, so you can just use this formula:

join({?fieldname},", ")

-LB
 
Or if you are just trying to concatenate fields to appear in a group footer

@Populate:
// place in details
whileprintingrecords;

global stringvar list;

list:=list&{fieldname}&', '

@Display
whileprintingrecords;

global stringvar list;

Ian
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top