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!

Mbarron - would you be so kind as to elaborate on your advise

Status
Not open for further replies.
Mar 10, 2003
25
GB
Hi Mike

Thank you for your advise yesterday re time schedules in Crystal, I have followd your instructions carefully - but the error I get is "NUMBER OF COPIES OF THE STRING IS TOO LARGE OR NOT AN INTEGER". Am I correct in the following...
The first formula {@to - from} goes to details
The second formula {@sched init} goes to Group header
The third formula {@sched accum} goes to Details, next to {@to - from}
The forth formula {@sched display} goes to Group footer
I must also surpress all existing data
??? I am sure I am missing something somewhere, please advise,...your message from yesterday below...
..."You can do this with 4 formulas and some formatting. You'll need to use a monospace font type. You'll need to group on your day.
I used "sched.class" to represent the [HIST] etc. above
Formula one formats the data to span your time columns. If you want the columns to be wider change the 10This formula goes in the details band:
{@to - from}
stringvar out;
numbervar spaces:=(({sched.to}-{sched.from})*24)*10 ;
out:="["+{sched.class}+replicatestring(" ",spaces-len({sched.class}))+"]"
You'll need three formulas to display the data.
This one goes in the group header.
{@sched init}
whileprintingrecords;
stringvar sched:=""
This one goes in the details band:
{@sched accum}
whileprintingrecords;
stringvar sched;
sched:=sched+{@to - from}
This one goes in the group footer:
{@sched display}
whileprintingrecords;
stringvar sched
Move the Group Name into the footer and suppress the group header and the details band.
It should look like this - (I eliminated the last "class" for display purposes):
8:00 9:00 10:00 11:00 12:00
Mon [MBA ][SLA ][HIST ]
Tue [SLA ][MBA ][GEN MAN ]
Wed [HIST ][MBA ][GEN MAN ]"
 
You didn't specify which formula the error occured. I'm guessing it was this one:

stringvar out;
numbervar spaces:=(({sched.to}-{sched.from})*24)*10 ;
out:="["+{sched.class}+replicatestring(" ",spaces-len({sched.class}))+"]"

If that is the case, It's because one of the fields is "too long" for the formula. Change the 10 to a larger number. What the formula is doing is taking the time difference between start and stop (in hours) and mulitpling by 10.

For example, if your "class" is 0.5 hours long, the formula changes that to 5. It then subtracts the number of characters from the class name from that number and adds that many spaces to the end of the field. If the class name is longer than, in this case, 5 the formula errors out because it is trying to create a negative number of spaces.

For future postings - Please reply to your oringinal postings instead of strarting a new thread. I always check my previous "unclosed" threads. Plus I have the email notification set.
Mike
 
Hi Mike

Still have the same error. This is an example of the headings and one line of report data:

Prog_ID Start_Date Start_Time Session_Time End_Time Session_Name
ALP1503 10/04/2003 15:30:00 3.50 19:00:00 Mary Kennedy_10/04/2003_15:30:00

Note the formats are dd/mm/yyyy hh:mm:ss

So I have changed the {@to - from} formula to read...

Stringvar out;
numbervar spaces:=(({@End time}-{Tutor_History.TH_Start_Time})*24)*10 ;
out:="["+{@Unique field}+replicatestring(" ",spaces-len({@Unique field}))+"]"

I have replaced the '10' with '20', '30', '32', '40' and even up to '75' but no result - the error remains "Number of the copies of the string is too large or not an integer"

All your help is appreciated.

Thanks,
Etienne
 
Try adding a "round" to the formula. In testing I had the "too short problem" You may be experiencing the non-interger.

change this:
spaces:=(({@End time}-{Tutor_History.TH_Start_Time})*24)*10

to this:
spaces:=round((({@End time}-{Tutor_History.TH_Start_Time})*24)*10 ) Mike
 
{@sched accum} in this case is called {@Sched accum}
and {@sched display} in this case is called {@Sched display}

Now I created the forst formula, {@Data size}...
stringvar out;
numbervar spaces:=(({Sessions.SES_End_Time}-{Sessions.SES_Start_Time})*24)*10 ;
out:="["+{@Session Name}+replicatestring(" ",spaces-len({@Session Name}))+"]"

Now I created the second formula, {@Sched init}...
whileprintingrecords;
stringvar sched:=""

Now I created the third formula, {@Sched accum}...
whileprintingrecords;
stringvar sched;
sched:=sched+{@Data size}

Now I created the last formula, {@Sched displayed}...
whileprintingrecords;
stringvar sched

...so far so good - but now I get to the uncertain part...

1) I surpress all the fields in the details section of the current Report Fields - this only leaves the {Ses_Date} group headers
2) I placed {@Data size} in the deatils band
3) I placed {@Sched init} in the group header next to Group # 1 name (i.e. {Ses_date})
4) I placed {@Sched accum} in the details band next to {@Data size}
5) I moved Group # 1 name (i.e. {Ses_date} to the group footer)
6) I placed {@Sched displayed} in the group footer, next to Group # 1 name (i.e. {Ses_date})
7) I suppressed the group header and details band

...now when I preview I get the error "The number of copies of the string is too large or not an integer"
This error occurs in {@Data size}. To try and solve, I followed your suggestions...

a) I changed the "*10" on {@Data size} to 3, 5, 15, and 25 - same error
b) I chande the {@Data size} formula to...
stringvar out;
numbervar spaces:=round((({Sessions.SES_End_Time}-{Sessions.SES_Start_Time})*24)*10) ;
out:="["+{@Session Name}+replicatestring(" ",spaces-len({@Session Name}))+"]"
And replaced the "*10" with 3, 5, 15, and 25 - same error

Is there anything that sticks out immediately as what might be causing this problem? Could it be that the {@Session name} field is a formula
as opposed to a normal field from the database?

Many thanks,
Etienne
 
Mike

This is a copy of what the basic report look like...


SES_Prog_ID SES_Module_ID SES_Date SES_Start_Time SES_Session_No SES_End_Time SES_Room_ID Session Name
07/04/2003
ALP1503 1 07/04/2003 08:30:00 1 13:00:00 38 AAA
ALP1503 1 07/04/2003 14:00:00 1 19:00:00 38 BBB
ALP1503 1 07/04/2003 20:30:00 1 21:30:00 38 CCC

08/04/2003
ALP1503 1 08/04/2003 09:00:00 1 13:00:00 38 DDD
ALP1503 1 08/04/2003 14:00:00 1 15:30:00 38 EEE
ALP1503 1 08/04/2003 15:30:00 1 18:00:00 38 FFF
ALP1503 1 08/04/2003 18:00:00 1 19:00:00 38 GGG
ALP1503 1 08/04/2003 20:30:00 1 21:30:00 38 HHH

09/04/2003
ALP1503 1 09/04/2003 09:00:00 1 12:30:00 38 III
ALP1503 1 09/04/2003 13:30:00 1 19:00:00 38 JJJ
ALP1503 1 09/04/2003 20:30:00 1 21:30:00 38 KKK

10/04/2003
ALP1503 1 10/04/2003 09:00:00 1 13:00:00 38 LLL
ALP1503 1 10/04/2003 14:00:00 1 15:30:00 38 MMM
ALP1503 1 10/04/2003 15:30:00 1 19:00:00 38 NNN
ALP1503 1 10/04/2003 20:30:00 1 21:30:00 38 OOO

11/04/2003
ALP1503 1 11/04/2003 08:30:00 1 13:30:00 38 PPP
ALP1503 1 11/04/2003 14:00:00 1 16:30:00 38 QQQ

Please note that:
"sched.class" in this case is {@Session Name} - a formula that creates unique "class" names - just for the sake of getting my head around this issue
{@to - from} in this case is called {@Data size}
{@sched init} in this case is called {@Sched init}
{@sched accum} in this case is called {@Sched accum}
and {@sched display} in this case is called {@Sched display}

Now I created the forst formula, {@Data size}...
stringvar out;
numbervar spaces:=(({Sessions.SES_End_Time}-{Sessions.SES_Start_Time})*24)*10 ;
out:="["+{@Session Name}+replicatestring(" ",spaces-len({@Session Name}))+"]"

Now I created the second formula, {@Sched init}...
whileprintingrecords;
stringvar sched:=""

Now I created the third formula, {@Sched accum}...
whileprintingrecords;
stringvar sched;
sched:=sched+{@Data size}

Now I created the last formula, {@Sched displayed}...
whileprintingrecords;
stringvar sched

...so far so good - but now I get to the uncertain part...

1) I surpress all the fields in the details section of the current Report Fields - this only leaves the {Ses_Date} group headers
2) I placed {@Data size} in the deatils band
3) I placed {@Sched init} in the group header next to Group # 1 name (i.e. {Ses_date})
4) I placed {@Sched accum} in the details band next to {@Data size}
5) I moved Group # 1 name (i.e. {Ses_date} to the group footer)
6) I placed {@Sched displayed} in the group footer, next to Group # 1 name (i.e. {Ses_date})
7) I suppressed the group header and details band

...now when I preview I get the error "The number of copies of the string is too large or not an integer"
This error occurs in {@Data size}. To try and solve, I followed your suggestions...

a) I changed the "*10" on {@Data size} to 3, 5, 15, and 25 - same error
b) I chande the {@Data size} formula to...
stringvar out;
numbervar spaces:=round((({Sessions.SES_End_Time}-{Sessions.SES_Start_Time})*24)*10) ;
out:="["+{@Session Name}+replicatestring(" ",spaces-len({@Session Name}))+"]"
And replaced the "*10" with 3, 5, 15, and 25 - same error

Is there anything that sticks out immediately as what might be causing this problem? Could it be that the {@Session name} field is a formula
as opposed to a normal field from the database?

Many thanks,
Etienne




 
I've been able to reproduce the error three ways.
1: the name length was too long -this I fixed by increasing the 10.

2: a non interger occured when multipling * 10 (I used half hour intervals in testing) this was fixed by the "round"

3: if the end time is less than the start time. This results in a negative string replication . Try reversing the fields for this part ({Sessions.SES_End_Time}-{Sessions.SES_Start_Time})


Try adding the following to the begining of the formula to see if the {@session name} may be causing a problem.

evaluateafter({@Session name});


If you can send the report to me with data (but without the fields I supplied on the canvas. Leave them with the report just don't insert them) I'll see if I can figure out what's causing the error. If you are using Version 9 I won't be able to open the report, we'd have to continue working on it here.

mbarron"@"arkwright.com Mike
 
With the data you posted I got the results below --- I changed the 10 to a 3 because it was the longest field name (plus it made for a better fit here.

Code:
07/04/2003     [AAA           ][BBB            ][CCC]
08/04/2003     [DDD         ][EEE  ][FFF     ][GGG][HHH]
09/04/2003     [III        ][JJJ              ][KKK]
10/04/2003     [LLL         ][MMM  ][NNN        ][OOO]
11/04/2003     [PPP            ][QQQ     ] Mike
 
Mike

I emailed the report to you (I use Crystal 8.0). I have tried your suggestions but with no success. I hope the report I have emailed will help.
It was emailed to mbarron@arkwright.com

Etienne
 
Eureka.

I was subtracting a datetime field, while you are using a time field. When subtracting a datetime the results are in days while subtracting time fields are in seconds.

Change the field to this:
numbervar spaces:=(({Sessions.SES_End_Time}-{Sessions.SES_Start_Time}))/3600*4 ;

The same this applies for the "4" as it did for the 10. If you are dealing with half hour increments, use an even number. (Divide your longest field name by your shortest increment) and you shouldn't have a problem with field lengths. If there are other increments, use the round function. Mike
 
That was indeed what caused the error!!!

Thanks for all the help - now I can progress this matter. I owe you 1000 beers!

Etienne
 
As with most things the problem does not end here!!!

I am refining the report (discussed above), and as soon as I add another table, and place any of the table fields on the report - it get the following error, "A string can be at most 254 characters long", and the error seems to occur in formula {@sched accum}
i.e:
whileprintingrecords;
stringvar sched;
sched:=sched+{@Data size}
No string size in that table is that long though???

Anything stands out as a possible cause?

Etienne
 
It's adding all of the string lenghs together. For example, 8 strings at 35 characters long would be 280 characters wide.

How wide is the page size you are using. At a size ten font, 254 chartacters is about 16 inches long.

Mike
 
Mike

The page I am using is a normal A4 size. I am still batteling to get my head around the 4 formulas. I am working with realy long {@Session Name} fields, even up to 254 characters. And there might be multiple "Classes" per day (Classes = @Session Name). Does these limitations mean that Crystal cannot do this scheduling? I have also through about representing the @Sessin Names by another key (e.g. 1, 2, 3, 4) which will make the @Session name/ similar only 2 or 3 characters long.

What do you suggest?

Etienne
 
CR9 will support string fields longer than 254 characters, previous versions do not

I would suggest using the representing the @Sessin Names by another key (e.g. 1, 2, 3, 4) you've mentioned.

Mike
 
Just a last question

Using a unique key to represent the long 'class name' not a problem - but the 4 formulas does not take into consideration multiple daily start times, but only seem to determine area sizes according to "Start time" and "End time" of the classes. This is not a true reflection, as some classes could strat at 8:30 and others at 9:00, etc.
The representation should therefor looki like this...
8:00 9:00 10:00 11:00 12:00 13:00 ...
Mon [1 ][2 ][3 ][ ...
Tue [4 ][5 ][ ...
Wed [6 ][7 ][ etc

Is this possible?
Many Thanks
Etienne
 
Here it is;

stringvar out;
stringvar start:="";

if onfirstrecord then
(numbervar spaces1:=round(({sched.from}-time(8,0,0))*3600)*4 ;
if spaces1=0 then start else
start:=replicatestring(" ",spaces1+2))

else

if {sched.day}<>previous({sched.day}) then
(numbervar spaces1:=round(({sched.from}-datetime(8,0,0))*3600)*4 ;
if spaces1=0 then start else
start:=replicatestring(&quot; &quot;,spaces1+2));

numbervar spaces:=round((({sched.to}-{sched.from})*3600)*4) ;
out:=start+&quot;[&quot;+{sched.class}+replicatestring(&quot; &quot;,spaces-len({sched.class}))+&quot;]&quot;


Mike
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top