Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Force 4.0 Reference - on pack do install a procedure to execute in the pack loop http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 on pack do          Install a procedure to execute in the pack loop
------------------------------------------------------------------------------
 Syntax
   on pack do [xProc]

 Arguments
   xProc is a function to repeatedly execute in the packing loop.

 Description
   The on pack do command installs the specified xProc into the
   pack loop. Whenever Force reads a record while packing a database, it will
   call xProc, and pass the current record number as a parameter. The
   records are processed in ascending order.

   The on pack do command is handy to display a progress indicator during the
   packing process, either a simple count-down display, or a progress bar.

   To uninstall the pack loop function, write the command without a xProc
   name.

   Note that packing an indexed database automatically performs a reindex
   after packing the database. To display the progress of the reindexing,
   use the on index do command.

 Example
   #define EXAMPLE_DATABASE
   #include example.hdr

   vardef sfar
      ulong nRecs2
   enddef
   
   proc DispRecs2
   param value ulong nCurrRec
   // Simple count-down display
   saverc()                        // save cursor
   ?? nRecs2 - nCurrRec            // show remaining records
   waitms( 100 )                   // some delay to make it more visible
   restrc()                        // restore cursor
   endproc
   
   proc Test_onpackdo
   clear
   cursoroff()
   open sTest
   nRecs2 := areccount( sTest )    // save record count
   on pack do DispRecs2            // install callback function
   ? "Packing database..."
   !sTest pack
   ? "done..."
   on pack do                      // deinstall callback function
   cursoron()
   endpro

   proc main
   Test_onpackdo()
   endproc

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson