Difference between revisions of "Truxton child file new child"

From truxwiki.com
Jump to navigation Jump to search
 
(One intermediate revision by the same user not shown)
Line 3: Line 3:
  
 
=Syntax=
 
=Syntax=
<syntaxhighlight lang="C">
+
<source lang="C">
 
uint64_t truxton_child_file_new_child( uint64_t child_handle );
 
uint64_t truxton_child_file_new_child( uint64_t child_handle );
</syntaxhighlight>
+
</source>
  
 
=Parameters=
 
=Parameters=
Line 15: Line 15:
  
 
=Sample=
 
=Sample=
 
+
<source lang="C" highlight="16">
<syntaxhighlight lang="C" highlight="16">
+
int print_id( uint64_t truxton )
int print_id(uint64_t truxton)
 
 
{
 
{
   uint64_t file = truxton_file_open_md5(truxton, "9ec8fb6095c35eff2b236863b7caaf10");
+
   uint64_t file = truxton_file_open_md5( truxton, "9ec8fb6095c35eff2b236863b7caaf10" );
  
 
   if ( file != 0 )
 
   if ( file != 0 )
 
   {
 
   {
       return(0);
+
       return( 0 );
 
   }
 
   }
  
Line 41: Line 40:
 
   truxton_file_free( file );
 
   truxton_file_free( file );
 
}
 
}
</syntaxhighlight>
+
</source>

Latest revision as of 17:39, 10 February 2021

This will create a new child file object in Truxton that is a child of the current file. That child will not exist in the database until truxton_child_file_save() is called.

Syntax

uint64_t truxton_child_file_new_child( uint64_t child_handle );

Parameters

child_handle

The handle created by the truxton_child_file_create or truxton_file_create_child call.

Return value

The a child file object handle.

Sample

int print_id( uint64_t truxton )
{
   uint64_t file = truxton_file_open_md5( truxton, "9ec8fb6095c35eff2b236863b7caaf10" );

   if ( file != 0 )
   {
      return( 0 );
   }

   uint64_t child = truxton_file_create_child( file );

   truxton_child_file_set_name( child, "Sam" );

   truxton_child_file_save( child );

   uint64_t grand_child = truxton_child_file_new_child( child );

   truxton_child_file_set_name( grand_child , "Paul" );
   truxton_child_file_save( grand_child );

   truxton_child_destroy( grand_child );
   truxton_child_destroy( child );
   truxton_file_free( file );
}