-1

I know how to write and read files in NASM 16-bit but is there a way to either move the file pointer to read a single line? Or at least split the lines in different strings? It's for a game that has a config file and a string list.

If you don't like my question, I'm just a beginner with files.

Stephan
  • 53,940
  • 10
  • 58
  • 91
  • 1
    please show what you've tried – phuclv Jun 12 '21 at 01:41
  • Assuming the operating system is DOS, and tagging accordingly. If not, please say. – Nate Eldredge Jun 12 '21 at 02:11
  • `for /?` tells you to double the percent-sign for the `for` metavariables: `for %%I in (%1) do set FileType=%%~xI`. also, they are case sensitive `%%i` is not `%%I`. – Stephan Dec 03 '21 at 22:12
  • 2
    Don't change your question into something completely different when it invalidates already given answers. Ask a new question instead. – Stephan Dec 03 '21 at 22:16

1 Answers1

2

I don't think so. You're expected to read the file in chunks with INT 21h / AH=3Fh and parse it into lines yourself. Likewise, the only way to seek is AH=42h which takes a byte count, not a line count.

The OS does not keep any record of where the line breaks are in the file, so the only way to actually seek to a particular line would be to read through the entire file until the appropriate number of CRLFs have been seen. And that's something the application can do for itself, so there's no particular need to provide a separate system call for it.

Nate Eldredge
  • 48,811
  • 6
  • 54
  • 82
  • Fun fact: some OSes *did* keep track of stuff like lines (or "records") within files; for example VMS files were *not* just flat arrays of bytes. (Or so I've read; I've seen a VAX desktop running VMS in person, but never used or programmed one. https://en.wikipedia.org/wiki/Files-11#Record-oriented_I/O:_Record_Management_Services). So if you were using NASM on OpenVMS maybe? But that wouldn't be 16-bit. – Peter Cordes Jun 12 '21 at 14:07