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!

Concatenate Problem

Status
Not open for further replies.

phxcoyotes097

Programmer
Feb 19, 2003
16
US
I need help on concatenating some variables in a program.
I knows it's probably simple, but can't find any documentation on it.

Example:

12
13
14

Need:

("12", "13", "14")

Thanks,

Ken
 
Ken:

There's many ways to do this. Hopefully, this is what you have in mind:

Regards,

Ed

##("12", "13", "14")

main

define scratch CHAR(80),
s1 CHAR(4),
s2 CHAR(4),
s3 CHAR(4),
quote CHAR(4),
comma CHAR(4)

let s1= "12"
let s2= "13"
let s3= "14"
let quote = "\""
let comma = ", "

LET scratch = "(", quote clipped, s1 clipped, quote clipped, comma clipped,
quote clipped, s2 clipped, quote clipped, comma clipped,
quote clipped, s3 clipped, quote clipped,")"
end main
 
What does the ## in front of ("12", "13", "14") mean? I want to use it with the result from the parse routine you gave me yesterday. The above would the the final result for my SQL "IN" statement.

Ken
 
Ken:

This:


##("12", "13", "14")

is just a quoted-out string. Sorry if it confused you. I read your question, and I see what you're trying to do.

I'll try to answer your question tonight...

Regards,

Ed
 
Hi,

Hope the following routine meets your requirement.

Regards,
Shriyan


database testdb
main
call test()
end main

function test()

define i,l_nos smallint, l_string varchar(64)

-- create a temp table and dump sample patterns
create temp table t_x (nos smallint) with no log
for i=10 to 13
insert into t_x values (i)
end for

-- declare a cursor for gathering rows from temp table
declare t_x_cur cursor for select nos from t_x

let l_string='('

open t_x_cur
while (1)
fetch t_x_cur into l_nos
if status=notfound then exit while end if

-- fetched variables are concatenated.
let l_string=l_string clipped, '&quot;', l_nos using &quot;<<<<<&quot;, '&quot;,'
end while

-- cut-off the trailing extra character (,)
let i=length(l_string clipped)
let l_string=l_string[1,i-1], ')'

-- show the result
display l_string

end function
 
olded....

Here's what I'm getting.

This is the scratch variable
SFDlopro00.4gl:input_form.scratch = &quot;(&quot;TJ&quot;,&quot;ED&quot;)

When I set m_rpt.prodclass_id = scratch I get the following

SFDlopro00.4gl:m_rpt.prodclass_id = &quot;(&quot;TJ&quot;,&quot;E&quot;

Ken
 
I figured out the proble why m_rpt.prodclass_id wasn't getting filled in.

Thanks,
Ken
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top