So... has anyone been able to get "krl_fgets" to work, reading strings from text files? At the moment, I'm stumped.
(it doesn't help that the manual is blatantly incorrect in several places, either...)
So, I've tried multiple different things. My original text file lacked any special separator, and I kept getting an error that my buffer string (chFileLine[]) had an invalid character 'H0D'. The original version of my text file was DOS-style, with Carriage Return ('H0D') and Line Feed ('H0A') terminating each line. Since the krl_fgets is based on the classic Unix fgets, I took this to mean that the CR was causing my troubles, and I changed my text file to Unix-type line termination, with only LF at the end of each line.
But, I still kept getting the invalid-character errors. So I added the ';' characters as separators, and changed my Separator value to match the ASCII value of ';'. Still no dice.
Then, I tried doing away with the separator and line-end characters entirely -- I reformatted the entire ASCII file so that each line would be identical length (using leading 0s), and set the character limit to end one character before the fgets would reach either the ';' or the LF. The "invalid character" message changed to complaining that the invalid character was 'H00' (or 0x0, but that's the same thing).
Still no good.
So then, I tried changing the character limit to 10, which is much smaller than the line length. And I still get the "Invalid character 0x0" message, but the message says that the location of the invalid character is chFileLine[10]. Then I tried changing the limit value, and basically found that whatever I set the character limit to, I will get an "invalid character 0x0" error for that character in the chFileLine string.
Along the way, I also tried things like clearing the chFileLine string, not clearing it, deliberately setting it in advance to various ASCII strings... I can definitely say that there are no Null (0x0) characters in that string when that message comes up, and the CWRITE is emphatically not making any changes to the string (which I've tried as both a static and runtime variable).
At the moment, I'm just... stumped. The file is definitely opening successfully (I have a separate subroutine for that) and I'm getting a good handle for it (and the Close works properly on that handle), and I've had lots of success opening text files and writing to them. The text file is located in /KRC/ROBOTER/USERFILES, just as it should be. I'm not even getting to the SWRITE parsing yet. I simply cannot figure out what this thing is complaining about.
As for errors in the manual:
1. The Separator argument is listed as being "optional" -- it's not. Leaving it off generates a STATE.MSG_NO of -10 (incorrect number of arguments passed) without fail
2. The Separator argument is shown as being type CHAR. It's not. Unless it's declared as INT (and it must be a variable, not an explicit value), MSG_NO -12 results (wrong data type). And my best guess is that it has to be set to the ASCII value of the separator character, but there's no way to be certain as yet.
3. Maybe not an error? No mention is made of how fgets handles Unix line terminators vs DOS line terminators. My original suspicion was that the DOS-type terminators were causing issues, but I can't test that theory yet.