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 index do install a procedure to execute in the indexing loop http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 on index do         Install a procedure to execute in the indexing loop
------------------------------------------------------------------------------
 Syntax
   on index do [xProc]

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

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

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

   To uninstall an index loop procedure, write the command without an xProc
   name.

 Example
   #define EXAMPLE_DATABASE
   #include example.hdr

   vardef sfar
      ulong nRecs1
   enddef
   
   proc DispRecs1
   param value ulong nCurrRec
   // Simple count-down display
   wait
   saverc()                        // save cursor
   ?? nRecs1 - nCurrRec            // show remaining records
   waitms( 100 )                   // some delay to make it more visible
   restrc()                        // restore cursor
   endproc
   
   proc Test_onindexdo
   clear
   cursoroff()
   open sTest
   nRecs1 := areccount( sTest )    // save record count
   on index do DispRecs1           // install callback function
   ? "Indexing database..."
   !sTest index "test.fdx" alias sIdxLN
   ? "done..."
   on index do                     // deinstall callback function
   cursoron()
   erase "test.fdx"
   endproc

   proc main
   Test_onindexdo()
   endproc

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