Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Array problem? Post Reply Post New Topic
Author Message
Nauip
Newbie
Newbie


Joined: 18 Feb 2008
Online Status: Offline
Posts: 2
Quote Nauip Replybullet Topic: Array problem?
    Posted: 18 Feb 2008 at 12:04pm

WhilePrintingRecords;
StringVar ExtText;
StringVar array lines := Split(ExtText, "~;~");
StringVar Desc := lines[1];
StringVar Exempt := "";
StringVar CoO := "";
StringVar MoP := "";
StringVar Misc := "";
NumberVar i;

For z := 1 to Ubound(lines) Do (
    If Instr(UpperCase(lines[z]), "EXEMPT") > 0              Then Exempt := lines[z]
    Else If Instr(UpperCase(lines[z]), "PRODUCT OF") > 0     Then CoO := Trim(Mid(lines[z], 11))
    Else If Instr(UpperCase(lines[z]), "WILD") > 0           Then MoP := lines[z]
    Else If Instr(UpperCase(lines[z]), "FARM") > 0           Then MoP := lines[z]
    Else Misc := Misc & lines[z];
);

Recently updated from Crystal 8.5 to 10 and this used to work fine then. Now I'm getting: "A subscript must be between 1 and the size of the array." and lines[1] (next to desc in the declarations) is highlighted (I assume this means it is the offending code)
Using an ODBC Connection to a MAS200 database. Confused
disclaimer : arrays (in Crystal) confuse the heck outta me and I'm relatively new to Crystal Reports. Most of them were created by the previous admin and I'm just trying to keep them going.


Edited by Nauip - 18 Feb 2008 at 12:06pm
IP IP Logged
BrianBischof
Admin Group
Admin Group
Avatar

Joined: 09 Nov 2006
Online Status: Offline
Posts: 2458
Quote BrianBischof Replybullet Posted: 19 Feb 2008 at 10:52pm
What is happening is that the line above it is using the Split() function to break out a line of text into multiple lines. The text uses "~;~" to mark where the lines should be split. If there isn't anything in the text, then no array gets created and you'll get that error. So you should check your data to make sure it matches the format necessary.

You can find out more about arrays and everything else related to Crystal data types and functions in three chapters in my book Crystal Reports Encyclopedia.
Please support the forum! Tell others by linking to it on your blog or website:<a href="http://www.crystalreportsbook.com/forum/">Crystal Reports Forum</a>
IP IP Logged
HiloFish
Newbie
Newbie


Joined: 18 Feb 2008
Online Status: Offline
Posts: 2
Quote HiloFish Replybullet Posted: 27 Feb 2008 at 12:55pm
well, to work around it I moved the desc = part into the loop and left the var declaration at the top empty.
IP IP Logged
Post Reply Post New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum



This page was generated in 0.031 seconds.