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

Global array var

Status
Not open for further replies.

wmbb

Technical User
Jul 17, 2005
320
NL
I've created a formula field containing the code below...
Code:
Global StringVar array ASmembers := ["LAMMERS","DUNGEN","TROMP","ESSERS","KRYSTEK","SMULDERS"];

In another formula field I want to use the array ASmembers as follows....
Code:
"Selected AS members: "+ JOIN(ASmembers, ", ");

But the array is not recognized.
ERROR message: ") is missing"
When I put the declaration described above on top of this new formula field it works again, but I don't want to declare the same array in more formula fields.

Whats going wrong ?
 
Cannot say for sure since I have not worked with arrays much. But for Global/Shared variables, you have to 're-declare' the variable (i.e., Global StringVar array ASmembers;) in every formula that you need it.
 
Unfortunately this doesn't work.
Anyone another suggestion I can try ?
 
kray4660's advice was absolutely correct. Amend your second formula to start with the Variable declaration and it will work. It should look like this:

Code:
Global StringVar array ASmembers;
"Selected AS members: "+ JOIN(ASmembers, ", ");

The fact that you "...don't want to declare the same array in more formula fields" really doesn't matter. It's just the way Crystal Reports works - ie that every formula must contain a declaration of all variables used within that formula.

Cheers
Pete


 
Hi pmax9999,

That is exactly what I tried but didn't work....
Also replacing "Global" by "Shared" didn't work....

At this moment I fully declare the array in more formula fields using
Code:
Global StringVar array ASmembers := ["LAMMERS","DUNGEN","TROMP","ESSERS","KRYSTEK","SMULDERS"];

But if the array changes I have to modify the array in every formula field !
 
Please provide more details.
[ul]
[li]What do you men by "It doesn't work". Do you mean you are getting an error message, or it is giving the wrong answer?[/li]
[li]What sections are the 2 formulas in?[/li]
[li]Are there sub reports involved?[/li]
[/ul]

Please also post the actual code used in your formulas.

Cheers
Pete

 
I would think you would not fully declare it again (i.e., Global StringVar array ASmembers; vs. Global StringVar array ASmembers := ["LAMMERS","DUNGEN","TROMP","ESSERS","KRYSTEK","SMULDERS"]; )
 
I can't get it to work.
Something strange happens....

See file attached.
The main string array is declared in @ASmembers.
If the full declaration is repeated in @test1, both options, @test1 and @test2, are showing the right results in the report even when in @test2 the array is not fully declared.

Changing the full declaration in @test1 to the short declaration, both options, @test1 and @test2, are showing no results in the report ??!!

Anyone a suggestion ?
 
 http://files.engineering.com/getfile.aspx?folder=02eda32c-e8de-4818-a2f2-cd6956e1b2f8&file=Report1.rpt
Not sure how the sample file explains your problem. The Array needs to be populated in a section prior to where you want to display the contents.

It would help if you explained what you are actually trying to do. It doesn't make sense to me why you would manually build an array only to display it in a later section. Why wouldn't you just manually build the display string when you need it?

Cheers
Pete


 
I create personal reports for users of our department.
One of the users want to create a weekly overview of the planned work only for the people of their group.
When finished, normally the next user comes to me to create such a report for their group.

So my thought was to filter the records using the ASmembers array.
Only the members-records will be shown in the report.

Because it is not visible for the user of the report what select criteria was used I want to show the ASmembers defined in the report footer.

But when the groupmembers changes now I have to change it in two formula's and this is not the way I normally work.
If you define an array and their should be a modification I want to change it at one location.

I hope you understand the essence of story....
 
Still not sure I understand.

Why are you using the array to Filter the records? Unless I misunderstand what you are doing it would be better and simpler to filter identify the Members in the Record Selection Formula. If you are using separate reports for each user you might just as well hard code the report to display the members, or a formula that extracts the list of members using the RecordSelection function.

Better still, build a single report with a Parameter to identify the User and code the Record Selection Formula to select the appropriate Members for that user. The User, and the Members could easily be displayed on the report using a simple formula.

Regards
Pete

 
Hi Pete,

You're absolutely right.
This is what I do indirectly.
I defined the array in a (boolean) formula field and use this field in the record selection...
Code:
Global StringVar array ASmembers := ["LAMMERS","DUNGEN","TROMP","ESSERS","KRYSTEK","SMULDERS"];
if {ORDTASK.ANALYST} in ASmembers then TRUE else FALSE

In the record selection I defined (among others):
Code:
{FOLDERS.XDATE_IN} in {?period} and {@ASmember} and {@AStechniques}

Now you're asking I don't know why I've chosen for this option ....?
Maybe to simplify the record selection or to have an option to display the ASmembers in the report, I don't know !

Is there another easy way to show (a part of) the record selection in the report footer ?

But.....
I still want to know why the global array option doesn't work like expected !!!

In any case, thanks for thinking with me.


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top