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

Exit a formula using basic syntax

Status
Not open for further replies.

stateprog

Programmer
Mar 7, 2002
4
US
I write my Crystal Reports formulas using basic syntax. There are occasions when I want to exit a formula before executing the last instruction. How do I do that? What keyword do I use? I've tried EXIT and END and EXIT SUB and EXIT FUNCTION and STOP and QUIT. I've tried GOTO a label name and that's no good either. Just what is the magic word to do this?
 
:) You can exit a loop with
Exit While or Exit For

But you cannot exit a formula unless these loops are the last instruction block of the formula

Jim Broadbent
 
Okay Jim, and thanks. maybe I can skin this cat another way....which prompts another question. I'm creating an array of unique values during the reading records pass. I'll use this for totals during the printing records pass. I put my array loading formula in the suppresed detail line. For each record I cycle through the array to see if I already have the value. If not, I increase an array index variable and load my new value into the next array element. This will not work correctly because I cannot seem to preserve the index variable value from one record to the next. In VB I should be able to solve this by defining the variable as STATIC. Crystal doesn't allow this. Is there any way to make this variable persistent?
thanks I
 
Hi .... I would not really do what you are doing as I understand it.

Filling an array - WhileReadingRecords - is dicey at best and usually flakey....it should be done - whilePrintingRecords - since you have no control.

increment the array index variable??? do you mean increase the value of a particular array element or expand the array??

Explain your problem in more detail. You can maintain a position in an array by creating a position variable that you can reference if you want

Lsyout your problem in detail and we shall suggest an alternative.

Jim Broadbent
 
Why can't you preserve the index variable?

You're probably best served to provide example data and expected output, someone here will probably provide a solution very quickly.

-k

 
This is a daily operator statistic report for a scanning process.
The scanning is done in three stages. In simplified format, each record has six fields, a Scan ID, Scan Date, a Scan Verify ID, Scan Verify Date a Supervisor Verify ID, and a Supervisor Verify Date. An individual operator may be the scanner and/or verifier and/or supervisor verifier for any record. This summary report should look like this:

OPERATOR #SCANNED #VERIFIED #SUPERVISOR VERIFIED

JOE 12 15 23
MARY 0 32 43
SUE 45 6 16

Pardon the ragged layout. My approach is to load an array with unique operator names during the record read pass, then compute totals for each during the record print pass.
Maintaning my position in the array as I load the names is my problem.
 
I was able to do something similar using two formulas.

The first formula determines the position of the member of the array. If the (in this case) user is not in the array it gets added and it's position noted:

//{@position}\whileprintingrecords;

shared stringvar array users;
local numbervar loop;
local numbervar loop2;
local numbervar count1:=1;


IF {@users}in users then
(for loop:= 1 to ubound(users) do(
if users[count1]={@users} then
loop:=ubound(users)
else count1:=count1+1))

else

(for loop2:=1 to 1 do(
redim preserve users[ubound(users)+1];
users[ubound(users)]:={@users};
count1:=ubound(users)));

count1-1


This formula uses the results from the first formula and adds 1 to a count for the user.

EVALUATEAFTER({@position});
whileprintingrecords;

shared numbervar array accum1;
shared stringvar array users;

(redim preserve accum1[ubound(users)];
accum1[{@position}]:=accum1[{@position}]+1)






Mike
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top