Android Question CRLF autotextsizelabel

Rusty

Well-Known Member
Licensed User
Longtime User
I have an autotextsizelabel that I am sending multiple lines delineated with a Chr(13) & Chr(10) as a carriage return and line feed.
When I look at the text being loaded it has a CHR(13) and CHR(10) within, but when I do at .contains, it fails.
When I display the ASCII of each character is shows that both the Carriage return and line feed are both Chr(13).
I hereby authorize and consent to examination and treatment as deemed necessary by physicians of A Medical Group, Inc. <---<< this has a chr(13) & chr(10)
I authorize release of information to my insurance carrier should it be necessary. <---<<< same here
The undersigned agrees to pay any costs incurred by this clinic in the event of account delinquency, all amounts due including, but not limited to, reasonable attorney’s fees. <---<<< same here
I hereby assign all medical and/or surgical benefits, including major medical benefits to which I am entitled, including Medicare, private insurance and other health plans to this clinic.<---<<< same here

B4X:
'this code is in the SetText of autotextsizelabel 
Public Sub setText(value As String)
    mLbl.SingleLine = False
    mLbl.Text = value
    Dim multipleLines As Boolean = value.Contains(chr(13) & chr(10))    <---<< this results in FALSE
    multipleLines = value.Contains(Chr(13)) Or value.Contains(Chr(10))  <---<< this results in TRUE
    For i = 0 To value.Length -1
        Log("i = " & Asc( value.SubString2(i, i+1)) & "   " &  value.SubString2(i, i+1)) <---<< see next comment
    Next

...
i = 46 .
i = 32
i = 13 <---<< this is correct
i = 13 <---<< this shows Chr(13) and should be a Chr(10)
i = 73 I
i = 32
i = 97 a
i = 117 u
i = 116 t
i = 104 h
i = 111 o
i = 114 r
...

Since I can't show the chr(13) and chr(10) in this environment, I have captured an image from notepad++. This was copied directly from the B4a IDE the Variable "value as string".
upload_2018-11-12_12-0-41.png


I can't figure out how, when I look at the data it is correct; it fails the contains and when I loop through character by character it is 13 and 13 when I can see it is not.
Any ideas will be greatly appreciated.
Thanks
Rusty
 

Mark Read

Well-Known Member
Licensed User
Longtime User
Have you tried

B4X:
Dim multipleLines As Boolean = value.Contains(CRLF)

according to this post: link
 
Upvote 0

Semen Matusovskiy

Well-Known Member
Licensed User
If you receive a file from Windows or "unknown" OS, replace Chr (13, 10) with CrLf before any other action.
If you send a file to Windows replace CRLF with Chr (13, 10).
 
Upvote 0

Rusty

Well-Known Member
Licensed User
Longtime User
Thanks all...
I use the same files for display on the web, PC and Android. Thus the need for CRLF (as per PC standards) as well as CRLF (as per Android standards).
Mark, I have tried Dim multipleLines As Boolean = value.Contains(CRLF) and because the value of the CHR(10) character is being (somehow) changed to CHR(13), it fails...
I guess the part that is hard to manage is the part where (in debug) I can watch the string and it has both chr(10) and chr(13) (which would work), but when I loop through it and log the values in the VERY NEXT statement(s), they are logged as chr(13) chr(13)...
Not sure how the Chr(10) becomes a 13 with nothing happening between statements...
Thanks,
Rusty
 
Upvote 0

Rusty

Well-Known Member
Licensed User
Longtime User
I made a video of the above stated problem but can't upload it. What file formats are supported for uploaded video into this blog?
I tried an MP4 but it rejects it...
Thanks
 
Upvote 0

Rusty

Well-Known Member
Licensed User
Longtime User
The data comes from an MSSQL table. The below is a view of the data. (I had to type in the locations of the CRLF (Chr(13) chr(10))'s since the blog doesn't recognize them when pasting into the Quote below)

...KEY COLUMNS... I hereby authorize and consent to examination and treatment as deemed necessary by physicians of Medical Group, Inc. CRLF
I authorize release of information to my insurance carrier should it be necessary. CRLF
The undersigned agrees to pay any costs incurred by Medical Group, Inc. in the event of account delinquency, all amounts due including, but not limited to, reasonable attorney’s fees. CRLF
I hereby assign all medical and/or surgical benefits, including major medical benefits to which I am entitled, including Medicare, private insurance and other health plans to Medical Group, Inc. CRLF
This assignment will remain in effect until revoked by me in writing. A photocopy of this agreement is to be considered as valid as the original. CRLF
I further authorize the release of all information necessary to secure payment. I understand and agree that payment by the responsible party will not be delayed or withheld because of any dispute between the responsible party and any insurance company, reimbursing agency, third party payer or because of pending legal claims. CRLF

I read this in from SQL as per above (KEY COLUMNS are not shown to protect client data) into a string variable. (as shown in post #1)
When I send this data to the autotextsizecolumn it DOES HAVE the CRLF characters within as shown in Post #1.
When the .Contains is checked, it fails finding the B4a constant CRLF (Chr(10)) even though it is there several times.
When I then loop through the exact string after the .Contains there are two chr(13) characters and the CHR(10)'s are all converted to Chr(13). (as shown in post #1 log image)
From my perspective, there has been no code that should have changed the Chr(10)'s to Chr(13)'s...

Thanks for the help, I'm baffled...
Rusty


UPDATE: I replaced all CRLF (Windows format 2 chars) with the CRLF Android Chr(10).
I then ran the string through a regex.split and it found only 1, in other words, it didn't find a chr(10). I then tried regex.split on the string with chr(13) and it did find them...
 
Last edited:
Upvote 0
Top