|
I have in my Main report a formula using the following code:
stringVar Segments;
WhileReadingRecords;
Segments:=Segments + ({TableA.ColumnX}) + ","
This gives me an array something like Value1,Value2,etc. There may be any number of values, including none, 1, 2, or 3.
So in my subreport I have created another formula field of the same name (Segments) and pass in {?Pm-@Segments}, having previously linked the subreport to the main report via @Segments. If I display this in my subreport it gives me exactly what I expect - i.e. Value1,Value2,etc.
Now I need to extract each array element as an individual string so that I can use them in my record selection formula. For example, another Formula field using split({?Pm-@Segments},",")[1]
This works and returns the first string. However, I need to add a test to see if the array element really exists and if not substitute with some other text to avoid a run-time error.
So why does this not work:
if ubound({?Pm-@Segments}) = 3 then split({?Pm-@Segments},",")[1] else "N/A"
The argument for the Ubound function returns an error "An array is required here", yet the Split function deals only with arrays???
How can I perform this test on all my array elements?
|
|
Sorry - confusing typo corrected:
So why does this not work:
if ubound({?Pm-@Segments}) = 1 then split({?Pm-@Segments},",")[1] else "N/A"
Also if I change the code in the Main Report formula to:
stringVar array Segments;
WhileReadingRecords;
Segments:=Segments + ({TableA.ColumnX}) + ","
CR then complains that 'The result of a formula cannot be an array'. I'm very confused! I don't care whether I use an array or a simple string but it seems that the functions at my disposal to break either into its comma-delimited parts is stopping me.
Edited by MartinHalford - 01 Jul 2015 at 12:58am
|