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!

Using Arrays to create outpu

Status
Not open for further replies.

UHsoccer

Programmer
Apr 24, 2003
139
US
Using CR 8.5, I have twelve (12) formulas that look like

// In row 2
whileprintingrecords ; numbervar monthStart ;
if monthStart = 12 then "Januar"
else if monthStart = 1 then "Februar"
else if monthStart = 2 then "Marz"
etc for each month
and
//in row 3
whileprintingrecords ; numbervar monthStart ;
if monthStart = 11 then "Januar"
else if monthStart = 12 then "Februar"
else if monthStart = 1 then "Marz"
etc for each month

Once complete, I need to create the same report in English, French and Dutch
I would like to create an array with the month names, so I can update it in ONE place and all formulas will follow. Remember, there are twelve formulas each with twelve entries and then four languages

I started with

whileprintingrecords ; stringvar array monthNameDef ;
monthNameDef[1] := "Januar";
monthNameDef[2] := "Februar";
monthNameDef[3] := "Marz" ;

Then trying to apply, I used the definition as

whileprintingrecords ; stringvar array monthNameDef ;
monthNameDef[1] := "Januar";
monthNameDef[2] := "Februar";
monthNameDef[3] := "Marz" ;
etc

But in using it as follows, I get the "a subscript must be between 1 and the size of the array" error.

whileprintingrecords ; numbervar monthStart ; stringvar array monthNameDef ;
if monthStart = 1 then monthNameDef[1] //"Januar"
else if monthStart = 2 then monthNameDef[2] //"Februar"
else if monthStart = 3 then monthNameDef[3] //"Marz"

Please help
 
I don't see where you are initializing the values for monthStart.

-LB
 
The definition for "monthStart" is in a different group segment of the report and it looks like

whileprintingrecords ; numbervar monthStart ;
monthStart := month(date({Projects.StartDate})) ;

It is really the use of an array that is my problem.
I have seen the "Ubound", but not sure how to apply that
 
You need to state the size of the array.

I'd take a different approach though, create one report and use a parameter to determine the language.

So declare the variables, as in:

whileprintingrecords ;
stringvar array monthNameDef[12];
if {?MyLanguageParameter} = "English" then
monthNameDef[1] := "January";
monthNameDef[2] := "February";
monthNameDef[3] := "March" ;
...etc...
else
if {?MyLanguageParameter} = "French" then
monthNameDef[1] := ...etc...
else
if {?MyLanguageParameter} = "Dutch" then
monthNameDef[1] := ...etc...

Now when you use them later, don't define them again, just use:

whileprintingrecords ;
stringvar array monthNameDef;
monthNameDef[month({table.datefield}))

or reference your monthstart variable in the formula and use that.

I've no idea why you have different formulas, and keep in mind that you cannot be placing formulas in row 1, 2, etc., Crystal allows you to place formulas in sections, one of which is the Details, which is where individual rows show up, so the whole description and requirements you're trying to convey are lost.

It would appear that you are new to Crystal, so I suggest that you stop stating what the architecture must be, and instead post technical information and requirements:

Database/connectivity used
Example data
Expected output

Anyway, the above should resolve your array concerns.

-k
 
I use the parameter "Lanuage" to define the name of the months and placed the formula in the header as

whileprintingrecords ; stringvar array monthNameDef[12] ;
if {?Language} = "German" then
(monthNameDef[1] := "Januar";
monthNameDef[2] := "Februar";
etc, through
monthNameDef[12] := "Dezember" ; )
else
if {?Language} = "English" then
( monthNameDef[1] := "January";
monthNameDef[2] := "February";
etc, Through
monthNameDef[12] := "December" ;)

It response with
"A subscript must be between 1 and the size of the array"


-------------------

Once the above is solved, the next step is

Here is the "technical Information" :

When a contract starts in March, the output has to show
Mar
Apr
etc
Feb

If the contract starts in December
Dec
Jan
etc
Nov

I plan to use 23 definitions (jan-dec followed by jan-nov) and then use the final formula as

whileprintingrecords ;
stringvar array monthNameDef[23];

1st position : monthNameDef[month({table.datefield})]
2nd position : monthNameDef[(month({table.datefield}) + 1 ]
etc
12th position : monthNameDef[(month({table.datefield}) + 12]


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top