Results 1 to 3 of 3

Thread: variant parameter

  1. #1
    thinBasic MVPs kryton9's Avatar
    Join Date
    Nov 2006
    Location
    Naples, Florida & Duluth, Georgia
    Age
    67
    Posts
    3,869
    Rep Power
    404

    variant parameter


    When calling a function having parameters of type VARIANT passes BYVAL, passed numeric values can be typed. An example can clarify.

    If you have a function like:



    Function MyFunction(ByVal v1 As Variant) As Long

    '...

    End Function



    you can call it passing any value plus a type in case of numeric. For example, the following are all accepted ways:



    MyFunction("Whatever string")

    MyFunction(123)

    MyFunction(123 As QUAD)

    MyFunction(1234.67

    MyFunction(1234.678 As Single)

    MyFunction(12345.67898889 As Double)



    In this way,
    This is really a neat feature. Can we do something similar in powerBasic? As far as I can tell we can only use variant with com objects?
    Acer Notebook: Win 10 Home 64 Bit, Core i7-4702MQ @ 2.2Ghz, 12 GB RAM, nVidia GTX 760M and Intel HD 4600
    Raspberry Pi 3: Raspbian OS use for Home Samba Server and Test HTTP Server

  2. #2
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    57
    Posts
    8,782
    Rep Power
    10

    Re: variant parameter

    Well,

    PB introduced VARIANT for a specific purpose that was to be used for COM interfaces. But you can use them in many different ways as long as you know what you are doing. Many languages uses variants but they hide some of the possible problems inside the language engine.

    PB has ... AS clause in assign statement so you can type something like:
    DIM V1 AS VARIANT
    V1 = 12345.678 AS DOUBLE
    But as does not let you indicate it during function parameter passing.

    One of the advantages of having a language (thinBasic) is the possibility to add the features we like

    Ciao
    Eros
    www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
    Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000

  3. #3
    thinBasic MVPs kryton9's Avatar
    Join Date
    Nov 2006
    Location
    Naples, Florida & Duluth, Georgia
    Age
    67
    Posts
    3,869
    Rep Power
    404

    Re: variant parameter

    One of the advantages of having a language (thinBasic) is the possibility to add the features we like
    That is the truth Eros, so glad you are making such a command and feature rich language, the way that a BASIC should be!
    Acer Notebook: Win 10 Home 64 Bit, Core i7-4702MQ @ 2.2Ghz, 12 GB RAM, nVidia GTX 760M and Intel HD 4600
    Raspberry Pi 3: Raspbian OS use for Home Samba Server and Test HTTP Server

Members who have read this thread: 0

There are no members to list at the moment.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •