smalltalk texteditor widget print new line - return

I am using Cincom VisualWorks and using the TextEditor widget. I am able to write data to this widget but for the life of me, I am unable to print new line (or carraige return) characters. Using "cr" as in for "Transcript: cr" doesn't work in this widget. Does anyone know what to do?

There is a method #setText:, and depending on the system you might need CR and LF:
myTextEditorWidget setText: 'line1', Character cr asString, Character lf asString, 'line2'.
if the #setText: method is not defined yet you can do so by adding this as an accessor to the class; say you told the UIBuilder that the text-field has name myText, then you can add the method:
myTextEditorWidget myText: 'line1', Character cr asString, Character lf asString, 'line2'.

Related

How to remove non-ascii char from MQ messages with ESQL

CONCLUSION:
For some reason the flow wouldn't let me convert the incoming message to a BLOB by changing the Message Domain property of the Input Node so I added a Reset Content Descriptor node before the Compute Node with the code from the accepted answer. On the line that parses the XML and creates the XMLNSC Child for the message I was getting a 'CHARACTER:Invalid wire format received' error so I took that line out and added another Reset Content Descriptor node after the Compute Node instead. Now it parses and replaces the Unicode characters with spaces. So now it doesn't crash.
Here is the code for the added Compute Node:
CREATE FUNCTION Main() RETURNS BOOLEAN
BEGIN
DECLARE NonPrintable BLOB X'0001020304050607080B0C0E0F101112131415161718191A1B1C1D1E1F7F808182838485868788898A8B8C8D8E8F909192939495969798999A9B9C9D9E9FA0A1A2A3A4A5A6A7A8A9AAABACADAEAFB0B1B2B3B4B5B6B7B8B9BABBBCBDBEBFC0C1C2C3C4C5C6C7C8C9CACBCCCDCECFD0D1D2D3D4D5D6D7D8D9DADBDCDDDEDFE0E1E2E3E4E5E6E7E8E9EAEBECEDEEEFF1F2F3F4F5F6F7F8F9FAFBFCFDFEFF';
DECLARE Printable BLOB X'20202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020202020';
DECLARE Fixed BLOB TRANSLATE(InputRoot.BLOB.BLOB, NonPrintable, Printable);
SET OutputRoot = InputRoot;
SET OutputRoot.BLOB.BLOB = Fixed;
RETURN TRUE;
END;
UPDATE:
The message is being parsed as XML using XMLNSC. Thought that would cause a problem, but it does not appear to be.
Now I'm using PHP. I've created a node to plug into the legacy flow. Here's the relevant code:
class fixIncompetence {
function evaluate ($output_assembly,$input_assembly) {
$output_assembly->MRM = $input_assembly->MRM;
$output_assembly->MQMD = $input_assembly->MQMD;
$tmp = htmlentities($input_assembly->MRM->VALUE_TO_FIX, ENT_HTML5|ENT_SUBSTITUTE,'UTF-8');
if (!empty($tmp)) {
$output_assembly->MRM->VALUE_TO_FIX = $tmp;
}
// Ensure there are no null MRM fields. MessageBroker is strict.
foreach ($output_assembly->MRM as $key => $val) {
if (empty($val)) {
$output_assembly->MRM->$key = '';
}
}
}
}
Right now I'm getting a vague error about read only messages, but before that it wasn't working either.
Original Question:
For some reason I am unable to impress upon the senders of our MQ
messages that smart quotes, endashes, emdashes, and such crash our XML
parser.
I managed to make a working solution with SQL queries, but it wasted
too many resources. Here's the last thing I tried, but it didn't work
either:
CREATE FUNCTION CLEAN(IN STR CHAR) RETURNS CHAR BEGIN
SET STR = REPLACE('–',STR,'–');
SET STR = REPLACE('—',STR,'—');
SET STR = REPLACE('·',STR,'·');
SET STR = REPLACE('“',STR,'“');
SET STR = REPLACE('”',STR,'”');
SET STR = REPLACE('‘',STR,'&lsqo;');
SET STR = REPLACE('’',STR,'’');
SET STR = REPLACE('•',STR,'•');
SET STR = REPLACE('°',STR,'°');
RETURN STR;
END;
As you can see I'm not very good at this. I have tried reading about
various ESQL string functions without much success.
So in ESQL you can use the TRANSLATE function.
The following is a snippet I use to clean up a BLOB containing non-ASCII low hex values so that it then be cast into a usable character string.
You should be able to modify it to change your undesired characters into something more benign. Basically each hex value in NonPrintable gets translated into its positional equivalent in Printable, in this case always a full-stop i.e. x'2E' in ASCII. You'll need to make your BLOB's long enough to cover the desired range of hex values.
DECLARE NonPrintable BLOB X'000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F202122232425262728292A2B2C2D2E2F303132333435363738393A3B3C3D3E3F';
DECLARE Printable BLOB X'2E2E2E2E2E2E2E2E2E2E2E2E2E2E2E2E2E2E2E2E2E2E2E2E2E2E2E2E2E2E2E2E2E2E2E2E2E2E2E2E2E2E2E2E2E2E2E2E2E2E2E2E2E2E2E2E2E2E2E2E2E2E2E2E';
SET WorkBlob = TRANSLATE(WorkBlob, NonPrintable, Printable);
BTW if messages with invalid characters only come in every now and then I'd probably specify BLOB on the input node and then use something similar to the following to invoke the XMLNSC parser.
CREATE LASTCHILD OF OutputRoot DOMAIN 'XMLNSC'
PARSE(InputRoot.BLOB.BLOB CCSID InputRoot.Properties.CodedCharSetId ENCODING InputRoot.Properties.Encoding);
With the exception terminal wired up you can then correct the BLOB's of any messages containing parser breaking invalid characters before attempting to reparse.
Finally my best wishes as I've had a number of battles over the years with being forced to correct invalid message content in the "Integration Layer" after all that's what it's meant to do.

#HttpContext.Current.User.Identity.Name not showing backslash

Super Simple. Only issues I find are people getting null. Which I obvi fixed. But where is the backslash???!!
params.me = '#HttpContext.Current.User.Identity.Name';
This returns
"domainUserName" <- Browser
"domain\\UserName" <- Debugging
What I expect is
"domain\UserName" <- Browser
Any ideas?
Based on your comments you are using the following code to show the user name:
alert('#HttpContext.Current.User.Identity.Name');
#HttpContext.Current.User.Identity.Nameis a string that can contain "\" backslash character. This character is considered as a escape character in javascript as it is in C# as well.
You need to escape the "\" character in the string before passing it to Javascript like that:
alert('#HttpContext.Current.User.Identity.Name.Replace("\\", "\\\\")')

Long strings in system Keyboard plist settings

I try add my own characters in keyboard.
I expand key 'z' by code to "Keyboard-en.plist":
"Roman-Accent-z" = {
Keycaps = "z mylongstringtitle ..."; // ... == \U017e \U017a \U017c characters ('z' with apostrophes and dots)
Strings = "z mylongstringvalue ...";
};
But keyboard not shown my string 'mylongstringtitle', only blank space ' ':
I can add only string 4 chars length on normal font and 7 chars on small font on 'button'. But I need add a long string.
Can I add 'mylongstringtitle' inside keycaps's string? May be I need set special parameters for long string? This is possible?
I don't think you will be able to add long string to be displayed in keyboard-en.plist. I believe the limitations of 4/7chars that you discovered are hard-coded in desire to avoid disfigured popup.
This keyboard behavior is not supported by Apple (it's not documented on http://developer.apple.com, or http://devforums.apple.com). Use of this feature in your app, therefore, is undefined behavior, which is considered programmer error.
That said, it's a neat feature. The limits of 4 and 7 characters for keycaps are hardcoded on iOS. I can't find them in any of the keyboard plists. You'd probably have to modify the keyboard binary to do what you want. (On OS X, on the other hand, this limit does not exist.)
A few alternatives exist, which you might know about:
You could modify this custom keyboard project
You could assign a custom inputView to be displayed at the top of the system keyboard

RichEdit.PlainText seems to not affect anything

I'm trying to write something like rtf editor in BCB6 and I've encountered such problem while trying to add table to my RichEdit1:
RichEdit1->PlainText=true;
AnsiString ret=RichEdit1->Text;
ret.Insert(table, RichEdit1->SelStart);
RichEdit1->Text=ret;
RichEdit1->PlainText=false;
RichEdit1->Repaint();
This code adds formatted text (code of table) to the RichEdit1 instead of adding formatting code as plain text and displaying it like a table.
Am I doing it wrong, or it can be a problem with something else.
The PlainText property is only used by the Lines->LoadFrom...() and Lines->SaveTo...() methods, nothing else.
The Text property only operates on plain text. Reading the property extracts the RichEdit's textual content without formatting. Setting the property does not process RTF code at all, the RichEdit's textual content is replaced with the new text as-is.
If you want to insert RTF code into the RichEdit, especially if you don't want to overwrite the RichEdit's current content, you will have to use the EM_STREAMIN message directly. For example:
DWORD CALLBACK StreamInCallback(DWORD_PTR dwCookie, LPBYTE pbBuff, LONG cb, LONG *pcb)
{
int numRead = reinterpret_cast<TStringStream*>(dwCookie)->Read(pbBuff, cb);
if (pcb) *pcb = numRead;
return 0;
}
TStringStream *strm = new TStringStream(table);
EDITSTREAM es = {0};
es.dwCookie = (DWORD_PTR) strm;
es.pfnCallback = &StreamInCallback;
SendMessage(RichEdit1->Handle, EM_STREAMIN, SF_RTF | SFF_SELECTION, reinterpret_cast<LPARAM>(&es));
delete strm;
Problem solved, formatting was not added because of table code was not in {} brackets, after adding them around table code and using SendMessage, program works well.

Problem with TAdvMemo component (about wordwrap)

I am using TAdvMemo. My problem is with the WordWrap property. It works very well when I type text in the text area, but when I add a string to it in code, it has no effect.
I have set WordWrap property to: wwRightMargin and RightMargin property to 80, but not see other property that can help me, so i ask some idea as solve it?
i mean for example:
AdvMemo.Lines.Add(MyString);
where MyString is a string as: 'hello word'. When it is longer than 80 chars, and wrap is enabled, it should wrap to a new line, but instead it's all on the same line.
Try using AdvMemo.InsertText instead. Lines.Add doesn't care about wrapping, it just handles some special chars in the string.
After you added text to adv memo you must update wrap by calling UpdateWrap() function. Here is an example for you:
AdvMemo.Lines.Add(MyString);
AdvMemo.UpdateWrap();
or
AdvMemo.Lines.Text(MyString);
AdvMemo.UpdateWrap();
Be sure that WordWrap property of Adv Memo is different than wwNone.

Resources