×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
• Talk With Other Members
• Be Notified Of Responses
• Keyword Search
Favorite Forums
• Automated Signatures
• Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

#### Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

# Concatenate Problem

## Concatenate Problem

(OP)
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

### RE: Concatenate Problem

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

### RE: Concatenate Problem

(OP)
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

### RE: Concatenate Problem

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.

Regards,

Ed

### RE: Concatenate Problem

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, '"', l_nos using "<<<<<", '",'
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

### RE: Concatenate Problem

(OP)
olded....

Here's what I'm getting.

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

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

SFDlopro00.4gl:m_rpt.prodclass_id  = "("TJ","E"

Ken

### RE: Concatenate Problem

(OP)
I figured out the proble why m_rpt.prodclass_id wasn't getting filled in.

Thanks,
Ken

#### Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

#### Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Close Box

# Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

• Talk To Other Members
• Notification Of Responses To Questions
• Favorite Forums One Click Access
• Keyword Search Of All Posts, And More...

Register now while it's still free!