sterling at camdensoftware.com
Mon Feb 21 01:26:16 UTC 2011
Quoth Gary Kline on Sunday, 20 February 2011:
> THis is to the entire list, mostly to Chip. It is o8.rb, my
> very slightly tweaked version of what you ma/// rather, what i
> found and began messing with a couple, three hours ago.
> I searched++ and could not find the C equivalent of
> "if counter % N == 0" in ruby. For some reason, use of parens
> in ruby seems to be discouraged. Anyway, I would have coded that
> ruby line as
> if ( counter % 15) == 0
> but didn't want to risk it since i don't know ruby.
> Anyway, o8.rb included. This version, using the "" to
> emulate a bar, makes reading a reasonably-sized bunch of text
> much easier.
> Thanks again for your help.
> Gary Kline kline at thought.org http://www.thought.org Public Service Unix
Try this version instead. There's no need to find the % 15, we're
already paging on the specified number.
pagesize = 15
optparse = OptionParser.new do |opts|
opts.banner = 'usage: npg [-n pagesize] file...'
opts.on('-n', '--numlines pagesize', 'Specify page size in number of lines') do |n|
pagesize = n.to_i
rescue OptionParser::InvalidOption, OptionParser::MissingArgument => e
if line = gets
system "stty raw"
system "stty -raw"
Sterling (Chip) Camden | sterling at camdensoftware.com | 2048D/3A978E4F
http://chipsquips.com | http://camdensoftware.com | http://chipstips.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Size: 488 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-questions/attachments/20110221/a6e16e17/attachment.pgp
More information about the freebsd-questions