get fpprintprec to round float inside function?



On June 30, 2011, Ted Woollett wrote:
------------------------
 I would like to use fpprintprec (or is there another
way?)  to round bytes to KB inside a function
folder_info, using code like:
----------------------------------
   folder_info ( path)  :=
       block ( [ fpprintprec : 2, stuff ],
               y:   float(x/1000), etc, etc )
-------------------------------------------------
   So far the simplest method (using
  fpprintprec to do the dirty work) which leaves the
 global value of fpprintprec unchanged, is to divide
the function into two functions:
------------------------------------------------
folder_info1 (fp) :=
     block ([v, aL, rL:[],fiL  ],
       aL : ls (fp),
       for v in aL do
            ( fiL : file_info (v),
              rL : cons ( [scut (v),
                   part (fiL,2),
              float (part (fiL,4)/1000)], rL)),
       reverse (rL))$

  folder_info (path) :=
         (fpprintprec : 2, %FI : folder_info1 (path),
              display (%FI), fpprintprec : 0, done)$
---------------------------------------
and simply put up with the global bound
symbol %FI appearance which comes from using display.
--------------------------------------------
(%i1) fpprintprec;
(%o1)                                  0
(%i2) load(search_mfiles);
(%o2)                     c:/work2/search_mfiles.mac
(%i3) folder_info ("c:/work2/temp1/");
%FI = [[atext1.txt, 6, 0.2], [atext2.txt, 7, 0.2], [calc1news.txt, 116, 
4.2],
[ndata1.dat, 9, 0.3], [stavros-tricks.txt, 44, 1.4], [text1.txt, 5, 0.2],
[text2.txt, 5, 0.2], [trigsimplification.txt, 157, 5.0], [wu-d.txt, 4, 0.3]]

(%o3)                                done
(%i4) fpprintprec;
(%o4)                                  0
------------------------------------------
Ted Woollett
p.s. Thanks to Richard Fateman and
Dieter Kaiser for suggestions. (I am
 trying to avoid the 'dirty work').