T
Tom Cloyd
I know this is a simple problem - to 'most everyone but me, but I cannot
see why I'm getting this error. I've explored things with ruby-debug,
and with irb inside of the debugger, and I simply cannot replicate the
error.
The code (this most of a little routine for converting an HTML file to a
textile marked up file):
# input
filein = open( "{whatever}" )
fi = filein.readlines
# output
fileout = open( "_textile.txt", 'w')
delta = [
["</p>", ''],
["</h1>", '']] # for brevity, I've truncated this array - you get
the idea, I assume
ld = delta.length
i = 0
until i > ld
#results = fi[0].gsub( delta[0], delta[1] ) <= in an attempt
isolate error, I broke this into the following:
s1 = delta[0] # <= exception is thrown here
s2 = delta[1]
results = fi[0].gsub( s1, s2 )
i += 1
end
The error msg:
$ ruby textilemkr.rb
textilemkr.rb:55:in `main': undefined method `[]' for nil:NilClass
(NoMethodError)
from textilemkr.rb:66
I've confirmed that delta[1][0] is valid, that "i" is 0 when error
occurs, etc.
If it works in irb, why doesn't it work when I run the routine via the
interpreter? What obvious thing am I missing?
All help will be gratefully accepted.
Tom
--
see why I'm getting this error. I've explored things with ruby-debug,
and with irb inside of the debugger, and I simply cannot replicate the
error.
The code (this most of a little routine for converting an HTML file to a
textile marked up file):
# input
filein = open( "{whatever}" )
fi = filein.readlines
# output
fileout = open( "_textile.txt", 'w')
delta = [
["</p>", ''],
["</h1>", '']] # for brevity, I've truncated this array - you get
the idea, I assume
ld = delta.length
i = 0
until i > ld
#results = fi[0].gsub( delta[0], delta[1] ) <= in an attempt
isolate error, I broke this into the following:
s1 = delta[0] # <= exception is thrown here
s2 = delta[1]
results = fi[0].gsub( s1, s2 )
i += 1
end
The error msg:
$ ruby textilemkr.rb
textilemkr.rb:55:in `main': undefined method `[]' for nil:NilClass
(NoMethodError)
from textilemkr.rb:66
I've confirmed that delta[1][0] is valid, that "i" is 0 when error
occurs, etc.
If it works in irb, why doesn't it work when I run the routine via the
interpreter? What obvious thing am I missing?
All help will be gratefully accepted.
Tom
--