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

How do i print numeric array elements

Status
Not open for further replies.

ronbconfused

Programmer
Sep 26, 2005
25
US
I'm allowing the user to select one or more numeric values from a drop down. i need to print what was selected from this drop down. i can do this for alpha fields but it seems numeric elements are a different animal. Please bear with me since i am less than a month into c.r. i have 20 + years on ibm products though.

thanks for your help and i hope i was clear in what i need
 
You would need a formula to do this i.e.

Code:
//@DispalyValues
Local Numbervar i;
Local Stringvar DisplayString;

For i := 1 to ubound({?Prompt})
Do
DisplayString := DisplayString + cstr({?Prompt}[i],0,"") + " " ;

DisplayString

HTH

Gary Parker
MIS Data Analyst
Manchester, England
 
ok i'll try this. how does the variable displaystring work? i'm using version 10 and what i need to see is the following: lets say the user selects these numeric values, 718, 719, 722 omitting 720 & 721. i want to see 718, 719, 722. will the above code do this? i'm learning as i go so i need to ask the questions

thanks for your reply
 
i just tried your code and it works fine. i wasn't able to separate the numbers with a comma without having the last element print with no comma but this should work

thanks alot
 
You can get rid of the last comma by altering the last line of the formula like this:

left(DisplayString,length(DisplayString)-2)

This assumes that each values is seperated by a comma and a space. If they are just seperated by a comma, then just subtract 1 instead of 2.

~Brian
 
Bear with me here, what part of the last line do i alter or is it the entire last line of the displaystring :=
 
Change the formula like this

Code:
//@DispalyValues
Local Numbervar i;
Local Stringvar DisplayString;

For i := 1 to ubound({?Prompt})
Do
DisplayString := DisplayString + cstr({?Prompt}[i],0,"") + ", " ;

left(DisplayString,length(DisplayString)-2)

HTH

Gary Parker
MIS Data Analyst
Manchester, England
 
Perfect! Thanks so much! now i need to digest this to understand why it worked.
 
ok one more question and i will stop. in my list of values i have one coded as 999 to denote All values. How can i place the word ALL in the selection list. i tried an if statement but that is causing the and error on the keyword For. it's telling me a string is required. Here's what i placed just above the for statement:

if {?WaveSelect} = 999 then
DisplayString := 'All'

else
 
Place the check at the end i.e.

Code:
//@DispalyValues
Local Numbervar i;
Local Stringvar DisplayString;

For i := 1 to ubound({?WaveSelect})
Do
DisplayString := DisplayString + cstr({?WaveSelect}[i],0,"") + ", " ;

If {?WaveSelect} = 999 Then
    'ALL'
Else
    left(DisplayString,length(DisplayString)-2)

HTH

Gary Parker
MIS Data Analyst
Manchester, England
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top