From: Paul Rubel Date: 2002-08-01T22:22:01+09:00 Subject: Re: How to make a virtual 2nd column!!! Hi Kurt, Kurt Euler wrote: > Here's a record formatting question for you: You might want to look into FormatR ;) http://www.crhc.uiuc.edu/~rubel/FormatR/ > Say I have a record like in this format... > nnnnnThis is a sample sentence meant to demonstrate desired word wrapping to make the appearance of a virtual column from a single long string that doesn't have any hard returns. > .. and I want to format it to look something like this: > nnnnn This is a sample sentence meant to > demonstrate desired word wrapping > to make the appearance of a virtual > column from a single long string > that doesn't have any hard returns. > where: > - nnnnn is a 5 character string. > - is a tab character (to be replaced by three spaces). > - The first space after every 35 or so characters in the sentence (2nd field of the record) is replaced by a hard return plus eight spaces. > - The sample above is one of many records in a file, separated by a hard return. > Thanks again, friends! > -Kurt I have two examples below, one pulls out the number and the other doesn't. They both give the same output. Watch out because they will modify line, you may need a copy if you'll want the contents later. Enjoy, Paul #!/usr/bin/env ruby require "format.rb" include FormatR #Have the number by itself template1 = < ./rt.rb template 1 12345 This is a sample sentence meant to demonstrate desired word wrapping to make the appearance of a virtual column from a single long string that doesn't have any hard returns. template 2 12345 This is a sample sentence meant to demonstrate desired word wrapping to make the appearance of a virtual column from a single long string that doesn't have any hard returns.