I should preface this by saying I am a newbie to coding. What I am essentially looking to do is to create a set of tables, like the ones in the XML Example Project to load rosters into my project.
What I have done right now to try to deconstruct and reconstruct it is to make my own custom-panel, but try using the XML files from the example project (copied over into the folder where my current panel is).
Right now I have started with just the table that displays the Team Name and Datafile.
I have created the following parameters
teamName (0x3)
teamFilePath (0x4)
teamTable (0x2, the table works fine and displays the above two parameters with their initial "blank" values)
teams (0xB, An integer range constraint whose purpose I am not sure of, but it is in the code for the Xpath button)
I have then made a button, to which I have pretty much copied the code from the Xpath button in the example project:
var filepath = ogscript.getPrivateString('constants','filepath');
var XMLDoc;
ogscript.debug('Reading XML file: ' + filepath);
XMLDoc = ogscript.parseXML(filepath);
if (XMLDoc == null) {
ogscript.debug('Failed to read file');
} else {
ogscript.debug('Parsing XML');
var found = ogscript.runXPath('/league/team', XMLDoc);
ogscript.debug('search found ' + found.length + ' items');
params.setValue(0xb, 0, found.length); // teams = length
for (var i = 0; i < found.length; i++) {
var node = found.item(i);
var teamname = node.getAttribute('name');
var filename = node.getAttribute('filename');
ogscript.debug(i + ": " + teamname + ", " + filename);
params.setValue(3, i, teamname); // teamNames[i] = teamname
params.setValue(4, i, filename); // teamFilePaths[i] = filename
}
params.setValue(0x2, 0, 0); // league = 0 (triggers on change)
}
The only changes being the parameter numbers.
Trying to use it, though, my parameters remain with their default values and I am not sure why. There is probably a really simple explanation, but as I said I am relatively new to this. There are lines in that code whose actions/purpose I am not even sure of.