W32util.dll w32olecleanup MIA + XML Example

W32util.dll w32olecleanup MIA + XML Example

Post by Dennis Bar » Sat, 11 Sep 2004 14:03:56


i,

The main problem I am having (apart from the lack of good examples) is
that:

call w32olecleanup

Doesn't work, I downloaded the latest code so perhaps its a new issue
as I haven't seen any posts on this issue but have seen some where
people are using it.

Some other issues:

* A "W32OleClearError()" call is badly needed.

* More examples, I have got some XML XPATH queries going so
I'll post it below, I'm sure it will save someone heaps of time.

* The OLE doco uses object and handle to sound like they mean
different things but thaye aren't for example see these
descriptions from the doco:
w32getproperty (handle, name[,typelist, parm1, ...]))
value
w32putproperty (object, name, typelist, value) 0 or 1

It should use "handle" consistently, the fact that it didn't
wasted about 20 minutes of my time.

Bye,
Dennis

P.S. The code has almost no error handling but does test/demonstrate
what would be required to add it:

/*
1. Try "getoleclass.exe MSXML.DOMDocument"
2. Library badly needs a "W32OleClearError()" call
3. w32olecleanup() doesn't exist, in doco, examples and found in
DLL...
*/


True = 1
False = 0
if rxfuncadd('w32loadfuncs','w32util','w32loadfuncs')>> 0 then
do
say rxfuncerrmsg()
exit 1
end
call w32loadfuncs

oXML = w32createobject('MSXML.DOMDocument')
if oXML = 0 | oXML = '' then
do
say 'CreateObject:' w32olegeterror()
exit 1
end

/*--- init ---*/
say 'ERROR?: ' w32olegeterror()
say "PUT: " || w32putproperty(oXML, "ValidateOnParse", "b", False)
say "PUT: " || w32putproperty(oXML, "Async", "b", False)
say "PUT: " || w32putproperty(oXML, "ResolveExternals", "b", False)
say 'ERROR?: ' w32olegeterror()

/*--- Load XML (string) ---*/
XmlString = <<><<>>Value.<Value.<"
say "LOAD XML: " || w32CallFunc(oXML, "LoadXml", "s", XmlString)
/*say "LOAD XML: " || w32getsubobj(oXML, "LoadXml", "s", XmlString)*/
say 'ERROR?: ' w32olegeterror()

/*--- Use XPATH to access property ---*/
say ''
XPATH = "//a/c"
say 'Getting object from XPATH = ' || XPATH
oXpath = w32getsubobj(oXML, "selectSingleNode", "s", XPATH)
say 'VALUE : ' || w32GetProperty(oXpath, "text")
say 'NAME : ' || w32GetProperty(oXpath, "nodeName")
say 'ERROR?: ' w32olegeterror()
if w32GetProperty(oXpath, "nodeName") = "" then
say "XPATH FAILED..................."

say ''
XPATH = "//a/b"
say 'Getting object from XPATH = ' || XPATH
oXpath = w32getsubobj(oXML, "selectSingleNode", "s", XPATH)
say 'VALUE : ' || w32GetProperty(oXpath, "text")
say 'NAME : ' || w32GetProperty(oXpath, "nodeName")
say 'ERROR?: ' w32olegeterror()
if w32GetProperty(oXpath, "nodeName") = "" then
say "XPATH FAILED..................."

say ''
XPATH = "//a/zunknown"
say 'Getting object from XPATH = ' || XPATH
oXpath = w32getsubobj(oXML, "selectSingleNode", "s", XPATH)
say 'VALUE : ' || w32GetProperty(oXpath, "text")
say 'NAME : ' || w32GetProperty(oXpath, "nodeName")
say 'ERROR?: ' w32olegeterror()
if w32GetProperty(oXpath, "nodeName") = "" then
say "XPATH FAILED..................."



/* Bug? Doesn't work, I found in the DLL though... */
say ''
say 'The following cleanup call will fail.....'
say ''
call w32olecleanup



----------------------------
Dennis Bareis ( XXXX@XXXXX.COM )
http://www.labyrinth.net.au/~dbareis/index.h
 
 
 

W32util.dll w32olecleanup MIA + XML Example

Post by rony » Sat, 11 Sep 2004 22:33:42

ennis,

below you'll find your example recoded in Object Rexx for Windows which has a proxy class to interface with OLE/ActiveX
objects. Just a little remark or two: you should always test whether a call/method invocation on the Windows side has
returned anything. Your last example, where you test what happens if an XPATH is used which does not return a value, you
should not use 0 or "" as the target of a message named "text". Maybe that (impossible) argument causes some troubles.

Anyway, here your example, rewritten in Object Rexx (but leaving the classic Rexx counterparts for comparison; the two
dashes "--" are line comments, i.e. everything after it up to the end of the line is regarded as a comment in Object Rexx):

------------------------ cut here ---------------------

/* Object Rexx rendering of your example, ---rgf */


-- True = 1
-- False = 0
-- if rxfuncadd('w32loadfuncs','w32util','w32loadfuncs') > 0 then
-- do
-- say rxfuncerrmsg()
-- exit 1
-- end
-- call w32loadfuncs

-- oXML = w32createobject('MSXML.DOMDocument')
-- if oXML = 0 | oXML = '' then
-- do
-- say 'CreateObject:' w32olegeterror()
-- exit 1
-- end


oXML=.OLEObject~new('MSXML.DOMDocument')
if oXML=.nil then
do
say 'CreateObject: not successful!'
exit 1
end


/*--- init ---*/
-- say 'ERROR?: ' w32olegeterror()
-- say "PUT: " || w32putproperty(oXML, "ValidateOnParse", "b", False)
-- say "PUT: " || w32putproperty(oXML, "Async", "b", False)
-- say "PUT: " || w32putproperty(oXML, "ResolveExternals", "b", False)
-- say 'ERROR?: ' w32olegeterror()

oXML~ValidateOnParse=.false
oXML~Async=.false
oXML~ResolveExternals=.false

/*--- Load XML (string) ---*/
XmlString = "<a><b>Value.B</b><c>Value.C</c></a>"
say "XmlString: [" || XmlString || "]"
say

-- say "LOAD XML: " || w32CallFunc(oXML, "LoadXml", "s", XmlString)
-- say 'ERROR?: ' w32olegeterror()
oXML~loadXml(XmlString)


/*--- Use XPATH to access property ---*/
say
XPATH = "//a/c"
say 'Getting object from XPATH = ' || XPATH

-- oXpath = w32getsubobj(oXML, "selectSingleNode", "s", XPATH)
-- say 'VALUE : ' || w32GetProperty(oXpath, "text")
-- say 'NAME : ' || w32GetProperty(oXpath, "nodeName")
-- say 'ERROR?: ' w32olegeterror()
-- if w32GetProperty(oXpath, "nodeName") = "" then
-- say "XPATH FAILED..................."

oXpath=oXML~selectSingleNode(XPATH)
say 'VALUE : ' || oXpath~text
say 'NAME : ' || oXpath~nodeName
if oXpath~nodeName = "" then
say "XPATH FAILED..................."


say
XPATH = "//a/b"


-- say 'Getting object from XPATH = ' || XPATH
-- oXpath = w32getsubobj(oXML, "selectSingleNode", "s", XPATH)
-- say 'VALUE : ' || w32GetProperty(oXpath, "text")
-- say 'NAME : ' || w32GetProperty(oXpath, "nodeName")
-- say 'ERROR?: ' w32olegeterror()
-- if w32GetProperty(oXpath, "nodeName") = "" then
-- say "XPATH FAILED..................."

oXpath=oXML~selectSingleNode(XPATH)
say 'VALUE : ' || oXpath~text
say 'NAME : ' || oXpath~nodeName
if oXpath~nodeName = "" then
say "XPATH FAILED..................."


say
XPATH = "//a/zunknown"

-- say 'Getting object from XPATH = ' || XPATH
-- oXpath = w32getsubobj(oXML, "selectSingleNode", "s", XPATH)
-- say 'VALUE : ' || w32GetProperty(oXpath, "text")
-- say 'NAME : ' || w32GetProperty(oXpath, "nodeName")
-- say 'ERROR?: ' w32olegeterror()
-- if w32GetProperty(oXpath
 
 
 

W32util.dll w32olecleanup MIA + XML Example

Post by Dennis Bar » Sun, 12 Sep 2004 16:02:12

i,

Thanks for the info.

I know that object rexx is pretty good and I would certainly like to
use objects, however it is not free.

Thanks,
Dennis


On Fri, 10 Sep 2004 15:33:42 +0200, rony
< XXXX@XXXXX.COM > wrote:



---
Dennis Bareis
http://www.labyrinth.net.au/~dbareis/index.htm
PPWIZARD: free HTML Preprocessor (really any text files)
MAKEMSI : free tool to Create or update MSI, MSM, CUB etc.
MSIDIFF : Compare or Display MSI, MSM, patches, transforms etc
 
 
 

W32util.dll w32olecleanup MIA + XML Example

Post by ptjm » Mon, 13 Sep 2004 12:24:51

In article < XXXX@XXXXX.COM >,


% The main problem I am having (apart from the lack of good examples) is
% that:
%
% call w32olecleanup
%
% Doesn't work,

What does it do? It's certainly been known to work. Just this morning
I called it and it worked like a charm. There are still some surprising
bugs in the OLE code, though. I'll try your test case out when I have
a chance.

% * A "W32OleClearError()" call is badly needed.

Hmm. There's code in there to clear the error buffer at the start
of every call, with the curious exceptions of w32ReleaseObject(),
w32OLECleanUp(), and of course w32OLEGetError(). Where does the
need for this arise?

% * More examples, I have got some XML XPATH queries going so
% I'll post it below, I'm sure it will save someone heaps of time.

Do you mind if I include it in the distribution?

% * The OLE doco uses object and handle to sound like they mean
% different things but thaye aren't for example see these
% descriptions from the doco:
% w32getproperty (handle, name[,typelist, parm1, ...]))
% value
% w32putproperty (object, name, typelist, value) 0 or 1

Those are synopses. The descriptions are quite consistent, to the
point where you might almost think they were a cut and paste job if
you didn't know that I labour over every phrase, sometimes late into
the night, until I'm sure they're perfect:

Given a valid handle to an object and the name of a property
of this object, [...]

I guess sometimes I hate the word handle, and sometimes I hate
the word object. It could probably stand to be tidied up. I completely
agree that the OLE routines need a usage guide, and I started writing
one about four years ago. The trouble is that I got about 200 lines
in when I wrote

I find the OLE routines to be hopeless from a useability perspective,
so my current plan is to re-implement them at some point during 2000.

and another couple of hundred lines later I decided my time would be
better spent working on that re-implementation. I did write it, but
I wasn't happy with it, then I rewrote it and wasn't happy with it,
and I did a little work on it last November with an eye to including
it in the release, but I didn't for reasons I don't recall -- perhaps
because I wanted to finish the usage guide first.


--

Patrick TJ McPhee
East York Canada
XXXX@XXXXX.COM
 
 
 

W32util.dll w32olecleanup MIA + XML Example

Post by Dennis Bar » Mon, 13 Sep 2004 17:45:58

Hi,

On 12 Sep 2004 03:24:51 GMT, XXXX@XXXXX.COM (Patrick TJ McPhee)





I'll have to restest everything, I noticed that I was using using an
older version even though the newer was in the current directory.
Sorry about that. I'd say these are old bugs/issues that have been
corrected.



No go for it. I'll get around to imrpoving it and may come up with
some others if you want, I'll send them when I've done this.

Bye,
Dennis

---
Dennis Bareis
http://www.yqcomputer.com/ ~dbareis/index.htm
PPWIZARD: free HTML Preprocessor (really any text files)
MAKEMSI : free tool to Create or update MSI, MSM, CUB etc.
MSIDIFF : Compare or Display MSI, MSM, patches, transforms etc
 
 
 

W32util.dll w32olecleanup MIA + XML Example

Post by Dennis Bar » Tue, 14 Sep 2004 16:52:16

Hi,

On 12 Sep 2004 03:24:51 GMT, XXXX@XXXXX.COM (Patrick TJ McPhee)





I'll have to restest everything, I noticed that I was using using an
older version even though the newer was in the current directory.
Sorry about that. I'd say these are old bugs/issues that have been
corrected.



No go for it. I'll get around to imrpoving it and may come up with
some others if you want, I'll send them when I've done this.

Bye,
Dennis

---
Dennis Bareis
http://www.yqcomputer.com/ ~dbareis/index.htm
PPWIZARD: free HTML Preprocessor (really any text files)
MAKEMSI : free tool to Create or update MSI, MSM, CUB etc.
MSIDIFF : Compare or Display MSI, MSM, patches, transforms etc