Announcement

Collapse
No announcement yet.

variant array byref ?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Michael Mattias
    replied
    > just wanted to return a PB variant array and not a variant having a safearray.

    FWIW, Sql/Server via ADO returns a safearray as a variant if the column type is 'nvarchar' ...... so you'd probably want to know how to handle that anyway.

    Here's how I did it, YMMV: Generic 'ADO' Connection and Query Tester (CC 5+/Win 9+) 11-02-08

    MCM

    Leave a comment:


  • Edwin Knoppert
    replied
    > if a PB array is that with which you wish to work in your 'method code.'

    I obtain data from Excel, not setting it.
    I just wanted to return a PB variant array and not a variant having a safearray.

    Case solved..

    Leave a comment:


  • Michael Mattias
    replied
    There are functions to convert safearrays into PB arrays, if a PB array is that with which you wish to work in your 'method code.'

    And I cannot imagine any "Win/32 development product supporting an object-oriented model which cannot pass a safearray parameter to a Component Object Model method."

    Leave a comment:


  • Edwin Knoppert
    replied
    I keep forgetting

    Leave a comment:


  • Michael Mattias
    replied
    >I wonder why passing an array is that problematic

    Simple.

    Only a PowerBASIC-created client could possibly pass a "PB Array", so your class would be unusable by the 14,653,904 programmers who use anything but PB.

    MCM

    Leave a comment:


  • Edwin Knoppert
    replied
    Originally posted by Michael Mattias View Post
    It was a thought.

    So I guess it's just pass the safearray "as variant" (not a PB array of variants) and deal with it in your code.
    Yes, i already did that, but it's not that ideal.
    It's a solution though.
    I wonder why passing an array is that problematic.

    Leave a comment:


  • Michael Mattias
    replied
    It was a thought.

    So I guess it's just pass the safearray "as variant" (not a PB array of variants) and deal with it in your code.

    Leave a comment:


  • José Roca
    replied
    Method ToArray( ByRef vArray() As Variant ) As Long
    You can't pass arrays to a method this way. COM knows nothing about PB descriptor arrays. Pass a pointer instead or a safe array.

    Leave a comment:


  • Michael Mattias
    replied
    If your param is one array, then it's "byref varray AS VARIANT" and vArray has been assigned an array, as in ..
    Code:
     vArray =      foo()  [AS datatype]
    BUt if you want to pass an array of variants (different) and the compiler will not accept, yout can try...
    Code:
     
    Method Foo  ( vArray() AS VARIANTAPI)
    .. after doing whatever you have to do to set that up.

    One safearray param = "varname [no parens] AS VARIANT "

    MCM

    Leave a comment:


  • Edwin Knoppert
    started a topic variant array byref ?

    variant array byref ?

    This is what i want to use and due that this is a method macro's for workaround are not suitable.
    Code:
    Method ToArray( ByRef vArray() As Variant ) As Long
    
        Redim vArray( 0 to 100 )
    
        vArray( 0 ) = 123
    
    End Method
    In fact the variant will be populated with a safearray obtained via Excel.

    I get this error:

    PowerBASIC for Windows
    PB/Win Version 9.01
    Copyright (c) 1996-2009 PowerBasic Inc.
    Venice, Florida USA
    All Rights Reserved

    (311:041): Scalar variable expected
Working...
X