macahu
2nd May 2005, 20:31
Hi everybody,
How can I use the concat$ function in order to get the separator beween the feelds : ;;
item;;quantity;;delivery date;;amount
Thanks for your help ;
mark_h
2nd May 2005, 21:00
Something like:
some.string = concats(";;",tiitm001.item,somedate,someamount)
This will put them into a string. If you need date in some format other than what this does look at some of the date conversion strings. I usually use sprintf$ to get dates into a readable format.
macahu
4th May 2005, 00:44
Hi mark,
It doesn't work, the function send always ";" and not ";;"
Regards
Usually the separator is one character.
string concat$( string separator, expr, ... )
should be actually -
string concat$( string separator(1), expr, ... )
for clarity.
Alternatively, you can use "&" operator or sprintf$() function.
Example with ** as separators -
temp = concat$("**", "hello", "world")
temp = sprintf$("**%s**%s", "hello", "world")
~Vamsi
4th May 2005, 18:06
Looks like an opportunity to write our own concat$.
function myconcat$(...)
{
|Anyone upto the challenge?
}
Here is part of my code, others can improve it.
|****************************************************
function main()
{
string temp(256)
temp = myconcat("*", "hello")
temp = myconcat("*", "hello", "world")
temp = myconcat("*", "hello", "world", "testing")
temp = myconcat("**", "hello", "world")
temp = myconcat("***", "hello", "world")
temp = myconcat("***", "hello", "world", "testing")
temp = myconcat("||", "hello", "world")
}
function string myconcat(const string sepa(), ...)
{
long i, leng
string result(1) based
string str.arg(1024)
e = alloc.mem(result, 1)
result = ""
for i = 2 to get.argc()
str.arg = get.string.arg(i)
leng = len(result) + len(str.arg)
if i = 2 then
leng = leng - 1
endif
e = alloc.mem(result, leng)
if isspace(result) then
result = "" & str.arg
else
leng = leng + len(sepa)
e = alloc.mem(result, leng)
result = strip$(result) & sepa & str.arg
endif
endfor
return(result)
}
|********************************************************