Results 1 to 2 of 2

Thread: CHOOSE and CALL used to do the same thing

  1. #1
    Member marcuslee's Avatar
    Join Date
    Sep 2008
    Location
    Kansas, USA
    Age
    42
    Posts
    222
    Rep Power
    38

    CHOOSE and CALL used to do the same thing

    This is an offshoot of this thread. So, you might want to read that one first.

    I didn't know where to put this message since I'm not suggesting to put this in the help file. It is simply interesting that you can accomplish the same thing two different ways. There are always options.

    The CHOOSE version:

    [code=thinbasic]
    USES "MATH"

    DIM RetNumber as DOUBLE
    DIM Index as LONG

    For Index = 1 TO 3
    RetNumber = Choose (Index, Fun1, Fun2, Fun3)
    msgbox 0,RetNumber
    Next

    Function Fun1()
    Function = PI
    End Function

    Function Fun2()
    Function = PI*2
    End Function

    Function Fun3()
    Function = PI*3
    End Function
    [/code]

    And, the CALL version:

    [code=thinbasic]
    'Call functions in a loop

    USES "Math"

    DIM Index AS LONG
    DIM RetNum AS DOUBLE

    FOR Index = 1 TO 3
    CALL "MyFunction" + Index( ) TO RetNum
    MSGBOX 0, RetNum
    NEXT

    FUNCTION MyFunction1( )
    FUNCTION = PI
    END FUNCTION

    FUNCTION MyFunction2( )
    FUNCTION = PI * 2
    END FUNCTION

    FUNCTION MyFunction3( )
    FUNCTION = PI * 3
    END FUNCTION
    [/code]


    Mark

  2. #2

    Re: CHOOSE and CALL used to do the same thing

    That is one of the huge advantages of thinBasic. Flexibility!

Similar Threads

  1. Help file: Choose and Choose$ issues
    By Petr Schreiber in forum Fixed or cleared errors in help material
    Replies: 4
    Last Post: 12-08-2011, 18:03

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
  •