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 - build from fields create a database from a field list http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 build from fields   Create a database from a field list
------------------------------------------------------------------------------
 Syntax
   build cFile from fields fields

 Arguments
   cFile is the name of the database file to create.
   fields is a list of fields defined in an alias declaration.

 Description
   The build from fields command creates the database file specified
   by cFile and then constructs a database header from fields.

   The file created by build from fields is not open when the command returns,
   i. e. it is not ready for appending, replacing, etc. The file must be
   opened with the open or use command after it has been built.

 Example
   #define EXAMPLE_DATABASE
   #include example.hdr

   dbfdef sTemp2
      char( 15 ) lastname
      dbl( 9:2 ) balance
      date       due
   enddef
   
   proc Test_buildfromfields
   vardef
      uint n
   enddef
   open sTest                          // open template database
   build "stemp2.dbf" from fields sTest->lastname, sTest->balance, sTest->due
   open sTemp2                         // open new database
   ? "New database is", adbf( sTemp2 ) // display structural data
   ? "Number of fields is", istr( afldcnt( sTemp2 ) )
   for n := 1 to afldcnt( sTemp2 )
      ? afieldname( sTemp2, n ):10, afieldtype( sTemp2, n ), ;
         afieldlen( sTemp2, n ), afielddec( sTemp2, n )
   next
   close all                           // clean up
   endproc

   proc main
   Test_buildfromfields()
   endproc

See Also: build from alias open

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