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

Creating Dynamic Array

Status
Not open for further replies.

Wabush

Programmer
Jan 15, 2001
31
0
0
US
I am trying to create a list of each unique value in a field by using the Creating Dynamic Arrays document from Crystal, but I get a syntax error. I am using 6.5 and am wondering if the redim preserve is allowed in this version.
Here is the formula:

WhilePrintingRecords;
stringVar array GroupList;
numberVar Counter;

if not ({HD_INCIDENT.OWNER_GRP} in GroupList) then


(Counter := Counter + 1;

if counter <= 100

then (redim preserve GroupList[Counter];

GroupList[Counter] := {HD_INCIDENT.OWNER_GRP}));
 
I don't think redim preserve was available in 6.5

If you type in redim preserve in your formula field, does it change colors? (I'm assuming of course that the &quot;keyword&quot; color changes take place in 6.5) Mike
If you're not part of the solution, you're part of the precipitate.
 
Hi Mike -
No, there was no keyword color change in 6.5. I just tried it in 8.5 and got no errors, so I guess I will have to find a way around it.

Thanks

Deanna
 
I think you may have to define your array firstand then use the rest of your formula.

put this formula in your group header. Add as many empty strings as you think you may need. Then suppress the field.

global stringvar array GroupList:=[&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;];
grouplist[1]


Change your other formula to:

WhilePrintingRecords;
global stringVar array GroupList;
numberVar Counter;


if not ({HD_INCIDENT.OWNER_GRP} in GroupList) then


(Counter := Counter + 1;

if counter <= 100


GroupList[Counter] := {HD_INCIDENT.OWNER_GRP});


Mike
If you're not part of the solution, you're part of the precipitate.
 
Hi Mike - Thanks again - that almost worked but I am still limited by 6.5 - so...instead of using an array, I just concatenated all the values in a string variable..the biggest limitation of this is a string can only be 255;

stringVar Groups;
if DistinctCount ({HD_INCIDENT.OWNER_GRP}) < 8 and Length (Groups) < 235 and InStr (Groups,{HD_INCIDENT.OWNER_GRP} ) = 0 then
Groups := Groups + &quot;:&quot; + {HD_INCIDENT.OWNER_GRP}
 
Here is a formula that allows for 4 of your &quot;Goups&quot; variables. I Set the limiter at 230 characters


WhilePrintingRecords;
stringvar NameList;
stringvar NameList2;
stringvar NameList3;
stringvar NameList4;

if length(NameList)>230 then
(if (NameList2<>&quot;&quot; and NameList3<>&quot;&quot;) then (NameList4:=NameList;NameList:=&quot;&quot;) else
(if NameList2<>&quot;&quot; then (NameList3:=NameList;NameList:=&quot;&quot;) else
(NameList2:=NameList;NameList:=&quot;&quot;)));

If instr(NameList3,{HD_INCIDENT.OWNER_GRP}) > 0 then
NameList3:=Namelist3 else
If instr(NameList2,{HD_INCIDENT.OWNER_GRP}) > 0 then
NameList2:=Namelist2 else
If instr(NameList,{HD_INCIDENT.OWNER_GRP}) > 0 then

NameList := NameList + &quot;:&quot; + {HD_INCIDENT.OWNER_GRP}; Mike
If you're not part of the solution, you're part of the precipitate.
 
Mike - sure that's perfect!

Thanks much

D
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top