quote:
Originally posted by matty
This is code from Screenshot Sender to enumerate controls it could be altered to do what you would need it to do:
Javascript code:
/*
Name: EnumControls
Purpose: Enum the controls from a specified window
Parameters: File - The name of the file
pPlusWnd - The Plus! window object
Return: None
*/
function EnumControls ( File , pPlusWnd ) {
_debug.getfuncname ( arguments ) ;
// Load the XML from the specified file
var XML = new ActiveXObject ( 'MSXML.DOMDocument' ) ;
XML.load ( File ) ;
// Loop through all of the controls
var Controls = XML.selectNodes ( '/Interfaces/Window [ @Id='' + pPlusWnd.WindowId + '' ] /Controls/Control' ) ;
for ( i=0 ; i<Controls.length ; i ++) {
var Id = Controls [ i ].getAttribute ( 'Id' ) ;
var Type = Controls [ i ].getAttribute ( 'xsi:type' ) ;
// Get the value depending on the control's type
objControls [ Id ] = {} ;
objControls [ Id ].XsiType = Type ;
objControls [ Id ].Value = pPlusWnd_GetControlvalue ( pPlusWnd , Id , Type ) ;
}
}
That loops through all of the controls, but I need it to loop through all the children of the controls. The problem I have is that some nodes, like the <Image> node, store their data in another child, meaning that I have to do a loop in a loop, in a loop, and so on.
Obviously, I can only go so far, and I'd rather just have the entire code, but I don't think that can be done, unless I don't use the XML DOM, and start checking each line through the FileSystemObject. But that's a bit ridiculous.
EDIT: Done it now. Ended up using the
nodeObj.xml property, and filtering out the recognized bits. Perhaps not the best method, but it works.
Javascript code:
var ControlExtra = "";
var ControlExtraProcess = ControlNode.xml;
ControlExtraProcess = ControlExtraProcess.replace(/<\/?Control.*>/g, "");
ControlExtraProcess = ControlExtraProcess.replace(/<Position[^ ]*?(\/>|>[^ ]*?<\/Position>)/g, "");
ControlExtraProcess = ControlExtraProcess.replace(/<Caption>[^ ]*?<\/Caption>/g, "");
ControlExtraProcess = ControlExtraProcess.replace(/<Help>[^ ]*?<\/Help>/g, "");
ControlExtraProcess = ControlExtraProcess.split("\r\n");
ControlExtraFilter = new Array();
for (var X in ControlExtraProcess)
{
if (ControlExtraProcess[X].replace(/\s/g, "") !== "")
{
ControlExtraFilter.push(ControlExtraProcess[X].replace(/\t/, ""));
}
}
ControlExtraFilter = ControlExtraFilter.join("\r\n");
if (ControlExtraFilter !== "")
{
ControlExtra = ControlExtraFilter;
}