cucucucu
12th May 2005, 11:21
Hi,
I input text in notepad, there are three lines in it. Now I want to display them in a form, so I use these script:

after read:
select tttxt010.*
from tttxt010
where tttxt010.ctxt = :fscpp280.txta
and tttxt010.clan = "2"
and tttxt010.seqe = 1
selectdo
string.scan(tttxt010.text,"%schr$(13)%schr$(13)%s",txt1,txt2,txt3)
endselect

when I check the form, only first line has been copied to txt1, txt2 and txt3 are empty. Could anyone please help me ??
Thanks a lot!! :p

norwim
12th May 2005, 12:25
Hi there,

did you try "\n" instead of chr$(13)? I strongly suppose that the function chr$ will not be resolved when used in string.scan. Why don't you loop through the source field and split if chr$ occurs?

string tout(255,100)
string hh(255)
long tused(100)
long i,j,k
k=0
for i=1 to 100
tout(1,i)=""
tused(i)=0
endfor
select ....
selectdo
hh=""
for i=1 to len(tttxt010.text)
if tttxt010.txt(i;1)<> chr$(13) then
hh=hh & tttxt010.text(i;1)
else
k=k+1
tout(1,k)=hh
tused(k)=1
hh=""
endif
endfor
endselect

Untested, but should give you k lines of text. Will crash if k>100.

hth

Norbert

Youp2001
12th May 2005, 12:41
Why not use the standard text functions. Seems much easier to me. For example, use function text.to.buf which places the specified number of lines in an array. This array then can be displayed on you form just like all other form fields.

Success.

Youp

cucucucu
13th May 2005, 05:12
Hi Norbert,
I had tried to use "\n", the result is same as using chr$(13). Your script can work, but I think it is a little complex. Thanks for your help!!!
^_^
Best Regards,
Cu

cucucucu
13th May 2005, 05:15
Hi Youp,
I have never use this function, could you please give me a example? Thanks a lot!!!!!

Best Regard,
Cu

cucucucu
13th May 2005, 06:40
I checked the old topics about this problem, and I have modified my script as below:

#include <bic_text>
string tem.text(72,40)
long ret

ret = set.mem(tem.text,"")
if fscpp280.txta <> 0 then
select tttxt010.*
from tttxt010
where tttxt010.ctxt = :fscpp280.txta
and tttxt010.clan = "2"
and tttxt010.seqe = 1
selectdo
ret = text.to.buf("tttxt010.text",language$,40,tem.text)
txt1 = tem.text(1,1)
txt2 = tem.text(1,2)
txt3 = tem.text(1,3)
endselect
endif
But the return value of ret = 0, tem.text is empty :(
Could anyone please give me some advice?

Best Regards,
Cu

nikos1
13th May 2005, 08:18
Hi,

try this:

#include <bic_text>
string tem.text(72,40)
string txt1(72), txt2(72), txt3(72)
long ret

ret = set.mem(tem.text,"")
if fscpp280.txta <> 0 then
ret = text.to.buf("fscpp280.txta",language$,40,tem.text)
txt1 = tem.text(1,1;72)
txt2 = tem.text(1,2;72)
txt3 = tem.text(1,3;72)
endif

Regards

cucucucu
13th May 2005, 08:47
Hi Nikos1,
after executing "ret = text.to.buf(......)", the value of ret is zero. By user manual, if ret = 0, then error.

Best Regards,
Cu

nikos1
13th May 2005, 09:43
Hi,

please check, if there exists a text for your text number and language in table tttxt010.

Regards

cucucucu
13th May 2005, 10:59
I have checked. There exists a text in tttxt010. tttxt010.text have data.

lakoon
13th May 2005, 11:30
Hello

Text are stored in the database like 1 textline = 1 databasetable row. So if you start a new line in the texteditor you will get a new line in the texttable.


The function text.to.buf returns the textlines into a array.

An example:
-First check how many rows in the text
-then allocate memory for the number of rows
-retreive text
-store text in your variables
Script


domain tcmcs.str80 text.table(1)
domain tcmcs.str80 out.str(10)
.
.
field = "tiitm001.txta" | Item Text

for lang = 2 to 4 | English, German, French
text.present.in.language(text.nr, str$(lang), lines)
if lines then
out.str(1) = ""
ret = alloc.mem(text.table, 80, lines)
ret = set.mem(text.table, "")
text.to.buf(strip$(field), str$(lang), lines, text.table)
for rec = 1 to lines
| put in out.str table or in different string variables
out.str(rec) = text.table(1,rec;80)
endfor
free.mem(text.table)
endif
endfor



/lakoon

Juergen
13th May 2005, 11:30
Maybe the text exist in another language as in the language which is stored in the vaiable language$ (the users current language).

Juergen

cucucucu
26th May 2005, 10:04
Hi lakoon,
I used the script that you gave to me, the return value with text.to.buf still is 0. So I give up. Now I use belowing to replace:

select tttxt010.*
from tttxt010
where tttxt010.ctxt = :fscpp280.txta
and tttxt010.clan = "2"
and tttxt010.seqe = 1
selectdo
lng = len(strip$(tttxt010.text))
for i = 1 to lng step 1
if tttxt010.text(i;1) = change.chr then
if l1 = 0 then
l1 = i
else
if l2 = 0 then
l2 = i
endif
endif
endif
endfor
txt1 = tttxt010.text(1;80)
if l1 <> 0 then
txt2 = tttxt010.text(l1+1;80)
else
txt2 = ""
endif
if l2 <> 0 then
txt3 = tttxt010.text(l2+1;80)
else
txt3 = ""
endif
endselect


It works. Thank you all!!!
Best Regards,
Cu

cucucucu
26th May 2005, 10:05
Thank you all :)

tnzabo
16th December 2006, 06:32
I'm trying to display all text on a form in a display field. I'm stepping through and seeing all the lines go through my array however once complete I only see the first or last line of my text, depending on what I put in the element field of my form field. I don't get it. How can I see the entire text? I'm using the text.to.buf() function. Code following:

f.oper.text is my form.field
extern domain tcmcs.str80 f.oper.text(40)

function display.oper.text()
{ long rec, lines

lines = text.to.buf("tisfc010.txta", language$, 40, text.table)
for rec = 1 to lines
| put in out.str table or in different string variables f.oper.text(1,rec) = text.table(1,rec;80)
display("f.oper.text")
endfor

}