| Author |
Message |
zach18
Groupie
Joined: 08 Feb 2011
Online Status: Offline
Posts: 46
|

Topic: Using Arrays Posted: 16 Mar 2011 at 6:43am |
|
I am currently prompting for a range of numbers. lets use 1-9 for this example. i want to put that into an array. This is what i am currently doing:
NumberVar Array NumRanges := ubound( {?Serial Nbr} );
Serial Nbr is the range of numbers, in this case 1-9.
how can i print that or even verify that it is working?
thanks
|
|
Using Crystal Report 2008
www.zachtech.us
|
IP Logged |
|
|
|
Keikoku
Senior Member
Joined: 01 Dec 2010
Online Status: Offline
Posts: 386
|

Posted: 16 Mar 2011 at 7:04am |
I believe ubound returns a single number, from what I'm reading here
If you're prompting for a range of numbers, is there a format for the input? ie: (1, 2, 3) Edited by Keikoku - 16 Mar 2011 at 7:05am
|
IP Logged |
|
zach18
Groupie
Joined: 08 Feb 2011
Online Status: Offline
Posts: 46
|

Posted: 17 Mar 2011 at 4:31am |
|
so if the user is entering a list of numbers like this 123412, 1234433, 1234433, 983872... and so on, is there a way to store that in an array?
|
|
Using Crystal Report 2008
www.zachtech.us
|
IP Logged |
|
Keikoku
Senior Member
Joined: 01 Dec 2010
Online Status: Offline
Posts: 386
|

Posted: 17 Mar 2011 at 4:43am |
|
Assuming strict standards are imposed on the input, yes.
Keep in mind that those will be string representations of numbers.
local stringvar array := split({?parameter}, ","))
However that means you will have an array as follows:
["123412", " 1234433", " 1234433", " 983872", ... ]
There's a space before every element after the first. That is expected because you only split on the comma; the spaces are left intact. Not an issue if you are converting it to a number type, but if you are using it to compare values you may find yourself wondering what's going on.
The trim function will take care of that leading whitespace.
Edited by Keikoku - 17 Mar 2011 at 4:44am
|
IP Logged |
|
zach18
Groupie
Joined: 08 Feb 2011
Online Status: Offline
Posts: 46
|

Posted: 17 Mar 2011 at 6:09am |
|
ok so this is what im attempting. get a parameter that is a range of numbers, store them into a string array, then loop through that list. not sure what im missing
stringvar array parameter := Split ({@ShipNmbr}, ",");
NumberVar NumRangesLength := count( {?Serial Nbr} );
NumberVar i = 1;
for i := 1 to NumRangesLength step 1 Do
(
NumberVar output = tonumber(parameter);
);
output;
its telling me a boolean is required
Edited by zach18 - 17 Mar 2011 at 6:11am
|
|
Using Crystal Report 2008
www.zachtech.us
|
IP Logged |
|
Keikoku
Senior Member
Joined: 01 Dec 2010
Online Status: Offline
Posts: 386
|

Posted: 17 Mar 2011 at 7:37am |
NumberVar i = 1;
Minor typo it seems.
By default the loop would increment at one step so that wouldn't be needed either. Edited by Keikoku - 17 Mar 2011 at 7:38am
|
IP Logged |
|
|
|