ANSI Standard PL/B Language and Visual PL/B
EditText Object Notes
NOTE TO OUR READERS
This web resource is written for our own use. But we feel strongly that the PL/B language should be shared with the software community. So feel free to use this at will!
BUT PLEASE...
if you find errors or omissions or have a better way to do something. TELL US! Dialog helps us all. Send e-mail to:
support@mmcctech.com
EditText Object
The
EditText object is one of the most fundamental objects for the Visual PL/B programmer. It's so common that it seems easy. These notes are just to remind us of some things that we seldom use. I won't even write about the basics for now, just the things I need to remember.
- CURSOR POSITION:
Once you get the data INTO an EditText you may want to position the cursor to an insertion point within the string. The instruction is:
SETITEM {edittext},1,nn .Where nn is the position
To force the cursor to the end of the string you can say SETITEM x,1,999.
This may require you to use or not use the SELECTALL property. I can't remember right now.
- FINDING BLOCKED TEXT
The user may block some text in the middle of the edit text and you want to know where it is.
For example, you might provide a float menu based on a right click. In that menu you could have the usual cut and copy but you might also have UPPER CASE. When they click that you want to get the blocked text and convert it all to upper case.
To find the starting and ending positions of the blocked text, do this:
GETITEM {edittext},1,nn .nn will get the STARTing byte
GETITEM {edittext},2,nn .nn will get the ENDing byte
You can also retrieve just the blocked text by using code "1", but having the receiving field be a string:
GETITEM {edittext},1,string .string gets blocked text
RichEditText Object
There has been some question about how to use this object in PL/B. The following discussion was found on the Sunbelt Forum in the "Example Programs" section under the topic "Richedittext" posted by Matthew Lake on 8/06/2004.
Matt has an example program:
Download Link
Robert Leidy came back on 3/05/2012 with the following:
Where the text is formatted like a word document? If so I've found a way to accomplish this using the rich-text object. What I do is build the document I want in Micorosoft Word (because I need a spell checker), and then save in the rich-text format. As this point you could open that .rtf file in a text editor and view the rich text code, it will looks somewhat like this...
"\cf2\f1\'b7\tab\b\f0 ASCII Printable Characters\cf0\b0 : ASCII decimal values from 32 to 126."
...lots of jibberish but still plain-old-ascii data.
If you want to distribute the .rtf file with your application, you could at runtime open the .rtf file as a "file" and read the contents into a string and then setprop the richtextobject,text=thatbigstring.
Or if you didn't want to distribute the .rtf you could take that data and within your program...
rtfData init "(cut and paste the rtf data here)"
and then at runtime just setprop richtext,text=rtfData
I've found an optional-additional step that makes things I little cleaner. I re-open the .rtf document in Microsoft WordPad (aka write.exe), and hit the save button. A lot of the fluff-extra-jibberish gets removed making that bigString of data smaller.
v1.10