Guidance Forums / Reginald Rexx / Bug in CHARIN

Search 搜索
Home Home

Forum List • Thread List • Refresh • New Topic • Search • Previous • Next First 1 Last
Message1. Bug in CHARIN
Posted by: Michael S 2012-06-02 19:52:21
I think I've discovered a bug in CHARIN.

I've attached a file that can be used together with the test script. Basically, it seems that if you've read x bytes from a file and then try and reset the pointer back to byte 1, the next read always starts reading from byte 2. If you try and set the pointer to 0 then charin complains. Try the following script using the attached file.
Posted by: Jeff Glatt 2012-06-06 07:37:51
Not a bug. You're not using CHARIN correctly. Here's the docs for the third arg

length indicates the requested number of characters to read in. If 0, then CHARIN() merely sets the "read character position" to position without reading any characters and returns an empty string. (ie, Similiar to using STREAM's SEEK). If length is omitted, CHARIN() defaults to reading only 1 character.

So your line...
temp = CHARIN(ansi_filein, 1)

... sets the position to 1 and then also reads the first char. Obviously, the next CHARIN will start at the second char (unless you supply another position). Try...
temp = CHARIN(ansi_filein, 1, 0)
Message3. Ahaaaaa !
Posted by: Michael S 2012-06-12 03:03:21
Thanks Jeff - will test at work tomorrow
Forum List • Thread List • Refresh • New Topic • Search • Previous • Next First 1 Last
© Tue 2024-7-23  Guidance Laboratory Inc. Hits:0