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!

Is it possible to loop an array value..

Status
Not open for further replies.

varavoorvishnu

Programmer
Sep 9, 2002
45
Hi All,
Is it possible to loop an array value..
For instance i have an array declared "a" which holds the values of string from
"Monday" to "Sunday" stored in the array..
Incase i need to print all the values from the array at a time,what should i do??
I dont want to give hard corded way like a[1],a[2]..and so on.
Please suggest me..

Vishnu
 
Hi synapsevampire ,
I would like to tell u that i am using Crystal Reports 7.0 and so the formula u gave did not work..Please suggest another alternative for looping the array value and display the values at a time.

Vishnu
 
Try something like:

whileprintingrecords;
stringvar array MyArray := {?a}; //your array
stringvar MyOutPut;
numbervar x;

for x := 1 to 7 do(
MyOutPut := MyOutPut+MyArray[x]+chr(13)
);
MyOutPut

-k kai@informeddatadecisions.com
 
for x := 1 to 7 do(
MyOutPut := MyOutPut+MyArray[x]+chr(13)
);
is not supported in crystal report 7.0
 
Sorry, I thought it was, I always forget what is available, try using a while instead, I checked and it's supported in 7:

whileprintingrecords;
stringvar array MyArray := {?a}; //your array
stringvar MyOutPut;
numbervar x;

while x < 7 do(
MyOutPut := MyOutPut+MyArray[x]+chr(13);
x := x+1
);
MyOutPut

-k kai@informeddatadecisions.com
 
synapsevampire:
It says an error that &quot;The Remaining part of the expression cannot be identified&quot; and the code doesnot save itself.
Vishnu
 
Sorry, forgot to initialize the X now that I changed from a FOR:

whileprintingrecords;
stringvar array MyArray := {?a}; //your array
stringvar MyOutPut;
numbervar x := 1;

while x < 7 do(
MyOutPut := MyOutPut+MyArray[x]+chr(13);
x := x+1
);
MyOutPut kai@informeddatadecisions.com
 
&quot;The Remaining Text doesnot appear to be Part of the Formula&quot;---> This is the error which CR7 gave when i gave
your code..

while x < 7 do(
----------------
MyOutPut := MyOutPut+MyArray[x]+chr(13);
x := x+1
);
MyOutPut

and that the cursor stands near the while loop after the Error message pops up.
It means that it doesnot support while loop in CR7..
Please give me an alternative solution.


Vishnu

 
It requires all of the code:

whileprintingrecords;
stringvar array MyArray := {?a}; //your array
stringvar MyOutPut;
numbervar x := 1;

while x < 7 do(
MyOutPut := MyOutPut+MyArray[x]+chr(13);
x := x+1
);
MyOutPut

This works fine here, and you need to reference your where I placed {?a}

-k kai@informeddatadecisions.com
 
I got a input parameter or a parameter field called
{?GetVal}.I give multiple inputs using input parameter field and so it will be stored in an array in {?GetVal}.
Now as u said i shall place the
{?GetVal} in place of ur {?a},even then it gives the same problem..Why could u give me another solution and wat is ur real name..I could not type ur name its too long..

Vishnu
 
Yours is probably a numeric VALUE, not a string...

This will concatenate your weekdays as numbers if that's what they are.

whileprintingrecords;
stringvar array MyArray := {?a}; //your array
stringvar MyOutPut;
numbervar x := 1;

while x < 7 do(
MyOutPut := MyOutPut+dayofweek(MyArray[x])+chr(13);
x := x+1
);
MyOutPut

This works fine here, and you need to reference your where I placed {?a}

-k kai@informeddatadecisions.com
 
Sorry, I didn't change the array type on the pervious post:

Yours is probably a numeric VALUE, not a string...

This will concatenate your weekdays as numbers if that's what they are.

whileprintingrecords;
Numbervar array MyArray := {?a}; //your array
stringvar MyOutPut;
numbervar x := 1;

while x < 7 do(
MyOutPut := MyOutPut+dayofweek(MyArray[x])+chr(13);
x := x+1
);
MyOutPut

-k kai@informeddatadecisions.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top