Difference between revisions of "TruxtonFileIO newchild"

From truxwiki.com
Jump to navigation Jump to search
(Created page with "This create an artifact object from a file in Truxton. It automatically associates the parent file and media identifiers used in the File table. =Syntax= <sy...")
 
Line 1: Line 1:
 
This create an artifact object from a file in Truxton.
 
This create an artifact object from a file in Truxton.
It automatically associates the parent file and media identifiers used in the [[File Table | File table.]]
+
It automatically associates the parent file and media identifiers used in the <code><nowiki>[</nowiki>[[File Table|File]]<nowiki>]</nowiki></code> table.
 
 
 
=Syntax=
 
=Syntax=
<syntaxhighlight lang="Python">
+
<source lang="Python">
 
object newchild();
 
object newchild();
</syntaxhighlight>
+
</source>
  
 
=Return value=
 
=Return value=
Line 11: Line 10:
  
 
=Sample=
 
=Sample=
 
+
<source lang="Python" highlight="7">
<syntaxhighlight lang="Python" highlight="7">
 
 
import truxton
 
import truxton
  
Line 29: Line 27:
 
if __name__ == "__main__":
 
if __name__ == "__main__":
 
   main()
 
   main()
</syntaxhighlight>
+
</source>

Revision as of 16:23, 9 December 2020

This create an artifact object from a file in Truxton. It automatically associates the parent file and media identifiers used in the [File] table.

Syntax

object newchild();

Return value

An child file object

Sample

import truxton

def main():
  t = truxton.create()
  file = t.getfileid("5ec2a123-74d6-5da7-0653-4e6800000000")

  child = file.newchild()

  child.name = "My Child"
  child.origin = truxton.ORIGIN_GENERATED
  child.write("Hello Truxton World")
  if child.save() is True:
    print( "New child saved as id " + child.id)

if __name__ == "__main__":
  main()