Your application may store some information, usually memo information, in Rich Text Format (RTF). The problem, of course, is that if the user reports on this field, they will see all of the RTF codes along with their text, making it confusing and hard to read.
One way you can handle this is to use the Microsoft Rich Text control to do the hard work of removing the RTF codes. This control has TextRTF and Text properties, so you can set its TextRTF property to your database value, and then read the plain text from its Text property. You can set this up in your Stonefield Query project as follows.
First, you need an instance of the Rich Text control to work with. In one of the scripts Stonefield Query executes during startup, such as Application.BeforeLogin, add the following lines:
SQApplication.AddProperty('oRTF')
SQApplication.oRTF = createobject('RICHTEXT.RichTextCtrl.1')
This creates a new property of the Application object and stores in it an instance of the Rich Text control. Next, create a new script named StripRTF which does the work of stripping the RTF codes:
lparameters tcRTF
SQApplication.oRTF.TextRTF = nvl(tcRTF, '')
return SQApplication.oRTF.Text
Now, you can call the StripRTF function from anywhere in Stonefield Query. For example, if your RTF is stored in a field called Customers.Comments, you could add a new calculated field to your data dictionary, with an expression of:
StripRTF( Comments )
The Microsoft Rich Text control may not necessarily be installed on the user's system. To install it using the Inno Setup script created by the Generate Setup function, do the following:
Since Inno Setup doesn't allow reading files from your Windows System folder into the generated Setup.exe, copy RichTx32.ocx from your Windows System folder (for example, C:\Windows\System32) into the Setup Files subdirectory of the Stonefield Query program folder.
In the [Files] section of the script file created by the Generate Setup function, add the following (although it's formatted on several lines here for readability, it should all be on one line):
Source: "{#SQPath}Setup Files\RichTx32.ocx"; DestDir: "{sys}"; Flags: onlyifdoesntexist sharedfile regserver
In the [Registry] section, add the following (although it's formatted on several lines here for readability, it should all be on one line):
Root: HKCR; Subkey: "Licenses\DC4D7920-6AC8-11cf-8ADB-00AA00C00905"; ValueType: string; ValueName: ""; ValueData: "iokouhloohrojhhhtnooiokomiwnmohosmsl"
© Stonefield Software Inc., 2023 • Updated: 06/06/16
Comment or report problem with topic