defjam90
10th April 2008, 12:03
Hi,

I am trying to remove the carriage return from text field , but I am unable to caputre the carriage return.I would like to make the text as a continous field & remove the carriage returns & replace it with letter "Z"

Here is the logic I am using.
txt = string(240)
select tttxt010.*
from tttxt010
where tttxt010._index1 = {:tibom010.txta} selectdo
txt = tttxt010.text
endselect

txt = PRINT LABEL AS FOLLOWS:"\n""RETROFIT 1482 TRANSDUCER"
\n = carriage return


End result(Required Output)
txt = PRINT LABEL AS FOLLOWS:"Z"RETROFIT 1482 TRANSDUCER"

I would like to remove the carriage return & replace it with "Z"


I have tried using several unix command using the shell option , but I am unable to remove the carriage return for ex rets = shell("sed 's/old/new/g' input.txt > output.txt",0)

Let me know the solution to over come the above problem.

I can easily do the replace using toad , using the following statment select replace (t$text,chr(10),'') from ttttxt010110 where t$ctxt = 184220

Unfortunately i cannot use this syntax with in a baan session

Let me know the solution to over come the above problem.

zardoz
10th April 2008, 12:29
After selection of txt, try this:


pcr = pos(txt, CR)
while pcr
txt(pos;1) = "Z"
pcr = pos(txt, CR)
endwhile


before, obvoiusly, you have to declare:


long pcr
#define CR chr$(13)

BaanInOhio
10th April 2008, 17:05
You can also use some text utilities to perform this task. This will also cover the situation where text may be stored in multiple 'tttxt010' records due to the text length:

Set up a 'based' string array = "string text.lines(1,1) based"
Call 'text.present.in.language' to determine number of lines in text = 'tibom010.txta'.
Use 'alloc.mem' to allocate string array to number of lines from 'text.present' call, select a wide enough string length value.
Call "text.to.buf" to move text lines to the array.
Loop for the number of lines in the buffer - read place the stripped contents of each line to a buffer, terminated with a your desired character between lines.

learner
27th June 2011, 22:08
After selection of txt, try this:


pcr = pos(txt, CR)
while pcr
txt(pos;1) = "Z"
pcr = pos(txt, CR)
endwhile


before, obvoiusly, you have to declare:


long pcr
#define CR chr$(13)



txt(pos;1) = "Z"


should be


txt(pcr;1) = "Z"


also for some reason I had to use chr$(10) for Carriage Returns.

-Learner

mark_h
28th June 2011, 00:34
I think it depends on the OS. I can't remember which is which - but I do not sometimes we run into problems moving files from windows platform to UNIX platform.

bdittmar
28th June 2011, 14:07
Hi,

I am trying to remove the carriage return from text field , but I am unable to caputre the carriage return.I would like to make the text as a continous field & remove the carriage returns & replace it with letter "Z"

Here is the logic I am using.
txt = string(240)
select tttxt010.*
from tttxt010
where tttxt010._index1 = {:tibom010.txta} selectdo
txt = tttxt010.text
endselect

txt = PRINT LABEL AS FOLLOWS:"\n""RETROFIT 1482 TRANSDUCER"
\n = carriage return


End result(Required Output)
txt = PRINT LABEL AS FOLLOWS:"Z"RETROFIT 1482 TRANSDUCER"

I would like to remove the carriage return & replace it with "Z"


I have tried using several unix command using the shell option , but I am unable to remove the carriage return for ex rets = shell("sed 's/old/new/g' input.txt > output.txt",0)

Let me know the solution to over come the above problem.

I can easily do the replace using toad , using the following statment select replace (t$text,chr(10),'') from ttttxt010110 where t$ctxt = 184220

Unfortunately i cannot use this syntax with in a baan session

Let me know the solution to over come the above problem.

Hello,

use text.to.buf() !

Regards