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 - count count the records within the specified scope http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 count               Count the records within the specified scope
------------------------------------------------------------------------------
 Syntax
   [!sAlias] count to gVar [scope] [while lExp] [for lExp]

 Arguments
   sAlias is the database to operate on.
   gVar is a long variable receiving the result.
   scope specifies a portion of the source database.
   lExp is a logical expression.

 Description
   The count command counts the records within the specified scope of the
   current or specified sAlias and then assigns the result to gVar.
   The gVar parameter may not be a field variable.

   The default scope of count is all.

 Example
   #define EXAMPLE_DATABASE
   #include example.hdr

   func ulong DelCount
   // Return number of deleted records (generic routine)
   param alias sAlias
   vardef
      ulong nDel
      ulong nRec
   enddef
   nRec := arecno( sAlias )
   !sAlias go top
   !sAlias count for deleted() to nDel
   !sAlias go nRec
   return( nDel )
   endfunc
   
   proc Test_count
   // Find out how many people called Joe are younger than 50
   vardef
      ulong nCounter
   enddef
   open sTest
   count to nCounter all for sTest->firstname = "Joe" .and. sTest->age < 50
   ? "Number of Joes younger than 50 years", nCounter
   go top
   delete                               // delete a record
   skip
   delete                               // delete a record
   go top
   count to nCounter while iskey() == 0 // count until a key is pressed
   ? "Data count", nCounter
   ? "Deleted records", DelCount( sTest )
   endproc

   proc main
   Test_count()
   endproc

See Also: Database command scope table average sum

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