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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Convert String Array to Number Array

Status
Not open for further replies.

overton

Programmer
Feb 1, 2002
2
US
I have multiple STRING parameters/inputs the user can select for search criteria for the report. I need to view the search critera in a field. I have no problem using a number array in the parameters and viewing the search criteria on the report in a field, but I am having much trouble with the string arrays. I have tried to convert the string array to a number array.
-------------
numbervar ArrayCount:= count({?stringarray});
numbervar Stepper;
numbervar array NewNumberArray:= [0];
redim NewNumberArray[1000];

for Stepper:= 1 to ArrayCount do
NewNumberArray[Stepper] := tonumber({?stringarray}[Stepper]);
-------------
If anyone knows of a way in which I do not have to convert the string array to a number array, I would greattly appreciate help.
 
I think you cannot use Redim in crystal syntax...in crystal syntax you must predefine the array before assigning values

Also the array maximum is limited to 1000 elements

So with that in mind you can set up your new number array for the maximum no. of elements (initialize the array to a ridiculous number...say 99999

numberVar Array NewNumberArray := [99999,99999,99999,
99999,99999,99999,
.... until 1000];

now I think this has a chance to work

for Stepper:= 1 to ArrayCount do
(
NewNumberArray[Stepper] := tonumber({?stringarray}
[Stepper]);
);


But that said...why do you need a whole new array? Why can you not just convert to numbers as you need them?



 
shared paramcount as number
'counts the number of entries to a parameter

'NOTE: =====
'
'A range type parameter counts as one entry.
'
'===========

shared increment as number
' increments the loop so that all parameter entries can be displayed

shared output as string
' creates a string "running total" so that all entries can be displayed

paramcount = count({?Reader Number})
Do While paramcount > increment
increment = increment +1
IF maximum({?Reader Number}(increment)) <> minimum({?Reader Number}(increment)) _
THEN output = output + minimum({?Reader Number}(increment)) + &quot; to &quot; + maximum({?Reader Number}(increment)) + chr(10) _
ELSE output = output + maximum({?Reader Number}(increment)) + &quot; &quot;
Loop

formula = output


works great
 
FYI-

Redim is a valid crystal syntax command. Software Support for Sage Mas90, Macola, Crystal Reports, Goldmine and MS Office
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top