alias test {
;This is the test alias to see if I can get /returns
echo $xml.document(http://api.imgur.com/2/image/D2ht4,imgurLoaded) this works fine
}
;This alias is the target of the $comcall
alias imgurLoaded {
;first check if document loaded correctly, $1 is a reference to the document
;echo imgurLoaded one < $1 > two < $2 > v1 < $v1 >
if (!$xml.parseError($1)) {
;echo -a $xml.node($1,//original).text
echo -a $iif($xml.selectNode($1,//original) && $v1 != $com($v1,text,2),$com($v1).result) $xml.destroy($v1)
}
noop $xml.destroy($1)
return This is imgurLoaded's return! Success! Exactly what I'm looking for... except I can't get it :(
}
alias xml.document {
;echo xml.document one < $1 > two < $2 >
var %document = $xml._register(document),%error
.comopen %document MSXML.DOMDOCUMENT
noop $com(%document,setProperty,3,bstr,SelectionLanguage,bstr,XPath) $com(%document,async,5,bool,$iif($2,0,-1))
; Here is the $comcall I was talking about!
noop testsuppie $comcall(%document,$2 %document,load,3,bstr,$1)
;echo Testing imgurLoaded's return: $imgurLoaded(%document)
return xml.document's return! Slightly successful :(
}
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
; YOU CAN STOP READING HERE. The following is just support code that doesn't change anything important
; Just leaving it here so you can copy/paste to test if you want.
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
alias imgur {
;Original primary alias from the hawkee link, I don't use it because it doesn't use /return
noop $xml.document($+(http://api.imgur.com/2/image/, $1),imgurLoaded)
}
alias xml.loadXML if ($xml.instanceOf($1) == document) return $com($1,loadXML,3,bstr,$2-)
alias xml.selectNode return $iif($xml._register(node,$1) && $v1 != $com($1,selectSingleNode,3,bstr,$2,dispatch* $v1),$v1)
alias xml.selectNodeSet return $iif($xml._register(nodeSet,$1) && $v1 != $com($1,selectNodes,3,bstr,$2,dispatch* $v1),$v1)
alias xml.node {
;echo xml.node one < $1 > two < $2 > v1 < $v1 > prop < $prop >
return $iif($xml.selectNode($1,$2) && $v1 != $com($v1,$prop,2),$com($v1).result) $xml.destroy($v1)
}
alias xml.setAttributes {
if ($$2) && ($com($1)) {
var %i 2
while (%i <= $0) {
noop $com($1,setAttribute,3,bstr,$(,$ $+ %i),bstr,$(,$ $+ $calc(%i + 1)))
inc %i 2
}
}
}
alias xml.destroy {
if ($xml.reference($$1)) {
var %nodes = $com(_xmlCom,selectNodes,3,bstr,$+(//*[@id=',$1'],//@id),dispatch* nodes)
while ($iif($com(nodes,nextNode,3,dispatch* ~xml) && $com(~xml),~xml)) {
var %comObject = $iif($com(~xml,text,2),$com(~xml).result)
if ($com(%comObject)) .comclose %comObject
.comclose ~xml
}
.comclose nodes $com(_xmlCom,selectSingleNode,3,bstr,$+(//*[@id=',$1']),dispatch* $+(node,$1)) $xml.remove($+(node,$1),$true)
}
else echo -a $1
}
alias xml.remove {
if ($xml.reference($1) || node* iswm $1) {
noop $com($1,parentNode,3,dispatch* $+(parent,$1))
noop $com($+(parent,$1),removeChild,3,dispatch,$1)
.comclose $+(parent,$1)
}
}
alias -l xml._register {
if (!$hget(_xml,_constructed)) xml._constructor
var %name = $xml._newName($1,$2)
noop $com(_xmlCom,selectSingleNode,3,bstr,$iif($2,$+(//*[@id=',$2']),/*),dispatch* _parent)
.comclose _parent $com(_xmlCom,createElement,3,bstr,$1,dispatch* _newNode) $com(_parent,appendChild,3,dispatch,_newNode)
.comclose _newNode $com(_newNode,setAttribute,3,bstr,id,bstr,%name)
hadd -m _xml %name $1
return %name
}
alias xml._newName {
return $gettok($+($gettok($2,1,46),._xml,$ticks,$com(0)),1-,46)
}
alias xml.reference return $iif($hget(_xml,$1),$true,$false)
alias xml.instanceOf return $iif($hget(_xml,$1),$v1)
alias -l xml._ownerDocument return $gettok($1,1,46)
alias xml.resetAll {
xml._destructor
xml._constructor
echo -a removed all xml object references
}
alias xml._constructor {
.comopen _xmlCom MSXML.DOMDOCUMENT
hadd -m _xml _constructed $com(_xmlCom,loadXML,3,bstr,<xmlComConnections />)
}
alias xml._destructor {
if ($com(_xmlCom)) .comclose _xmlCom
hfree _xml
var %i = $com(0)
while (%i > 0) {
if (_xml* iswm $com(%i)) .comclose $v2
dec %i
}
hadd -m _xml _constructed 0
}