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
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
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
Ken
RE: Concatenate Problem
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
RE: Concatenate Problem
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
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
Thanks,
Ken