Date: prev next · Thread: first prev next last
2018 Archives by date, by thread · List index


Hi Patrick,

Le 06/01/2018 à 10:58, Patrick Gelin a écrit :

Below is a complet macro to manage Vectors of variants (With french
coments) . I've got a problem with unitary test (Cf. Sub Main) because
call to procedure 'v.Ajouter(duolet)' use always passage by reference
instead of a passage by value (ByVal) ! For all that, I delicately
manage a passage by value in my function...

I tested with a call to New operator in order to build specifics
instances at each call, like this :

    duolet = new __TDuolet
    duolet.key = "MONTAGNE"
    duolet.Item = 3
    v.Ajouter(duolet)

And it's fine, the duolet variable is a new one instance. But I don't
want the caller do all this stuff. I would like easier way to do ...


This
    v.Ajouter(ByVal duolet)
won't do. The ByVal specifier is only present at the declaration level, not the calling one.


You could just add a CreateDuolet() function to create the Duolets, like this :

Function CreateDuolet(ByRef pKey As String, pItem As Variant) As __TDuolet

        Dim MyDuolet As __TDuolet

        MyDuolet.key = pKey
        MyDuolet.item = pItem

        CreateDuolet = MyDuolet

End Function

(note : this function is not a class member)

Then, the caller has just to specify:

duolet = CreateDuolet("MONTAGNE", 3)
v.Ajouter(duolet)

or you might also simply call
v.Ajouter(CreateDuolet("MONTAGNE", 3))


BTW, I've noticed some glitches elsewhere, eg: in the _Expend() method, you've declared isPresserved as Optional but never test for its presence or not in the method body. This might lead to strange results, don't you think?
[BTW, BTW, shouldn't the method be called "_Expand" instead of "_Expend"?]


HTH,
--
Jean-Francois Nifenecker, Bordeaux


--
To unsubscribe e-mail to: users+unsubscribe@global.libreoffice.org
Problems? https://www.libreoffice.org/get-help/mailing-lists/how-to-unsubscribe/
Posting guidelines + more: https://wiki.documentfoundation.org/Netiquette
List archive: https://listarchives.libreoffice.org/global/users/
All messages sent to this list will be publicly archived and cannot be deleted

Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.