Subscribe for automatic updates: RSS icon RSS

Login icon Sign in for full access | Help icon Help
Advanced search

Pages: [1]
  Reply  |  Print  
Author Topic: working with Textedit-Fields  (Read 11271 times)
Stefan S.
Posts: 90


« on: February 19, 2009, 09:54:25 am »

Hello,
to write free text in "old"-4JS BDL we used an input array with f.e. 60 Characters per line.
Each row in the array we stored as 1 row in a table.

In many Reports we printed each row of this table with 60 Characters.

No I want to use the textedit field instead of an Array.

I definded a string-variable and read the text from the table and append it to the string.
After each row I added an ascii 10 to have the same Text-Layout as before in the array.
The per file is using a fixed Fontpitch, so I can only use 60 Characters per Line.

That works very fine.

But now I wrtie a new text. At the end of the line a new word is beginning at at next line (without CR) ....

When I save the Text in  the table I must be able to split the text after 60 Character, but at lines with  "Word-Wrap"  the "Blanks" at the end of the lines where clipped. So the 60 charactrers has the Information from 2 lines of from my Screen, but 2 Lines on the screens must be to lines in the table.


I hope you understand my problem.

Has anyone an idea for me

thanks in advance

Stefan Serwe
Snorri B.
Posts: 103


« Reply #1 on: February 19, 2009, 10:32:47 am »

Stefan,

you just need to create a routine that splits the text something like:
Code
  1. define txt string, line char(60), more char
  2. .
  3. .
  4. -- Before inserting
  5. call split_text(txt, 60) returning txt, line, more
  6. while more -- or whatever
  7.  insert into ......
  8.  call split_text(txt, 60) returning txt, line, more
  9. end while
  10.  

Hope this helps,
-Snorri
Stefan S.
Posts: 90


« Reply #2 on: February 19, 2009, 10:57:00 am »

Thanks Snorri,
but splitting the text after 60 characters ist not the problem

I attached a hardcopy to sh my problem.

In this case I need to create 2 Lines in my table.



* textedit.jpg (111.2 KB, 872x538 - viewed 1508 times.)
.
Four Js
Posts: 115


« Reply #3 on: February 19, 2009, 11:16:12 am »

Stefan,

maybe the solution is in the "wrapPolicy" TextEdit style Attribute.
set it to "anywhere" then GDC will wrap your text after 60 characters, then you will see in the first line "12...WORD" and in the second "WRAP" instead of "12...90" and "WORDWRAP".

Code
  1.  <Style name="TextEdit">
  2.     <StyleAttribute name="wrapPolicy" value="anywhere" />
  3.  </Style>


* wordwrap.jpg (17.86 KB, 532x193 - viewed 1500 times.)
Snorri B.
Posts: 103


« Reply #4 on: February 19, 2009, 11:20:34 am »

Stefan, you just need to check in your routine if the user has enetered <LF>
We actually have a routine that works:
Code
  1. function split_text(text,blen)
  2.  
  3. define
  4.  text varchar(10000),
  5.  blen,tlen,i integer
  6. if blen <= 1 then
  7.  return text clipped,null      -- Illegal length
  8. end if
  9. let tlen = length(text)
  10. ------------------------------------------------------------------
  11. -- Do we get an EOL within our split?
  12. ------------------------------------------------------------------
  13. for i = 1 to minint(blen + 1,tlen) step 1
  14.  if text[i,i] = "\n" then
  15.    case
  16.    when tlen = 1 return null,null
  17.    when i = 1 return null,text[i+1,tlen]               -- First char is EOL
  18.    when i = tlen return text[1,i-1],null               -- Last char is EOL
  19.    otherwise return text[1,i-1] clipped,text[i+1,tlen] -- Line fits
  20.    end case
  21.  end if
  22. end for
  23. ------------------------------------------------------------------
  24. -- Check if last split
  25. ------------------------------------------------------------------
  26. if tlen <= blen then
  27.  return text clipped,null
  28. end if
  29. ------------------------------------------------------------------
  30. -- Check if we need to split words
  31. ------------------------------------------------------------------
  32. for i = minint(blen + 1,tlen) to 1 step -1
  33.  if text[i,i] = " " then
  34.    case
  35.    when i = 1 return null,text[i+1,tlen]               -- First char space
  36.    when i = tlen return text[1,i-1],null               -- Last char space
  37.    otherwise return text[1,i-1] clipped,text[i+1,tlen] -- Line split
  38.    end case
  39.  end if
  40. end for
  41. ------------------------------------------------------------------
  42. -- We need to split within a word
  43. ------------------------------------------------------------------
  44. return text[1,blen],text[blen+1,tlen]
  45.  
  46. end function
  47.  
  48. function minint(val1,val2)
  49.  
  50. define val1,val2 integer
  51. case
  52. when val1 is null return val2
  53. when val2 is null return val1
  54. when val1 < val2 return val1
  55. otherwise return val2
  56. end case
  57.  
  58. end function
  59.  
  60.  
  61.  

split_returns null if it finished so you can use this in a loop like:

Code
  1.  
  2. while nigsamn.aths is not null
  3.   call split_text(nigsamn.aths,76) returning rep,nigsamn.aths
  4.    if rep is not null then
  5.      call reportput(rep)
  6.      let icnt = icnt + 1
  7.    end if
  8. end while
  9.  
Stefan S.
Posts: 90


« Reply #5 on: February 19, 2009, 01:03:27 pm »

OK many Thanks for the tipps

Reply 3:
it works fine, but if I want to copy a text from a document and paste it into the 60-Characters textedit field there is a lot of work to correct the layout of the thext.

Reply 4:
This is excactly what I want to do. Great.

Pages: [1]
  Reply  |  Print  
 
Jump to:  

Powered by SMF 1.1.21 | SMF © 2015, Simple Machines