Difference between revisions of "TruxtonChildFileIO 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 child file 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 11:
  
 
=Sample=
 
=Sample=
 
+
<source lang="Python" line highlight="15">
<syntaxhighlight lang="Python" line highlight="15">
 
 
import truxton
 
import truxton
  
Line 36: Line 35:
 
if __name__ == "__main__":
 
if __name__ == "__main__":
 
   main()
 
   main()
</syntaxhighlight>
+
</source>

Revision as of 12:22, 22 February 2021

This create child file 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

 1 import truxton
 2 
 3 def main():
 4   t = truxton.create()
 5   file = t.getfileid("5ec2a123-74d6-5da7-0653-4e6800000000")
 6 
 7   child = file.newchild()
 8 
 9   child.name = "My Child"
10   child.origin = truxton.ORIGIN_GENERATED
11   child.write("Hello Truxton World")
12   if child.save() is True:
13     print( "New child saved as id " + child.id)
14 
15   child2 = child.newchild()
16   child2.name = "My GrandChild"
17   child2.origin = truxton.ORIGIN_GENERATED
18   child2.write("Hello Truxton World")
19   if child.save() is True:
20     print( "New grandchild saved as id " + child.id)
21 
22 if __name__ == "__main__":
23   main()