I’m working on a CGI script that iterates through a list of items of a
class I’ve defined (class Report). Report::to_s just returns the string
“yay!” for testing purposes.
As you can see, the “yay!” is supposed to appear surrounded by li tags,
but it never does.
I have absolutely no idea why I’d need the exception handling code given
my data set, but between each iteration, an exception is raised (can’t
convert nil in to String). It is saying “yay!” for each report in the
data set, and I can verify this by making Report::to_s say something
more identifying.
So I’m trying to unravel two mysteries:
Why aren’t the "yay!"s surrounded by li tags?
Why are exceptions being raised between each iteration, yet each item
in the data set being iterated through passes through without exception?
I realize this probably isn’t enough code to discern all the
peculiarities, but I’m just not sure what other parts would be useful.
Sorry in advance!
yay!
yay!
but it never does.
2) Why are exceptions being raised between each iteration, yet each item
in the data set being iterated through passes through without exception?
I realize this probably isn’t enough code to discern all the
peculiarities, but I’m just not sure what other parts would be useful.
Sorry in advance!
probably you’ve defined ‘to_s’ as
class Report
def to_s
puts …
end
end
instead of
class Report
def to_s
‘some string’
end
end
which is outputing something, returning nil, and causing the error to be
thrown. this should be very easiy to debug: just take out your
exception
handling code and run from the command line using
In general, the CGI library will spit out exactly what you give it.
There’s even a ‘pretty’ option so it will properly indent everything and
make it easy to read, although I’ve found this can cause problems with
textareas (extra whitespace).
Thanks! I’ve learned that having a one-line string for a method will
return that string.
CGI might be good under Ruby, but I’m definitely in the habit of writing
my own HTML just because a lot of other languages’ modules generate some
ugly HTML. I’ve got another project that’s just starting out. If Ruby’s
CGI is prettier, I might go that way. I do know that I like its
block-code styling.
My guess is that your to_s method does
puts “yay!” and raises an exception, instead of just returning yay! (def to_s;
“yay!”
end)
Could you show us the definition of to_s ?
Regards,
Sylvain
Hi all-
I need to automate a few function in an Access form. The form will
already be opened, (basically I need to push a button and fill out a few
things in the window that opens, then close the newly opened form and
click OK on the dialog box that pops up). So first, basically I need to
attach to the opened Access form, an then if anyone has any clues on
finding ole commands to do that other things that would be great.
To add to James’ good suggestions, I’d suggest finding an OLE browser.
I know VB6 has one, and so should other M$ dev tools if you have
access to them.
If you don’t have access to those, ActiveState has a spiffy little OLE
browser included with it’s free Perl binaries.
Hi all-
I need to automate a few function in an Access form. The form will
already be opened, (basically I need to push a button and fill out a few
things in the window that opens, then close the newly opened form and
click OK on the dialog box that pops up). So first, basically I need to
attach to the opened Access form, an then if anyone has any clues on
finding ole commands to do that other things that would be great.
Look at AutoItX (free software to script mouse clicks and keyboard
entries). It’s scriptable with Ruby + Win32OLE
–
James B.
“The greatest obstacle to discovery is not ignorance, but the illusion
of knowledge.”
D. Boorstin
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.