News:

  • July 01, 2026, 08:47:34 PM

Login with username, password and session length

Author Topic: STRPRINT or EMAIL formatting oddly  (Read 30292 times)

Controls Guy

  • Internal Dev
  • Hero Member
  • ****
  • Posts: 3619
  • Darth Ladder
STRPRINT or EMAIL formatting oddly
« on: March 19, 2015, 07:07:21 PM »
I have the following in a FOR loop, building a table to email.

It works in general, but some lines seem to have extraneous carriage returns for some bizarre reason, as shown in the second screenshot, even though all the  lines are built by the same STRPRINT box.   ???

Any ideas?
I retract my earlier statement that half of all politicians are crooks.  Half of all politicians are NOT crooks.  There.

Controls Guy

  • Internal Dev
  • Hero Member
  • ****
  • Posts: 3619
  • Darth Ladder
Re: STRPRINT or EMAIL formatting oddly
« Reply #1 on: March 19, 2015, 07:08:47 PM »
It would also be nice if one of the Fmtxxx() functions had a mode for implied decimal.  That would have been useful here for example.
I retract my earlier statement that half of all politicians are crooks.  Half of all politicians are NOT crooks.  There.

plcnut

  • Hero Member
  • *****
  • Posts: 814
    • premiersi.com
Re: STRPRINT or EMAIL formatting oddly
« Reply #2 on: March 19, 2015, 07:27:40 PM »
It would 'appear' to be a text wrap issue. Have you tried to view the data in a dataview that is set to view as Hex? This way you could confirm their is an actual CRLF.
Circumstances don't determine who we are, they only reveal it.

~Jason Wolthuis
Premier Systems Integration, LLC
http://premiersi.com

Controls Guy

  • Internal Dev
  • Hero Member
  • ****
  • Posts: 3619
  • Darth Ladder
Re: STRPRINT or EMAIL formatting oddly
« Reply #3 on: March 19, 2015, 07:43:47 PM »
Well, it would seem to be, but the only place I'm putting one in, is at the very end.  There might be one embedded in the string value, but the extraneous break isn't in the part of the line that comes from the string value.  ?????
I retract my earlier statement that half of all politicians are crooks.  Half of all politicians are NOT crooks.  There.

ADC Product Engineer

  • Hero Member
  • *****
  • Posts: 270
Re: STRPRINT or EMAIL formatting oddly
« Reply #4 on: March 19, 2015, 07:48:49 PM »
IIRC, it has something to do with not having a proper termination in the string (<CR><LF>).  The buffer fills and then at 72 characters (I think) it forces the <CR> <LF>.

This is from memory, so Franji1 or BobO may come in and correct me as to the particulars on it.
« Last Edit: March 19, 2015, 07:50:25 PM by ADC Product Engineer »

Controls Guy

  • Internal Dev
  • Hero Member
  • ****
  • Posts: 3619
  • Darth Ladder
Re: STRPRINT or EMAIL formatting oddly
« Reply #5 on: March 20, 2015, 12:07:22 AM »
Well then, I'm really confused, because there WAS an 0D0A at the end of the previous line (hence the carriage return) way less than 72 characters previous, plus all the other lines make it farther than the broken ones do, with no problem.  Guess I have to look at the actual hex contents of Report0.
I retract my earlier statement that half of all politicians are crooks.  Half of all politicians are NOT crooks.  There.

ADC Product Engineer

  • Hero Member
  • *****
  • Posts: 270
Re: STRPRINT or EMAIL formatting oddly
« Reply #6 on: March 20, 2015, 08:46:32 AM »
As a follow up, I was mostly correct in my previous post.  (It only took me a half hour of email digging to find the relevant information.)

If you are sending email, SMTP servers require a 0D0A every 80 characters or one will be forced into the string.

Controls Guy

  • Internal Dev
  • Hero Member
  • ****
  • Posts: 3619
  • Darth Ladder
Re: STRPRINT or EMAIL formatting oddly
« Reply #7 on: March 20, 2015, 01:19:43 PM »
OK, I'm getting confuseder by the minute.   :o

ADC PE, you seem to be almost right.  The prebuilt string does have CRLF's where expected, about every 39 characters or so, according to a Data View in DMD.  I checked and the first extra CR in the email is indeed exactly 80 characters from the beginning of the message (though the second one is 180 chars after??), so you'd think maybe the EMAIL box is failing to send them and SMTP server is inserting an extra......BUT, it's only the 80th character IF YOU COUNT the <CR>'s and <LF>'s that are supposed to be there, plus the previous lines break where intended!  So I know the server's getting the intended 0D0A's, so that hypothesis doesn't work.

So then I thought maybe it's a bug in that specific SMTP server (inbox.com), so I tried another email server (vfemail.net), and the received email had extra breaks in exactly the same positions.  Can't be a bug in TWO servers, can it?

So then I thought maybe it's in my email client (Thunderbird), and it's just rendering that way on screen, but I looked at the message on the server using Cox's webmail client, and the extraneous breaks are already in by that point.

At this point, don't know what to do, other than put the mirroring switch on and verify what Do-More's sending, byte by byte.

Thoughts?
« Last Edit: March 20, 2015, 01:22:22 PM by Controls Guy »
I retract my earlier statement that half of all politicians are crooks.  Half of all politicians are NOT crooks.  There.

Controls Guy

  • Internal Dev
  • Hero Member
  • ****
  • Posts: 3619
  • Darth Ladder
Re: STRPRINT or EMAIL formatting oddly
« Reply #8 on: March 20, 2015, 07:37:04 PM »
BobO figured this out for me.  My MHR strings had ASCII NULLs (0x00's) in them, which broke the character counter, so if I replace the NULLs with spaces, all should be good.

Thanks, BobO!   :)
I retract my earlier statement that half of all politicians are crooks.  Half of all politicians are NOT crooks.  There.

ADC Product Engineer

  • Hero Member
  • *****
  • Posts: 270
Re: STRPRINT or EMAIL formatting oddly
« Reply #9 on: March 20, 2015, 10:41:04 PM »
Do-more is the culprit.  It is strictly adhering to the SMTP spec which states that every 80 characters, there must be a CR/LF.

Good to know about the null's.  I hadn't thought of that, but it makes sense.

Controls Guy

  • Internal Dev
  • Hero Member
  • ****
  • Posts: 3619
  • Darth Ladder
Re: STRPRINT or EMAIL formatting oddly
« Reply #10 on: March 20, 2015, 11:12:00 PM »
Well, it really had nothing to do with CRLF frequency, or only indirectly.  There were plenty of CRLF's present that no additional ones were needed.  The central issue is that NULL's break the character counting, and that can be worked around.
I retract my earlier statement that half of all politicians are crooks.  Half of all politicians are NOT crooks.  There.

BobO

  • Host Moderator
  • Hero Member
  • *****
  • Posts: 6164
  • Yes Pinky, Do-more will control the world!
Re: STRPRINT or EMAIL formatting oddly
« Reply #11 on: March 22, 2015, 10:32:45 AM »
The line break code uses standard C string handling to look for CR/LF. It hits a NULL and concludes that there is none, then grabs 78 characters, looks for white space at the end, adds CR/LF, and spits out the line...which now has 2 line breaks and a bunch of illegal NULLs.

Do-more could be a bit more graceful about it, but the NULLs are not permitted in the email. I will look at adding some warnings...and maybe converting illegal characters to something else.
"It has recently come to our attention that users spend 95% of their time using 5% of the available features. That might be relevant." -BobO

Controls Guy

  • Internal Dev
  • Hero Member
  • ****
  • Posts: 3619
  • Darth Ladder
Re: STRPRINT or EMAIL formatting oddly
« Reply #12 on: March 22, 2015, 11:12:21 PM »
For me at least, either or both of those (run time warning or replacement) would be fine.  If you do real-time replacement, you probably want to announce it somehow, or else someday, somehow, the replacement will bite someone in some mystifying way that's hard to diagnose.

Thank you again for figuring out what was going on here.  It really had me baffled.  :)
I retract my earlier statement that half of all politicians are crooks.  Half of all politicians are NOT crooks.  There.

BobO

  • Host Moderator
  • Hero Member
  • *****
  • Posts: 6164
  • Yes Pinky, Do-more will control the world!
Re: STRPRINT or EMAIL formatting oddly
« Reply #13 on: March 23, 2015, 08:31:33 PM »
For me at least, either or both of those (run time warning or replacement) would be fine.  If you do real-time replacement, you probably want to announce it somehow, or else someday, somehow, the replacement will bite someone in some mystifying way that's hard to diagnose.

Thank you again for figuring out what was going on here.  It really had me baffled.  :)

If we did replace, we would certainly warn also. I am inclined to just warn.
"It has recently come to our attention that users spend 95% of their time using 5% of the available features. That might be relevant." -BobO

Controls Guy

  • Internal Dev
  • Hero Member
  • ****
  • Posts: 3619
  • Darth Ladder
Re: STRPRINT or EMAIL formatting oddly
« Reply #14 on: March 24, 2015, 02:01:03 AM »
I think just warning would be fine.
I retract my earlier statement that half of all politicians are crooks.  Half of all politicians are NOT crooks.  There.