I have a file.After importing i want to read this.I want if the first character in a line of the file is semicolon then it should read the next line.
Is there any procedure to do that.
What does the file look like? You might be able to use lineread() which uses the SKILL parser to read the file - and if it contains blank lines or SKILL-like comments, it will return t rather than the contents of the line...
In reply to Andrew Beckett:
In reply to Rojalin:
I've no idea what ".sexp" file is, but if you had a file that looked like this (say):
; some commentsa b c; some more comments; and some more/* and evensomeC-like comments */1 2 3 ; ignore this bit at the end of the line
you could do:
port=infile("myfile")when(port while(data=lineread(port) unless(data==t printf("elements on the line were: %L\n" data) ) ))close(port)
It will then output:
elements on the line were: (a b c)elements on the line were: (1 2 3)
You should read the documentatin on lineread. This won't work if it's not in SKILL-like syntax. If you want to general line-by-line reading and returning a string, you could do:port=infile("myfile")when(port while(gets(line port) unless(substring(line 1 1)==";" printf("The line that was read was: %s" line) ) ) close(port))
Then this outputs:
The line that was read was: a b cThe line that was read was: /* and evenThe line that was read was: someThe line that was read was: C-like comments */The line that was read was: 1 2 3 ; ignore this bit at the end of the line
Note that gets() will include the carriage return in the string that was read.
So your mileage may vary - you can do whatever you want, but you'll just need to code it appropriately. You could also use the rex.* functions or pcre.* functions (in IC61X for pcre) to use pattern matching if that's easier.