Fix for TnXMLScreen.Render()

Topics: Developer Forum, Project Management Forum, User Forum
Jul 12, 2008 at 1:19 AM
Hello everyone,

I have modified the Render() method in TnXMLScreen.cs so that it works correctly.

In some cases it would not return a screen, but reported "**BUGBUG** Unformatted screen is blank", when in fact it was NOT Unformatted.Text but was Field, which is valid in some cases.
I changed the code so that it checks Field and Unformated.Text seperately and processes them independenly.  Now it works for unformatted screens.

There is also a "Array index out of bounds" exception that can be thrown in some cases.  I put more index bounds checking in.

One thing to watch for is that Render() uses chindex < Unformatted.Text[i].Length as the loop terminator in the unformatted screen processing, but indexes into text[chindex].  The string text is always _CX long but Unformatted.Text[i] can be longer, since "<" is expanded to "&lt;" (XML codes).  I actually replace "&lt;" back to "<" and use text.Length as the chindex loop terminator.  I also moved the padding of text to just before assigning text to mScreenRows[i].  I use text.PadRight(_cx, ' ') instead of the padding loop that was there.

This whole thing (XMLScreen) needs reworking badly.  Render() processes so many buffers and then overwrites them later that it's almost hard to keep up with.  Also, this whole buffer processes could be speeded up if XML was out of the loop in this class.  Buffers to XML to a bunch of buffers, that's a lot of processing for such a small task.

I did several more changes to Render() that I won't go into here.

If anyone is interested in the code, I will be glad to give it to them via emal, with the stipulation that it is under the same LGPL licence and I don't even pretend it will help anyone and I'm not reposonsible for any harm, etc..... you know :)


Clyde
Jan 21, 2009 at 11:53 AM
Hello Clyde,

I will be glad to get your fixes for Render(). Please, let me know if you still have them.

Thanks,
Olga
Jan 21, 2009 at 10:44 PM
Hi Olga,
I have attached the file.............as usual, no warranty or implied use etc................use at your own risk................hope it helps :)
Clyde
----- Original Message -----
From: [email removed]
To: [email removed]
Sent: Wednesday, January 21, 2009 6:53 AM
Subject: Re: Fix for TnXMLScreen.Render() [Open3270:31362]

From: olga_pa

Hello Clyde,

I will be glad to get your fixes for Render(). Please, let me know if you still have them.

Thanks,
Olga
Jan 25, 2009 at 1:07 PM
Hello Clyde,
Unfortunately, the attachments are removed by codeplex server when you reply to the post. Could you, please, share the source via some alternative location (gist.github.com, or similar)
Thank you!
Olga
Jan 25, 2009 at 6:33 PM
Olga,
Do you have an email address or an ftp site I can send it to? (I don't want to sign up for something else just to send one source file).
Clyde
----- Original Message -----
From: [email removed]
To: [email removed]
Sent: Sunday, January 25, 2009 8:07 AM
Subject: Re: Fix for TnXMLScreen.Render() [Open3270:31362]

From: olga_pa

Hello Clyde,
Unfortunately, the attachments are removed by codeplex server when you reply to the post. Could you, please, share the source via some alternative location (gist.github.com, or similar)
Thank you!
Olga
Coordinator
Jan 26, 2009 at 11:03 AM
Olga, if you don't mind waiting a while, I'm currently busy consolidating all the fixes that are floating around.

Once Clyde, and the others, send me these, I will upload the new version.

regards,
Francois
Jan 26, 2009 at 11:12 AM
Edited Jan 26, 2009 at 11:25 AM

Hi Clyde,

I sent you a message with email :)

Thanks!


Jan 26, 2009 at 11:16 AM
Hi Francois,

I have to make it work, and without the fixes the library didn't work for me.
I took the fixes that appear here in the discussions and managed to work with the library after that.
I will replace this code with yours as soon as you publish the new version.

Thanks,
Olga

Coordinator
Jan 26, 2009 at 11:20 AM
Ok.

Note that by posting your email address on a public online forum, you're opening yourself to a lot of spammers.  You should've sent your email address in a private message to Clyde.  You can still delete your comment if you wish.

F
Jan 26, 2009 at 11:26 AM
Thank you Francois! I deleted the email and sent a private message
Apr 10, 2009 at 4:38 PM
Hi I would like to have your modified code. I think it could help me with my project.
Apr 13, 2009 at 7:46 AM
Saugortgarcia,
Sorry it took me so long to reply, I had a busy weekend.
I think that the attached file is correct. I pulled it from my version that I'm currently using in production.
Igitur is supposed to have a version of the code with a merge of all the changes I have made and others. I have not seen the merged code yet.
Let me know if this helps you, if not then perhaps I can help in some other way.
Clyde
----- Original Message -----
From: [email removed]
To: [email removed]
Sent: Friday, April 10, 2009 11:38 AM
Subject: Re: Fix for TnXMLScreen.Render() [Open3270:31362]

From: saugortgarcia

Hi I would like to have your modified code. I think it could help me with my project.
Coordinator
Apr 13, 2009 at 8:24 AM
Hi guys,

Sorry that I've been taking so long with this. I'm writing actuarial exams in a weeks' time, but after that I promise I'll consolidate all the fixes.  At the moment I'm just studying 24/7.

Francois
Coordinator
Jun 23, 2009 at 12:22 PM

I have consolidated all the fixes and feedback in the source code.  Feel free to download the latest version of the source code.

Please give me feedback, especially if I created more bugs!

regards,
Francois

Jul 10, 2009 at 3:00 PM

@ignitur:

My test of the latest version of the source code fails:

TnXMLScreen.cs

Line 471: string tens = " ", singles= " "; // the quoted strings must be 3 spaces each, it gets lost in translation by codeplex...

must be

<font size="2" color="#0000ff"><font size="2" color="#0000ff">

string

</font></font><font size="2" color="#0000ff">

 

</font>

tens = "   ", singles= "  "; // the quoted strings must be 3 spaces each, it gets lost in translation by codeplex...

 

 

Coordinator
Jul 10, 2009 at 3:16 PM

If you replace that line with

string tens = new String(' ', 3);
string singles = new String(' ', 3);

Does it solve the problem then?

Jul 11, 2009 at 7:03 PM

Yes, this fixes my runtime-error problem. Another problem seems very strange to me. With the previous version the connect to our Hostsystem returns the screen I expected a everything works fine. The new version of the library return a different screen I never seen before on our Host. Have you change anything regarding to the connect procedure?

Dec 10, 2009 at 9:24 PM

I have a few screens that present <1> and <2> to represent data.  In actions.cs, the method encodeXML(string data) first converts < to &lt; and then it converts & to &amp;

The problem this caused for me was that my GetScreenAsXML.Dump() was returning the text on the screen as lt;1>

Basically, it was replacing the &lt; to be like this &amp;lt;

When the code tries to change it back, it doesn't properly recognize that the &amp; should go back to &, thus leaving &lt; 

Instead, it left only lt;

I swapped the two lines in encodeXML such that it handles the '&' charcater replacement prior to handling the '<' character replacement

Not sure if anyone else has had this issue.  Funny thing is, before I updated my project, I had none of these problems.  I had found the bug that put you in an endless loop, but everything else was working just fine for over a year now.  Ah well, such is progress.  Thanks to all who have been committing code.