Just a little help with file reading...

Just starting out? Need help? Post your questions and find answers here.
User avatar
FragSax
New User
New User
Posts: 9
Joined: Tue May 24, 2011 11:58 pm

Just a little help with file reading...

Post by FragSax »

I'm working on the simplest possible scripting language and all I really want to know is how I could implement comments? In my head comments start with a '#' and I just want PureBasic's File function to ignore that line... How would I go about doing something like this?
PureBasic 4.51 User
Ramihyn_
Enthusiast
Enthusiast
Posts: 314
Joined: Fri Feb 24, 2006 9:40 am

Re: Just a little help with file reading...

Post by Ramihyn_ »

Line by line parsing of an open text file. Skip execution of empty lines and lines starting with a '#'

Code: Select all

  While (Eof(fileID) = 0)
    Command$    = Trim(ReadString(FileID))
    First$  = Left(Command$, 1)

    If ((First$ <> "") And (First$ <> "#"))


    endif
  Wend
As long as you dont support multiple commands each line.
User avatar
FragSax
New User
New User
Posts: 9
Joined: Tue May 24, 2011 11:58 pm

Re: Just a little help with file reading...

Post by FragSax »

Very much appreciated...
PureBasic 4.51 User
Post Reply