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

array for a field?

Status
Not open for further replies.

tarnee19

IS-IT--Management
Jan 18, 2005
24
US
I would like to know if I can declare an array for time field, for suppose I would like to store a part of table "time" in array timeIn and another part of table "time" in array timeOut, and how would I go about calling these two arrays from a formula?



 
You can, just declare them and populate them.

The version of Crystal dictates the size of arrays, and in general you should try to avoid using arrays.

Very little technical information supplied, the basics that should be included with posts are:

Crystal version
Database/connectivity used
Example data (real examples, not pseudo examples)
Expected output as a result of the example data

-k
 
I am using CR 10, through ODBC from Win XP professional.

Example of my problem:

I have string type time values, here is my <@time> formula:

numberVar secs := Round({DUPTIMRPT4.CPPCTM} mod 100);
numberVar time2 := ({DUPTIMRPT4.CPPCTM}-secs)/100;
numberVar mins := Round(time2 mod 100);
numberVar hours := Round((time2 - mins)/100);
stringVar str := CStr(hours,0,"");
stringVar str1 := CStr(mins,0,"");
stringVar str2 := CStr(secs,0,"");

if ({DUPTIMRPT4.CPPCTM} <> 999999) then
TimeValue(hours, mins,secs );

I have a <@test> formula that counts to 1 for I's and 2's for O's:

if {DUPTIMRPT4.CPTRST} = "I" then
(numberVar countS := 1;
timeVar array timeS0 := [{@TIME}]
)

else if {DUPTIMRPT4.CPTRST} = "O" then
(
timeVar array timeS01 := {@TIME};
countS := countS +1)

else if {DUPTIMRPT4.CPTRST} = "1" then
(countS := 3);
countS;


To display my columns in my desire format, i.e. when <@test> =2, I will display using <@display> formula:

numbervar i := 1;
numbervar j := 1;

if {@TEST} = 2 then ({DUPTIMRPT4.CPTRDN}&" "&{@DATE}&" "&timeVar array timeS0&" "&timeVar array timeS01[j]&" "&{DUPTIMRPT4.CPINHR}&" "&{@RUNTOTAL};
);


Output should look like:

days date timeS0 timeS01
sun 1/2/2005 10:22:34AM 3:45:33PM
sun 1/2/2005 11:23:59AM 3:43:40PM
sun 1/2/2005 09:60:38AM 09:50:38PM
mon 1/3/2005 12:00:32AM 3:33:33PM
mon 1/3/2005 09:30:67AM 09:00:32PM
tues 1/4/2005 5:40:00AM 5:40:00PM

But I get:

days date timeS0 timeS01
sun 1/2/2005 5:40:00AM 5:40:00PM
sun 1/2/2005 5:40:00AM 5:40:00PM
sun 1/2/2005 5:40:00AM 5:40:00PM
mon 1/3/2005 5:40:00AM 5:40:00PM
mon 1/3/2005 5:40:00AM 5:40:00PM
tues 1/4/2005 5:40:00AM 5:40:00PM



But the above formula only takes in the last values for time i.e. timeS0 and timeSO1, i.e. the last two records of time, I want to have all the times just like any other fields, could you please show me some light?

Thanks,
Tanzina
 
As in my previous posting, please post example data, and expected output resulting from the example data.

I don't need to see what you're getting as a result of your current methods, I need to know what you have and what you need.

-k
 
This is what I have:

days date CPTRST TIME
sun 1/2/2005 I 10:22:34AM
sun 1/2/2005 O 3:45:33PM
sun 1/2/2005 I 11:23:59AM
sun 1/2/2005 O 3:43:40PM
sun 1/2/2005 I 09:60:38AM
sun 1/2/2005 O 09:50:38PM
mon 1/3/2005 I 12:00:32AM
mon 1/3/2005 O 3:33:33PM
mon 1/3/2005 I 09:30:67AM
mon 1/3/2005 O 09:00:32PM
tues 1/4/2005 I 5:40:00AM
tues 1/4/2005 O 5:40:00PM


This is what I need:

days date timeS0 timeS01
sun 1/2/2005 10:22:34AM 3:45:33PM
sun 1/2/2005 11:23:59AM 3:43:40PM
sun 1/2/2005 09:60:38AM 09:50:38PM
mon 1/3/2005 12:00:32AM 3:33:33PM
mon 1/3/2005 09:30:67AM 09:00:32PM
tues 1/4/2005 5:40:00AM 5:40:00PM

Thanks,
Tanzina
 
Looks easy enough to cheat.

Right click the details and select format section.

In the X 2 next to suppress place the following formula:

recordnumber/2<>abs(recordnumber/2)

Now it will only display on every second row.

Now place the days, date, and time (in the timeso1 location) directly from the table into the report.

Create a formula for the time field (timeso) as in:

previous({table.time})

Should work.

-k
 
I dont see any suppress when i right click details, but there is one suppress when i right click details and that is in section expert->suppress no drill down, when i put the formula in there and follow as you said, it does not make any difference to the values.
 
RIght click on the left side of the details in the gray area and select format section. You'll see in the choices an X 2 next to suppress.

This is for placing formulas.

-k
 
Soory, I just realized you had cr 10.

If you clicked the x 2 and placed the formula in there, then it should be suppressing every odd numbered record providing you have not sorted the rows.

Another solution would be to use formulas to do the same.

In the report header place:

whileprintingrecords;
numbervar Row:= 0;

In the details use:
whileprintingrecords;
numbervar Row:= Row+1;

In the x 2 next to suppress place:

numbervar Row:= Row+1;
row/2<> abs(row/2)

-k
 
you mean use 2 formulas, one in report header and one in details and then do suppress in details?

if i do that, then only the column with Row variable that i just created using your formula gets changed, none other columns change as i wish to.
 
Can you give an example of what you mean?

And what do you get when you just used the first method described?

Text rarely conveys problems, examples work well.

-k
 
Unless you're changing the requirements...

By the term row variable I assume you mean the formula I supplied is the only one that changes.

If you look at your supplied and required, that's exactly what you asked for.

Row 1 data except for the times are identical.

-k
 
Thanks for all your help, sorted out my problem right.
 
I am trying to create an array in Crystal 8 for a 12 month year. I tried to create it as a formula but it errors as not acceptable as a formula value.

Where do I create an array?

I want to create a 12 month array and read my records to load the months with counts.
 
I responded to your other post, as you've probably realized, piggybacking on a dead thread won't get much action.

-k
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top