Jump to content
Developer Wiki and Function Reference Links ×

EOLN


Juno

Recommended Posts

If you can be sure that each line contains the same number of fields, you can just do:

ReadLn(fieldOne, fieldTwo, fieldThree);

and all three variables will get assigned in one shot. Note that PASCAL requires that each field be non-nil for this to work. So if the data actually look like this:

something-tab-tab-something

you'll have problems. One way to solve this problem, if you're writing the file, is simply to make sure that you don't write any non-nil fields (come up with something that to you denotes an empty field, and write that instead of a nil string).

In situations where the number of fields can vary, I usually just use StdReadLn, which reads the whole line into one variable. Then I parse the variable, looking for the delimiters myself. It's a pain, but it's reliable.

Link to comment

Unfortunately, the lines can have a variable number of entries. The StdReadLn is a possible solution but you are right, it is a pain.

EOLN seemed like a simple answer but it doesn't work the way I expected it to, unlike EOF.

Thanks for the suggestions,

-juno

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...