Page 1 of 1

RapaGUI 1.1 GetEntry method

Posted: Mon Jun 26, 2017 5:28 pm
by SamuraiCrow
I can load a file created with a generator in my Table Editor. The problem is it won't save correctly if an empty node is present.

Image
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	
Image

Re: RapaGUI 1.1 GetEntry method

Posted: Tue Jun 27, 2017 6:38 am
by SamuraiCrow
Reduced images:
Image
Image

Re: RapaGUI 1.1 GetEntry method

Posted: Tue Jun 27, 2017 5:39 pm
by airsoftsoftwair
Can you elaborate some more on this? From what you wrote I don't understand where you suspect a bug here. Are you saying that there is a bug in WriteTable(), ReadTable() or Treeview.GetEntry()?

Re: RapaGUI 1.1 GetEntry method

Posted: Wed Jun 28, 2017 2:32 am
by SamuraiCrow
Treeview.GetEntry skips a record when it encounters an empty node. If the empty node is gone, the subroutine listed above works. The "next" mode is wrong.

Re: RapaGUI 1.1 GetEntry method

Posted: Sat Jul 01, 2017 10:48 pm
by airsoftsoftwair
Right, I can confirm this. It works correctly on AmigaOS, though, but not on the other platforms. Thanks for reporting!

Re: RapaGUI 1.1 GetEntry method

Posted: Thu Aug 10, 2017 7:18 pm
by airsoftsoftwair

Code: Select all

- Fix [Win32/Linux/MacOS]: Treeview.GetEntry() didn't work correctly for nodes which were empty