The screenshot above is a successful load after generating a file using the tester script pictured in the upper-left corner.
After saving with the following code and loading back is illustrated in the screenshot below:
Code: Select all
/*
** Convert a Treeview to a table
*/
Function p_TreeToTable()
return(p_TreeRecursion({},"Root"))
EndFunction
; worker function for p_TreeToTable
Function p_TreeRecursion(self, node)
Local test, entry = moai.DoMethod("tree", "GetEntry", node, "Head")
While test
DebugPrint("entering with "..entry.items[0])
If entry.Node = False
self[entry.items[0]] = moai.Get(entry.ID, "userdata")
Else
DebugPrint("recurring with "..entry.items[0])
self[entry.items[0]] = p_TreeRecursion({}, entry.UID)
EndIf
test, entry = moai.DoMethod("tree", "GetEntry", entry.UID, "Next")
DebugPrint(IIf(test,"not done","done"))
Wend
DebugPrint("Returning")
Return(self)
EndFunction
/*
** Save
*/
Function p_Save()
moai.Set("status", "text", "Saving file")
Local table = p_TreeToTable()
Local currentfile = OpenFile(Nil, projectname$, #MODE_WRITE)
WriteTable(currentfile, table)
CloseFile(currentfile)
table=Nil
CollectGarbage()
changed = False
saved = True
p_UpdateTitle()
p_UpdateButtonState()
moai.Set("status", "text", "Ready")
EndFunction