J
Jesse B.
I am trying to write a basic script to implement "silent comments"
In the example anything from "input.txt" that is enclosed between "--/"
and "/--" will not be output to "output.text" It appears that the
problem I am having is that the opening string is indexed from beginning
of file, whereas the closing string is indexed from beginning of line.
So I would like to figure out why.
Also when using Ruby1.9 there is an error message about using "each"
with a string that I need to find a workaround to.
any help is greatly appreciated. thanks in advance.
here is the code:
infile = IO.readlines('input.txt','').to_s
outfile = File.new("output.txt", "w")
begins = "--/"
ends = "/--"
start_ss = infile.index(begins)
end_ss = infile.index(ends)
infile[start_ss, end_ss] = ""
infile.each {
|i|
outfile.write i
}
puts start_ss
puts end_ss
outfile.close()
In the example anything from "input.txt" that is enclosed between "--/"
and "/--" will not be output to "output.text" It appears that the
problem I am having is that the opening string is indexed from beginning
of file, whereas the closing string is indexed from beginning of line.
So I would like to figure out why.
Also when using Ruby1.9 there is an error message about using "each"
with a string that I need to find a workaround to.
any help is greatly appreciated. thanks in advance.
here is the code:
infile = IO.readlines('input.txt','').to_s
outfile = File.new("output.txt", "w")
begins = "--/"
ends = "/--"
start_ss = infile.index(begins)
end_ss = infile.index(ends)
infile[start_ss, end_ss] = ""
infile.each {
|i|
outfile.write i
}
puts start_ss
puts end_ss
outfile.close()