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!

grrrrrr Arrays and I'm totaly stumped 2

Status
Not open for further replies.

BlindPete

Programmer
Jul 5, 2000
711
US
what I want to do (and this overly simplstic example)is create an array to hold names of fruit.

@InitArrays -supressed field in header
WhilePrintingRecords;
GLOBAL StringVar array Fruit := ["apples","pears","lemons"];
""//eliminates CR error msg

now in my report I want to reference and/or modify that array. How do I do that?
-Pete[noevil]
 
Hey again Pete!

Because your array has been assigned to a global variable called Fruit, every time you declare and reference this variable thereafter, you will be referring to your array.

How you want to use the array thereafter is ultimately up to you:
Code:
WhilePrintingRecords;
StringVar Array Fruit;
UBound(Fruit);
here you're telling Crystal to tell you how many components are in your array. So the return would be 3.
Code:
WhilePrintingRecords;
StringVar Array Fruit;
Fruit[3];
here you're telling Crystal to display the 3rd component in the array. So the return would be "lemons".

I'm being very generic, but if you post some examples of your data and what you're trying to achieve I'm sure that between yourself and the guys here you can knock out a solution that meets your needs.

Naith
 
ok I'm stumped again. I can't seem to update my global array. And yes I am being overly simplistic. So lets dispence with the fruit array and show some real exapmles.

@InitArrays - Supressed field in report header
WhilePrintingRecords;
GLOBAL StringVar array AssignedPrimeCode := ["","","","","","","","","","","","","",""];

""//eliminates CR error


@populateDisplayArray
WhilePrintingRecords;
stringvar array AssignedPrimeCode; //your array

AssignedPrimeCode[{TreeLevels.TreeLevelDepth}+1] = {TreeLevels.TreeLevelPrimeContractor};

JOIN(AssignedPrimeCode,'-')

I get no errors BUT it displays ----------- so its not populating the array as I would like it to.
Any ideas? I'm certain the fields:
{TreeLevels.TreeLevelDepth} - integer
{TreeLevels.TreeLevelPrimeContractor} - string(12)
are populated as debugger I am also showing them in detail band. They have values but the array does not update?


-Pete[noevil]
 
I'm not at all sure what you're trying to do here:

AssignedPrimeCode[{TreeLevels.TreeLevelDepth}+1] = {TreeLevels.TreeLevelPrimeContractor};

What is that? What's the Depth field for? Are you trying to build an array out of the field {TreeLevels.TreeLevelPrimeContractor}?

For better or worse, let me assume that's what you're trying to do.

Your first formula's good. But let's change the second:

WhilePrintingRecords;
StringVar Array AssignedPrimeCode;
NumberVar Increment;

Increment := Increment + 1;

If OnFirstRecord
Then AssignedPrimeCode[Increment] := {TreeLevels.TreeLevelPrimeContractor}
Else
If Counter <= n //('n' represents your total number of &quot;&quot;)
Then
AssignedPrimeCode[Increment] := {TreeLevels.TreeLevelPrimeContractor};

In another formula, if you use:
WhilePrintingRecords;
StringVar Array AssignedPrimeCode[6];
..then you'll see the 6th value of the array.

I'm afraid I haven't tested this, so suck it and see.

Naith
 
Naith, I'll try that code. the dbase is highly structured.

I am attempting use one dbase field as the array's index for storing certain values of another dbase field so thats what this stamtment is doing

AssignedPrimeCode[{TreeLevels.TreeLevelDepth}+1] = {TreeLevels.TreeLevelPrimeContractor};

this is the array's index {TreeLevels.TreeLevelDepth}+1

this is the field I want to store {TreeLevels.TreeLevelPrimeContractor} at that index location -Pete[noevil]
 
Doh! it was missing sytnax

AssignedPrimeCode[{TreeLevels.TreeLevelDepth}+1] := {TreeLevels.TreeLevelPrimeContractor};


and thanks pelajhia for the PDF link I dloaded/printed and am using.

A star for each of you!

-Pete[noevil]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top