Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2020 : Report Design
Message Icon Topic: getting values from an array Post Reply Post New Topic
Author Message
zach18
Groupie
Groupie
Avatar

Joined: 08 Feb 2011
Online Status: Offline
Posts: 46
Quote zach18 Replybullet Topic: getting values from an array
    Posted: 18 Mar 2011 at 6:48am
StringVar Array parameter := Split ({@serial#}, ",");

NumberVar NumRangesLength := count( {?Serial Nbr} );

Global NumberVar i = 1;

NumberVar output = tonumber(parameter);
    
if NumRangesLength > 0 then
    parameter;
    i = i + 1;

for some reason parameter isnt showing the array sign[], but it is there with i in it.
How can i get the items out of an array? parameter is an array of incrementing numbers, i just need to get that out and display it on a new page.




Edited by zach18 - 18 Mar 2011 at 7:06am
Using Crystal Report 2008
www.zachtech.us
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4372
Quote lockwelle Replybullet Posted: 21 Mar 2011 at 3:16am
yeah, evidently [] with i inside is the tag for italics
 
StringVar Array parameter := Split ({@serial#}, ",");

NumberVar NumRangesLength := ubound(parameter);

Global NumberVar x = 1; 

    
if NumRangesLength > 0 then
    parameter[x]; 
    x := x + 1;
revised the code slightly, but it dawned on me, you will see nothing, as you are not looping, and the last you thing that is being displayed is probably the number 2.
 
so as a test, to access the array try:
StringVar Array parameter := Split ({@serial#}, ",");

NumberVar NumRangesLength := ubound(parameter);

Global NumberVar x = 1; 
local stringvar test ="";
for x+1 to NumRangesLength     Do
(  test := test + parameter[x]; 
);
  
test
 
HTH
IP IP Logged
zach18
Groupie
Groupie
Avatar

Joined: 08 Feb 2011
Online Status: Offline
Posts: 46
Quote zach18 Replybullet Posted: 22 Mar 2011 at 4:38am
ok i've got the code working, but how can i test the array? i'm a java programmer mainly so i at a lost on how to display this. any ideas?
Using Crystal Report 2008
www.zachtech.us
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4372
Quote lockwelle Replybullet Posted: 24 Mar 2011 at 3:40am
pass in a string of serial # and see what is displayed...I know it sounds obvious, but that is what 'test' at the end does, it displays the result of the concatenation of the array that was split...at least it should.
IP IP Logged
zach18
Groupie
Groupie
Avatar

Joined: 08 Feb 2011
Online Status: Offline
Posts: 46
Quote zach18 Replybullet Posted: 24 Mar 2011 at 4:36am
ok so im having a different problem now.

StringVar Array parameter := Split ({@serial#}, ",");

@serial# is a formula that i created that just has the parameter Serial Nmbr in it.

the formula wont accept that, it says a string is required because i put the parameter into the xbound code we have setup.

how to i get out each individual part of the parameter?
Using Crystal Report 2008
www.zachtech.us
IP IP Logged
Keikoku
Senior Member
Senior Member


Joined: 01 Dec 2010
Online Status: Offline
Posts: 386
Quote Keikoku Replybullet Posted: 24 Mar 2011 at 4:41am
maybe you can try to pass in CStr({@serial#}) since it wants a string?
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4372
Quote lockwelle Replybullet Posted: 25 Mar 2011 at 3:51am
or, you could hard code a string of comma delimited numbers in the formula...then you know the input and desired output and see if they match.
 
Sorry, I thought you would have already done that to get the code to work
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.