Loading ...
Sorry, an error occurred while loading the content.
 

Re: Iterating hash from COM objects

Expand Messages
  • Paul Kulchenko
    Hi Gusti, ... Yes; SOAP::Lite uses ActiveState s PDK to generate COM interface. From PDK documentation (see link from Google s cache; couldn t find it after
    Message 1 of 3 , Dec 21, 2002
      Hi Gusti,

      > hashecho.vbs, I could not find any references in order to obtain
      > all keys
      > from the variable �echohash� and thus use loops to extract them.
      Yes; SOAP::Lite uses ActiveState's PDK to generate COM interface.
      From PDK documentation (see link from Google's cache; couldn't find
      it after quick search on activestate's site:
      http://216.239.33.100/search?q=cache:oqBbbZPzB64C:aspn.activestate.com/ASPN/Perl/Reference/Products/PDK/PerlCOM/Hashes.html+PerlCOM+%22::hash%22+keys+values+site:activestate.com&hl=en&ie=UTF-8):


      -If you know the name of a key, you can access its value as a
      property, as in objHash.propertyname
      -If you don't know the name of the key(s), you can get at all the
      hash keys with the Keys() method. The Keys() method returns an array
      containing all the keys in the hash. Similarly, the Values() method
      returns an array containing all the values.
      -You can use the Each() method to fetch successive key/value pairs as
      an array with two elements.

      Let me know if that doesn't work for you. I'll update the
      documentation to include this info.

      Best wishes, Paul.

      --- Gusti Seregeg <gusti@...> wrote:
      > Dear Paul,
      >
      > Thank you for bringing SOAP::Lite to the world. I have used it in
      > many
      > occasions with my Perl script to communicate with Web Services that
      > I
      > develop.
      >
      > I am now trying it out with COM objects so that my customers can
      > enjoy it
      > too but without having to know Perl. One question I�d like to ask
      > you is,
      > how to iterate the hash results. From your sample code (below)
      > taken from
      > hashecho.vbs, I could not find any references in order to obtain
      > all keys
      > from the variable �echohash� and thus use loops to extract them.
      >
      > A quick hint would be much appreciated.
      >
      > Thank you Paul. Great work!!!
      >
      > Gusti Seregeg.
      > Melbourne.
      >
      >
      > ------------------------------------
      > ' -- SOAP::Lite -- soaplite.com -- Copyright (C) 2001 Paul
      > Kulchenko --
      >
      > ' Connect to remote SOAP server
      >
      > Set soaplite = CreateObject("SOAP.Lite")
      > ' values can be stored in hash using "hash" method
      > Set subhash = soaplite.hash("key_c", "Value C")
      > Set hash = soaplite.hash("key_a", "Value A", "key_b", subhash)
      > ' or can be assigned directly
      > hash.key_b.key_d = "Value D"
      >
      > Set echohash = soaplite.new( _
      > "proxy", "http://services.soaplite.com/echo.cgi", _
      > "uri", "http://namespaces.soaplite.com/Echo" _
      > ).echo(hash).result
      >
      > MsgBox "key_a: " & echohash.key_a & chr(13) & _
      > "key_b+key_c: " & echohash.key_b.key_c & chr(13) & _
      > "key_b+key_d: " & echohash.key_b.key_d
      >
      >
      >
      >
      >


      __________________________________________________
      Do you Yahoo!?
      Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
      http://mailplus.yahoo.com
    • Paul Kulchenko
      Hi Gusti, ... from examples/COM/README: How do I call a method in a list/array context? You can coerce any method call into a list context. Instead of
      Message 2 of 3 , Dec 22, 2002
        Hi Gusti,

        > to article 2198 - Andy Kelk] and ended up only one entry. How do I
        > pass wantarray() context to valueof() method?

        from examples/COM/README:

        How do I call a method in a list/array context?

        You can coerce any method call into a list context. Instead of
        invoking:

        Dim arrayFoo
        arrayFoo = myPerlObj.some_method()

        Use the List property to invoke the method:

        Dim arrayFoo
        arrayFoo = myPerlObj.List.some_method()

        Hope this helps.

        Best wishes, Paul.

        --- "gusti64 <gusti.seregeg@...>"
        <gusti.seregeg@...> wrote:
        > Thanks Paul,
        >
        > That solved the problem. Wow, should've come to this forum a lot
        > earlier!!
        >
        > There is another one, for those who work on the COM/.NET space.
        > In Perl, I can retrieve results as arrays with this call:
        >
        > @result= $som->valueof ('//Result')
        >
        > That is fine in Perl, but I can't specify that in COM objects.
        > Each
        > time I do this (VB)
        >
        > Set result= som.valueof ("//Result")
        >
        > it yields a hash. Unfortunately, all having the same key [similar
        > to article 2198 - Andy Kelk] and ended up only one entry. How do I
        > pass wantarray() context to valueof() method?
        >
        > Thanks.
        > Gusti.
        >
        >
        > --- In soaplite@yahoogroups.com, Paul Kulchenko <paulclinger@y...>
        > wrote:
        > > Hi Gusti,
        > >
        > > > hashecho.vbs, I could not find any references in order to
        > obtain
        > > > all keys
        > > > from the variable `echohash' and thus use loops to
        > extract them.
        > > Yes; SOAP::Lite uses ActiveState's PDK to generate COM interface.
        > > From PDK documentation (see link from Google's cache; couldn't
        > find
        > > it after quick search on activestate's site:
        > > http://216.239.33.100/search?
        >
        q=cache:oqBbbZPzB64C:aspn.activestate.com/ASPN/Perl/Reference/Product
        > s/PDK/PerlCOM/Hashes.html+PerlCOM+%22::hash%
        > 22+keys+values+site:activestate.com&hl=en&ie=UTF-8):
        > >
        > >
        > > -If you know the name of a key, you can access its value as a
        > > property, as in objHash.propertyname
        > > -If you don't know the name of the key(s), you can get at all the
        > > hash keys with the Keys() method. The Keys() method returns an
        > array
        > > containing all the keys in the hash. Similarly, the Values()
        > method
        > > returns an array containing all the values.
        > > -You can use the Each() method to fetch successive key/value
        > pairs
        > as
        > > an array with two elements.
        > >
        > > Let me know if that doesn't work for you. I'll update the
        > > documentation to include this info.
        > >
        > > Best wishes, Paul.
        > >
        > > --- Gusti Seregeg <gusti@s...> wrote:
        > > > Dear Paul,
        > > >
        > > > Thank you for bringing SOAP::Lite to the world. I have used it
        >
        > in
        > > > many
        > > > occasions with my Perl script to communicate with Web Services
        > that
        > > > I
        > > > develop.
        > > >
        > > > I am now trying it out with COM objects so that my customers
        > can
        > > > enjoy it
        > > > too but without having to know Perl. One question I'd like
        > to
        > ask
        > > > you is,
        > > > how to iterate the hash results. From your sample code (below)
        > > > taken from
        > > > hashecho.vbs, I could not find any references in order to
        > obtain
        > > > all keys
        > > > from the variable `echohash' and thus use loops to
        > extract them.
        > > >
        > > > A quick hint would be much appreciated.
        > > >
        > > > Thank you Paul. Great work!!!
        > > >
        > > > Gusti Seregeg.
        > > > Melbourne.
        > > >
        > > >
        > > > ------------------------------------
        > > > ' -- SOAP::Lite -- soaplite.com -- Copyright (C) 2001 Paul
        > > > Kulchenko --
        > > >
        > > > ' Connect to remote SOAP server
        > > >
        > > > Set soaplite = CreateObject("SOAP.Lite")
        > > > ' values can be stored in hash using "hash" method
        > > > Set subhash = soaplite.hash("key_c", "Value C")
        > > > Set hash = soaplite.hash("key_a", "Value A", "key_b", subhash)
        > > > ' or can be assigned directly
        > > > hash.key_b.key_d = "Value D"
        > > >
        > > > Set echohash = soaplite.new( _
        > > > "proxy", "http://services.soaplite.com/echo.cgi", _
        > > > "uri", "http://namespaces.soaplite.com/Echo" _
        > > > ).echo(hash).result
        > > >
        > > > MsgBox "key_a: " & echohash.key_a & chr(13) & _
        > > > "key_b+key_c: " & echohash.key_b.key_c & chr(13) & _
        > > > "key_b+key_d: " & echohash.key_b.key_d
        > > >
        > > >
        > > >
        > > >
        > > >
        > >
        > >
        > > __________________________________________________
        > > Do you Yahoo!?
        > > Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
        > > http://mailplus.yahoo.com
        >
      • gusti64 <gusti.seregeg@piotech.com.au>
        Thanks again for the speedy reply Paul. As I am getting deeper into this COM interface, there are more things I discovered and learnt. Now I am puzzled with
        Message 3 of 3 , Dec 22, 2002
          Thanks again for the speedy reply Paul.

          As I am getting deeper into this COM interface, there are more
          things I discovered and learnt. Now I am puzzled with the
          difference returned from Perl and COM versions for the same call.

          In Perl:
          @arr= $som->valueof ( "//Result" )

          returns array of hashes, which is what I expected. But

          In VB:
          Set arr= som.List.valueof ( "//Result" )

          returns array of scalars (Variant/Error). Did I miss anything here?

          Thanks.
          Gusti.
        Your message has been successfully submitted and would be delivered to recipients shortly.