array - Crystal Reports Training, Books, and Forum

Author: Ada

Jun. 30, 2025

13

0

0

Tags: Mechanical Parts & Fabrication Services

array - Crystal Reports Training, Books, and Forum

Author Message rptxyz
Newbie



Joined: 24 Nov
Online Status: Offline
Posts: 27
Topic: array
    Posted: 09 Jan at 10:33pm like to make an array from a field in a crystal 9 report using formula. like to know how many elements the array has and to access any of its elements using an index within the range. any example on how to do it?. MakeArray did not work for me. IP Logged Lugh
Senior Member



Joined: 14 Nov
Online Status: Offline
Posts: 377
Posted: 10 Jan at 4:44am Let me try to restate this a bit, to see if I understand you correctly.

You want to store all of the values for a given field into an array.  You then want to perform various array functions on this.  Correct?

This is very possible, and not even all that tricky once you know the technique.  However, you need to be aware that there are some timing issues involved.  You may need to become very familiar with WhileReadingRecords, WhilePrintingRecords, and EvaluateAfter.  Brian's book has an excellent section on these.

In order to accomplish this, you need to create a global array variable, use ReDim Preserve on each record to expand it, and then store the value of the current field.  Your formula would look something like:


Global StringVar Array X;
//You can use NumberVar or anything else, as required.

ReDim Preserve X[RecordNumber];
//ReDim Preserve establishes the size of the array, without dropping existing data.
//RecordNumber is an existing Crystal function that gives the number of the current record. 
//As you move to each new record, the RecordNumber will increment by 1.


X[RecordNumber] := {MyReport.MyField}
//This stores the current value in the new slot in the array.


You can then run any array functions on this you might need.  You should, ideally, use these functions in the report footer, to ensure that all records are read into the array.  However, you can try using WhileReadingRecords on this formula, and WhilePrintingRecords on the calculation formula, which should work.


IP Logged rptxyz
Newbie



Joined: 24 Nov
Online Status: Offline
Posts: 27
Posted: 10 Jan at 7:34am so this,X[RecordNumber] := {MyReport.MyField} , is the whole array or just an element?.  how array size is determined?. your explanation was very helpful. IP Logged Lugh
Senior Member



Joined: 14 Nov
Online Status: Offline
Posts: 377
Posted: 10 Jan at 10:43am It's just a single element.  The size of the array is established by the ReDim command.  Since you ReDim on every record, it will always increase the size of the array by 1 each time.  (Keep in mind that arrays can only have elements, so keep your record count as low as you can!)

And, I made the same typo here.  It should be X(RecordNumber), with parentheses, not square brackets.  Not sure where my head was this morning. 


IP Logged rptxyz
Newbie



Joined: 24 Nov
Online Status: Offline
Posts: 27
Posted: 10 Jan at 9:24pm IP Logged Lugh
Senior Member



Joined: 14 Nov
Online Status: Offline
Posts: 377
Posted: 11 Jan at 4:31am OK, I see a few problems here.

How is index being populated in formula1?  I noticed the comment about the for loop.  What is the for loop doing?  Can you post the entire formula?

In formula2, you may need to explicitly put EvaluateAfter(@formula1).  I have a feeling that you are attempting to call the array before you initialize it.

Speaking of which, you didn't include your scope indicators in your copied text.  You are setting these as Global, yes?


IP Logged rptxyz
Newbie



Joined: 24 Nov
Online Status: Offline
Posts: 27
Posted: 11 Jan at 8:33am IP Logged Lugh
Senior Member



Joined: 14 Nov
Online Status: Offline
Posts: 377
Posted: 11 Jan at 11:19am Originally posted by rptxyz

created :
formula1:
whileprintingrecords;
numbervar array crarray;
numbervar index;
if not({report.field} in crarray) then
index : index + 1

View Details

This should be:

index := index + 1

if index <=
Redim Preserve crarray[index];
crarray[index] := {report.field}));

Where did these parentheses come from?

Explore more:
What is Juki Spare Parts and Why Do We Use Them?
BSP Female Hose Fittings - Fitsch

You will get efficient and thoughtful service from EBO.

formula2:
whileprintingrecords;
numbervar array crarray[1];

You probably still need to put the EvaluateAfter statement in here.


IP Logged rptxyz
Newbie



Joined: 24 Nov
Online Status: Offline
Posts: 27
Posted: 11 Jan at 8:12pm got the same error when put @formula1 and @formula2 next to each other in detail section but got no error when put the @formula1 in detail but moved @formula2 to page footer. could not make it work when both were in detail section.

Linear Arrays of Crystal GAGG, CSI, CWO, GOS

Linear Arrays, which are made from single row of pixels, or slabs of scintillation crystals, are to be optically reflective and isolating. Their assemblies are typically coupled with pixellated photodiodes & Silicone photomultipliers and used quite often in security type applications, such as baggage scanners, cargo inspection, and other non-destructive testing. When used in a nuclear medical application, crystals such as LYSO are used in Bone Mineral Densitometry or Positron Emission Tomography(PET) machines. 

The scintillation crystals that can be produced into linear arrays include most commonly used CsI(Tl), CdWO4, GOS, LYSO(Ce), GAGG(Ce) and BGO, we could also produce linear arrays from other scintillation materials like YSO(Ce), YAG(Ce), YAP(Ce) and Plastic Scintillator etc. We offer a variety of design options in terms of pixel size, pixel pitch, the number of pixels, pixel separator materials and crystal surface finishes, in order to optimize array performance during actual application. Our manufacturing process ensures the arrays with high light output, high sensitivity, high resolution as well as excellent pixel-to-pixel, batch-to-batch uniformity with minimal crosstalk.

Are you interested in learning more about Crystal Array? Contact us today to secure an expert consultation!

Comments

Please Join Us to post.

0

0/2000

Guest Posts

If you are interested in sending in a Guest Blogger Submission,welcome to write for us.

Your Name: (required)

Your Email: (required)

Subject:

Your Message: (required)

0/2000