BarbaraBartlow
Programmer
I have a PeachTree (Btrieve) database in which the user has recorded two salesman's initials if the commission on a sale is to be split. For example there may be salesmen BB and BH. If the commission is to be split, she has set up a thrid salesman called 'BB/BH' and attributed the sale to 'him'. I am now trying to develop a report showing the commission for each true sales person. What I had thought would work would be to set up arrays - one containing the salesman initials, one containing his accumulated sales, and one containing his accumulated commissions and then print the arrays as the end of the report. (below you will see additional arrays; don't be distracted, there are just certain sales that need to be broken out for a different commission rate - that's not the problem.) The problem I'm having is just finding the proper way to set up the subscript I guess. I want the logic to say, if the salesman is already in the array (have encountered previously) then add his sales/commissions to the corresponding element in the other array(s). If the salesman is not in the array, then increase the subscript by one (Redim preserve the array) and put him and the sales and commissions in the appropriate arrays. Code below only shows this portion of code, because I have not successfully gotten my first salesman in an array yet. I repeatedly get and error on the first Redim Preserve statement salying "an arrays dimension must be an integer between 1 and 1000". What am I doing wrong that "I" in the code below is not an integer to Crystal. What is the proper way of doing this.
A further question is, once I get past the issue of getting salesmen into the array, if I issue a statement like "If salesman IN arrayname" and I get a true result, how can I identify the subscript for where that salesman is in the array?
Thanks for any help offered.
Here's the code:
EvaluateAfter({@Slash});
Shared NumberVar Array SalesArray;
Shared NumberVar Array CommArray;
Shared NumberVar Array SGSalesArray;
Shared NumberVar Array SGCommArray;
Shared StringVar Array SalesmanArray;
Local NumberVar I;
Shared NumberVar Sales1;
Shared NumberVar Comm1;
Local NumberVar SGSales1;
Local NumberVar SGComm1;
Shared NumberVar Sales2;
Local NumberVar Comm2;
Local NumberVar SGSales2;
Local NumberVar SGComm2;
Shared StringVar Salesman1;
Shared StringVar Salesman2;
Local NumberVar SlashPosition;
Local NumberVar FoundPosition;
Local BooleanVar Found;
SlashPosition := INT({@Slash} - 1);
Found := False;
Salesman1 := " ";
Salesman2 := " ";
IF NOT (Salesman1 IN SalesmanArray)
THEN I := Int(UBOUND(SalesmanArray) + 1);
ReDim Preserve SalesmanArray;
ReDim Preserve SalesArray;
ReDim Preserve CommArray;
ReDim Preserve SGSalesArray;
ReDim Preserve SGCommArray;
SalesmanArray := Salesman1;
SalesArray := SalesArray + Sales1;
CommArray := CommArray + Comm1;
SGSalesArray := SGSalesArray + SGSales1;
SGCommArray := SgCommArray + SGComm1;
A further question is, once I get past the issue of getting salesmen into the array, if I issue a statement like "If salesman IN arrayname" and I get a true result, how can I identify the subscript for where that salesman is in the array?
Thanks for any help offered.
Here's the code:
EvaluateAfter({@Slash});
Shared NumberVar Array SalesArray;
Shared NumberVar Array CommArray;
Shared NumberVar Array SGSalesArray;
Shared NumberVar Array SGCommArray;
Shared StringVar Array SalesmanArray;
Local NumberVar I;
Shared NumberVar Sales1;
Shared NumberVar Comm1;
Local NumberVar SGSales1;
Local NumberVar SGComm1;
Shared NumberVar Sales2;
Local NumberVar Comm2;
Local NumberVar SGSales2;
Local NumberVar SGComm2;
Shared StringVar Salesman1;
Shared StringVar Salesman2;
Local NumberVar SlashPosition;
Local NumberVar FoundPosition;
Local BooleanVar Found;
SlashPosition := INT({@Slash} - 1);
Found := False;
Salesman1 := " ";
Salesman2 := " ";
IF NOT (Salesman1 IN SalesmanArray)
THEN I := Int(UBOUND(SalesmanArray) + 1);
ReDim Preserve SalesmanArray;
ReDim Preserve SalesArray;
ReDim Preserve CommArray;
ReDim Preserve SGSalesArray;
ReDim Preserve SGCommArray;
SalesmanArray := Salesman1;
SalesArray := SalesArray + Sales1;
CommArray := CommArray + Comm1;
SGSalesArray := SGSalesArray + SGSales1;
SGCommArray := SgCommArray + SGComm1;