From owner-freebsd-questions@FreeBSD.ORG Mon Feb 21 01:26:16 2011 Return-Path: Delivered-To: freebsd-questions@FreeBSD.ORG Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5B054106566C for ; Mon, 21 Feb 2011 01:26:16 +0000 (UTC) (envelope-from sterling@camdensoftware.com) Received: from wh2.interactivevillages.com (wh2.interactivevillages.com [75.125.250.34]) by mx1.freebsd.org (Postfix) with ESMTP id 2041D8FC21 for ; Mon, 21 Feb 2011 01:26:15 +0000 (UTC) Received: from c-24-22-230-24.hsd1.wa.comcast.net ([24.22.230.24] helo=_HOSTNAME_) by wh2.interactivevillages.com with esmtpsa (TLSv1:AES256-SHA:256) (Exim 4.69) (envelope-from ) id 1PrKXR-0007bA-CB for freebsd-questions@FreeBSD.ORG; Sun, 20 Feb 2011 17:26:10 -0800 Received: by _HOSTNAME_ (sSMTP sendmail emulation); Sun, 20 Feb 2011 17:26:11 -0800 Date: Sun, 20 Feb 2011 17:26:11 -0800 From: Chip Camden To: FreeBSD Mailing List Message-ID: <20110221012610.GC2220@libertas.local.camdensoftware.com> Mail-Followup-To: FreeBSD Mailing List References: <20110221011755.GA16912@thought.org> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="kVXhAStRUZ/+rrGn" Content-Disposition: inline In-Reply-To: <20110221011755.GA16912@thought.org> User-Agent: Mutt/1.4.2.3i Company: Camden Software Consulting URL: http://camdensoftware.com X-PGP-Key: http://pgp.mit.edu:11371/pks/lookup?search=0xD6DBAF91 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - wh2.interactivevillages.com X-AntiAbuse: Original Domain - freebsd.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - camdensoftware.com Cc: Subject: Re: revised pager..... X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 21 Feb 2011 01:26:16 -0000 --kVXhAStRUZ/+rrGn Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Quoth Gary Kline on Sunday, 20 February 2011: > THis is to the entire list, mostly to Chip. It is o8.rb, my=20 > very slightly tweaked version of what you ma/// rather, what i > found and began messing with a couple, three hours ago. >=20 > I searched++ and could not find the C equivalent of > "if counter % N =3D=3D 0" in ruby. For some reason, use of parens > in ruby seems to be discouraged. Anyway, I would have coded that > ruby line as=20 >=20 > if ( counter % 15) =3D=3D 0 >=20 > but didn't want to risk it since i don't know ruby. >=20 > Anyway, o8.rb included. This version, using the "[][][][][]" to > emulate a bar, makes reading a reasonably-sized bunch of text > much easier. >=20 > Thanks again for your help. =20 >=20 > --=20 > Gary Kline kline@thought.org http://www.thought.org Public Service Un= ix >=20 Try this version instead. There's no need to find the % 15, we're already paging on the specified number. #!/usr/bin/env ruby require 'optparse' def banner print "\n[][][][][][][][][][][][][][][][][][][][]\n\n" end pagesize =3D 15 optparse =3D OptionParser.new do |opts| opts.banner =3D 'usage: npg [-n pagesize] file...' opts.on('-n', '--numlines pagesize', 'Specify page size in number of line= s') do |n| pagesize =3D n.to_i end end begin optparse.parse! rescue OptionParser::InvalidOption, OptionParser::MissingArgument =3D> e puts e puts optparse exit 1 end banner loop do pagesize.times do if line =3D gets puts line else banner exit end end banner print "More..." system "stty raw" STDIN.getc system "stty -raw" banner end --=20 Sterling (Chip) Camden | sterling@camdensoftware.com | 2048D/3A978E4F http://chipsquips.com | http://camdensoftware.com | http://chipstips.com --kVXhAStRUZ/+rrGn Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (FreeBSD) iQEcBAEBAgAGBQJNYb8yAAoJEIpckszW26+ROigH/2HXwm/KqHhSxLb11u8Lz4nZ 1lSfZAEhxnvWAsuDQgi6w0VDDq7+kX8J2fedIOTKippIL4wsIGj8ALVAZv2BF/rv PQzonva9zvrCztfLZ+IEzb5WHk+eqwet9XETuefQg5MKZgo4RMiVmwLWEKo9CHHh 9svgMo8E4+okqJDDarfhLuxmeVeUGA5jY4DklHuswdv2fL8R4KBHk7qGZLURZU/x kAZeOy1Fbuf9uFDNU9LuLQgPiJ0uv3ZmiUG4US0OlptLFi0O8n1LuZSgasghuxe7 XwSutDqLoc5eAWs/OLzdEN39rrclMqpd/7nLHotnJ0QAH0qEhKDL7dE/xdHj1p4= =/efy -----END PGP SIGNATURE----- --kVXhAStRUZ/+rrGn--