Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: Print in While-loop? Post Reply Post New Topic
Author Message
Dake
Newbie
Newbie


Joined: 01 Oct 2010
Online Status: Offline
Posts: 1
Quote Dake Replybullet Topic: Print in While-loop?
     Posted: 01 Oct 2010 at 1:13am

Hi,

Newbie to the forum as well as to Crystal I need help with what I guess is an easy question (and yes, I have tried searching the forum...). 

My problem is that I have a list of string values in which there is a contiued series number - String looks like this:

XX-<serialnumber>-YY

XX-<serialnumber+1>-YY

XX-<serialnumber+n>-YY

Some of the values might accidentaly have been deleted, and my job is now to find and publish the "holes in the list of values". Since there might be more than one conseqtive deleted value in a row, I somehow have to loop through all missing values and also somehow publish these.

I have so far come up with this (that isn't very pretty)... in which I thought I could send a "print" command in the while loop to add the missing value:
<code>
StringVar s_ExcNo;
NumberVar n_numFirst;
NumberVar n_increaser;
StringVar s_nextValue;
NumberVar n_numSecond;
NumberVar n_numDiff;
StringVar s_Result := "";
 
// Start by emptying the increaser of possible junkvalues
n_increaser := 0;
 
// Get the numbers out of the String
s_ExcNo := Mid({MyView.MyString}, 4, 5);
n_numFirst := ToNumber (s_ExcNo);
n_increaser := n_numFirst;
 
// Get the next number
s_nextValue := Next({MyView.MyString});
s_nextValue := Mid(s_nextValue, 4, 5);
n_numSecond := ToNumber(s_nextValue);
 
// Decrease the second (NEXT) -value
n_numSecond := n_numSecond-1;
 
// Populate the difference variable with the number consecutive missing values 
n_numDiff := n_numSecond - n_numFirst;

// Check if the second number is equal to the first
If(n_numSecond = n_numFirst) THEN (
  "0" // Will be suppressed an not displayed in the report
)
Else (
// Loop whilst n_numDiff isn't '0'
    While n_numdiff > 0   
    Do (
        // Decrease the condition value
        n_numdiff := n_numDiff-1;
 
        // increase the increaser value by 1, n_numdiff times
        n_increaser := n_increaser + 1;     
// Put the resultstring together
s_Result := s_Result & n_increaser & ", ";
// NOW UGLY CONCATENATING TO SHOW THE RESULT
 
// HERE I INSTEAD WOULD LIKE TO ADD A NEW ROW WITH THE RESULTSTRING TO THE REPORT
    );
    s_Result
)
</code>
 
 
I guess there are more simple and easier ways to to this... as you see - I need help! Wink
 
Regards,
Dake
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 01 Oct 2010 at 3:44am
you could create a 'list' by using chr(13)+chr(10)..or maybe its wchr, but this isn't so much new row as allowing the text object to grow, which maybe all that you need.
 
if you order the records by the serial numbers, then you could just check if the next or last value is the current value less 1...if not, do the math to report the missing values... something like:
 
local numbervar missing := next({table.field}) + 1 - next({table.field});
if  missing > 0 then
  do loop
 
 
HTH
 
  
IP IP Logged
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum