Formatting text

13 views
Skip to first unread message

Jostein Bakke

unread,
Dec 27, 2025, 7:07:55 AM (2 days ago) Dec 27
to TheDBCommunity
Perhaps a luxury-problem?:
I have some news-articles stored in a table, where the texts in the articles are saved in a memo-field.  (And a pointer to a PDF-file in another field – forget that.)  Using the memo-field I can search for whatever.  Lets, for simplicity sake, say that I want a list over all the articles that contain then name George.  In a report I want to display some of the text before and after the search-word, so that it is easy to se the context of the search-word(s). This I have done.

Now the question: Is it possible to format the text (using ObjectPAL) so that the search-word is bold (within the tekst)?  (…and then George did this and that…)

Jostein Bakke

Kevin Zawicki

unread,
Dec 27, 2025, 8:07:01 AM (2 days ago) Dec 27
to TheDBCommunity
There is no automatic way to do this...

I have done this is a few ways.

 

You can use a formatted memo field type and parse the test to find the words and then select the word and make it bold.

 

Find the text and select it (in OPAL).

 

Look at these types of commands (examples):

active.action(MoveRightWord)

active.action(SelectLeftWord)

 

 

Then look at something like this (snipped code)

method FontFormatKeys(var eventInfo KeyEvent) logical

 var

  ky                   string

  fs        smallInt

  retval logical

 endvar

 

 ky = eventinfo.vchar()

 retval = true

 

 if eventInfo.isControlKeyDown() = true then

  retval = false

 

  fs = active.Font.Style

  switch

   case ky = "B":

    active.Font.Style = fs.bitXOR(FontAttribBold)

 

   case ky = "U":

    active.font.style = fs.bitXOR(FontAttribUnderline)

 

   case ky = "I":

    active.font.style = fs.bitXOR(FontAttribItalic)

 

   case ky = "K":

    active.font.style = fs.bitXOR(FontAttribStrikeOut)

 

   case ky = "N":

    active.font.style = FontAttribNormal

 

   case ky = "VK_UP":

    active.font.size = active.font.size + 1

 

   case ky = "VK_DOWN":

    if active.font.size > 1 then

     active.font.size = active.font.size - 1

    endif

 

   otherwise:

    retval = true

 

  endswitch

 

 endif

 

 return retval

endMethod

 

 

Other methods include doing this outside of Paradox and pasting an RTF into the Fmemo field. This got a little trickier in the new MS Office, when it changed to XML internal format.

 Or

In OPAL parse the plain text and create a HTML doc and display in browser.

 

 


Jostein Bakke

unread,
Dec 27, 2025, 10:20:52 AM (2 days ago) Dec 27
to TheDBCommunity
Thanks a lot for the answer. I should have mentioned what I have tried:

I have tried the RTF-approach. I read in a template RTF-file into an array, like this:
[1]  {\rtf1\ansi\deff0
[2]  {\fonttbl\f0\fswiss\fcharset0\fprq2 Arial;}
[3]  Etc…

[6]  Text1
[7]  }{\f0\fs28\b\cf1
[8]  Text2
[9]  }{\f0\cf1  
[10]  Text3
[11]  }}
Item 6, 8 and 10 are changed into the «before the bold»-part of the text, item 8 is the bold part, end item 10 is the after-part (not bold).
I have tried to save this file into en RTF-file (successfully! – it will open as a rtf-file), however Paradox don't think it is a RTF-file.  I cannot get it back to a memo-variable (readFromRTFFile() will just show all the ansi-characters).

I have also tried to put the string into a field, and made objectPAL select the text I want to make bold (works OK), however I cannot find a code that works on the SELECTED text («active» will work on the field).  
(I have also tried to open the pop-up-menu for the field, but MouseRightUp won't invoke it. (Planned to use sendKeys()…).

Do you have an example of a code that works?

BTW: Merry X-mas!

Jostein Bakke

Kevin Zawicki

unread,
Dec 27, 2025, 11:34:41 AM (2 days ago) Dec 27
to TheDBCommunity
...
however I cannot find a code that works on the SELECTED text

active.Font.Style = fs.bitXOR(FontAttribBold)
works on text I have selected, I select the text by mouse or by OPAL, I am in field view mode

Jostein Bakke

unread,
Dec 28, 2025, 3:05:06 AM (yesterday) Dec 28
to TheDBCommunity
That did it!
Actually the simpler code:  active.Font.Style = FontAttribBold   also worked.
Thanks a lot!
Jostein Bakke

Steven Green

unread,
Dec 28, 2025, 9:30:07 AM (20 hours ago) Dec 28
to TheDBCommunity
just a word of caution here, if you need to write this stuff back to fields in tables.. 

memo fields are not always stable, especially if they are edited frequently
formatted memo fields are way less stable than memo fields, especially if they are edited frequently

Reply all
Reply to author
Forward
0 new messages