Setting up a variable length format at runtime 
Author Message
 Setting up a variable length format at runtime

Hello,
        I am trying to figure out how to create a variable-length form using
the format command. I would like to take the output of "ls" and arrange
the filenames in a 4-col space on the screen with numbers proceding
each file like:

        1) file1      2) file2     3) file3     4) file4
        5) file5      6) file6     7) file7     8) file8

Each page in the file list will have its own top of page format.

I can set the page length with $= to the number of lines I want to see
at a time but I don't know how many files will be in a given directory.

How can I set up a format that will be evaluated at runtime such that
the list of files I scanned from the output of ls will properly fill
in each new page?

stumped.



Fri, 14 Aug 1998 03:00:00 GMT  
 Setting up a variable length format at runtime

Quote:
>I can set the page length with $= to the number of lines I want to see
>at a time but I don't know how many files will be in a given directory.
>How can I set up a format that will be evaluated at runtime such that
>the list of files I scanned from the output of ls will properly fill
>in each new page?

Are you sure you need a variable length format? If you just want to
force a top of page for each output of ls, set the lines left on page
variable ($-) to zero.

If you need the format to be evaluated at runtime, put it into a
string and eval "" it. The repitition operator x might come in handy
for making the proper number of columns or lines.
--
Andrew Langmead



Sat, 15 Aug 1998 03:00:00 GMT  
 Setting up a variable length format at runtime

:       I am trying to figure out how to create a variable-length form using
: the format command. I would like to take the output of "ls" and arrange
: the filenames in a 4-col space on the screen with numbers proceding
: each file like:

:       1) file1      2) file2     3) file3     4) file4
:       5) file5      6) file6     7) file7     8) file8

: Each page in the file list will have its own top of page format.

: I can set the page length with $= to the number of lines I want to see
: at a time but I don't know how many files will be in a given directory.

: How can I set up a format that will be evaluated at runtime such that
: the list of files I scanned from the output of ls will properly fill
: in each new page?

You don't need to set "up a variable length format at runtime".

You could do something like:

###################################
#!/usr/bin/perl




   $i1 = $i;
   $i2 = $i+1;
   $i3 = $i+2;
   $i4 = $i+3;
   write;
#print "f1: $f1  f2: $f2   f3: $f3   f4: $f4\n";

Quote:
}

format STDOUT=

   $i1, $f1,        $i2, $f2,        $i3, $f3,        $i4, $f4
.

format STDOUT_TOP=

      $%
------------------------------------------------------
.

###################################

--
  Tad McClellan,      Logistics Specialist (IETMs and SGML guy)

  Just be thankful we don't get all the government we pay for!



Sat, 15 Aug 1998 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Variable length Format

2. setting select options at runtime

3. Options cannot be set at runtime using configure method

4. HELP WANTED: runtime error message: VARIABLE ERROR.

5. read variables and values in them at runtime.

6. internal variable-format and unexpected variable-value

7. Using printf to format (padd) fields lengths

8. Problem with setting the Page Length

9. Is runtime variable creation possible?

10. Creating runtime variables.

11. Perl tuning/speed question: all subsets of a set of length k -- keeping the inital order

12. determine the length of a formatted string?

 

 
Powered by phpBB® Forum Software