Yesterday, I learned a good lesson to not copy and paste text from a pdf
into the Forth environment. There can be hidden characters when doing
so, and then a word fails because the input isn't correct.
For an hour or so I was chasing down an imaginary bug in the
(non-standard) word NUMBER? used to convert a counted string into a
signed double length number.
Krishna Myneni <krishna.myneni@ccreweb.org> wrote:
Yesterday, I learned a good lesson to not copy and paste text from a pdf
into the Forth environment. There can be hidden characters when doing
so, and then a word fails because the input isn't correct.
I've encountered that problem often enough over many years to
get a feel for it as when action doesn't match logic.
Vim has a ':list' option that will display non-printiables
and for block files just re-write the suspect line. Also
have ADUMP that prints text and displays any non-printable
as '^nn', where nn was the value of the non-printable.
Krishna Myneni wrote:
[..]
For an hour or so I was chasing down an imaginary bug in the
(non-standard) word NUMBER? used to convert a counted string into a
signed double length number.
I know about '-', and single/double quote characters. They are a
nuisance not only in Forth.
Was it something else?
-marcel
On 7/1/24 06:47, mhx wrote:
Krishna Myneni wrote:
[..]
For an hour or so I was chasing down an imaginary bug in the
(non-standard) word NUMBER? used to convert a counted string into a
signed double length number.
I know about '-', and single/double quote characters. They are a
nuisance not only in Forth.
Was it something else?
-marcel
It was a large number containing commas. I deleted the commas.
The text is pasted here:
−170,141,183,460,469,231,731,687,303,715,884,105,728
It appears to have pasted properly, but there is a difference between
Line 1 and Line 2. The latter is entered by hand.
\ Line 1
c" −170141183460469231731687303715884105728" NUMBER? .s
0
0
0
ok
drop 2drop \ Now enter by hand
ok
\ Line 2
c" -170141183460469231731687303715884105728" NUMBER? .s
^−17
No display difference when I used :SET LIST in Vim. But I found the
issue was the difference between a unicode minus sign and an ASCII minus
sign -- see above.
Krishna Myneni <krishna.myneni@ccreweb.org> wrote:
No display difference when I used :SET LIST in Vim. But I found the
issue was the difference between a unicode minus sign and an ASCII minus
sign -- see above.
Hard to believe Vim :SET LIST wouldn't catch that. But I use codepage
KOI8-R so that wouldn't show up for me. I'll have to try Vim on unicode terminal.
But my ADUMP would catch it for sure; it's showing the values Forth sees.
Ok, tried on unicode terminal and the PDF I used had the correct value,
45, for minus after copy to text file that I loaded with Forth.
(Vim ga over the minus also showed 45). Also if I type minus in
Vim on text file and it had the correct value. So your particular
PDF file was the culprit; so yes, all be warned.
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 504 |
Nodes: | 16 (2 / 14) |
Uptime: | 11:11:25 |
Calls: | 9,903 |
Calls today: | 12 |
Files: | 13,797 |
Messages: | 6,343,280 |
Posted today: | 6 |