quote:
Originally posted by SmokingCookie
Have you slept well?
Anyway, here you go with a fix. I've left out the control/element typing. You can do that by retrieving the "xsi:type" attribute of a selected node (so K.item()). I've also included a prototype of my own JSON interpreter, but it does not return valid JSON yet. It's only to give you a basic idea of the object that has been created by parseFile().
Ok, let's see.
js code:
var ControlsXPath = "//Interfaces/Window[@Id=\"" + WindowId + "\"]/Controls/Control";
var ElementsXPath = "//Interfaces/Window[@Id=\"" + WindowId + "\"]/Elements/Element";
// Define objects that contain the control types, subdevided into control/element IDs
ret.Interface[WindowId] = new Object();
ret.Interface[WindowId].Controls = new Object();
ret.Interface[WindowId].Elements = new Object();
1) Am I able to create my own, like this? For example, to get the window title:
js code:
var CaptionsXPath = "//Interfaces/Window[@Id=\"" + WindowId + "\"]/Attributes/Caption";
var TitlesXPath = "//Interfaces/Window[@Id=\"" + WindowId + "\"]/TitleBar/Title/Text";
But... it can't be enumerated:
js code:
var K = new Enumerator(xml.selectNodes(CaptionsXPath));
It's different, because the value isn't "<Item Parameter="Value">", but "<Item>Value</Item>". How can I get that?
js code:
var K = new Enumerator(xml.selectNodes(ControlsXPath));
if(K.count() > 0) {
for(; !K.atEnd(); K.moveNext()) {
var ControlNode = K.item();
var ControlId = ControlNode.getAttribute("Id");
// Define an object for this control type (as in ButtonControl or StaticControl) that contains the actual control
// Only done when necessary
if(ControlId in ret.Interface[WindowId].Controls) {
//[alert the user that there's 2 or more controls with the same ID]
continue;
}
// You'll have to do your own stuff here
ret.Interface[WindowId].Controls[ControlId] = "null" //[JScript control definition stuff]
}
}
2a) If that gets a control ID, then I assume that getting the type uses the same method, replacing ".getAttribute("Id")" with ".getAttribute("xsi:type")", right?
2b) Would this work:
js code:
var K = new Enumerator(xml.selectNodes(ControlsXPath + "/Position"));
for(; !K.atEnd(); K.moveNext()) {
var ControlNode = K.item();
var ControlLeft = ControlNode.getAttribute("Left");
// Define an object for this control type (as in ButtonControl or StaticControl) that contains the actual control
// Only done when necessary
if(ControlId in ret.Interface[WindowId].Controls) {
//[alert the user that there's 2 or more controls with the same ID]
continue;
}
// You'll have to do your own stuff here
ret.Interface[WindowId].Controls[ControlId] = "null" //[JScript control definition stuff]
}
I apologise for so many questions, but this is a confusing topic for me...
EDIT: yes, I slept well. 10 good hours.
quote:
Originally posted by Flippy
I may be stupid lol, but how do I even use this? I installed the script, it says it's started in the preferences/options screen, but I have no idea how to use it lol... I don't see it anywhere?
Go to the Script Menu > "Interface Writer" > "Create a new interface...".