Page 1 of 2 12 LastLast
Results 1 to 10 of 15

Thread: Oxygen Flexi Parameter Passing

  1. #1

    Oxygen Flexi Parameter Passing


    Flexible Parameter Passing

    This feature enables functions subs and methods to specify default values for their parameters. If you use HTML you will be familiar with tags and their optional attributes. This does the same for BASIC functions.

    All you have to do is assign a value to each parameter in the function prototype. For example:

    function f( byval a=20 as long, byval b=22 as long ) as long
    function=a+b
    end function


    then you can use this function in the normal way or assign values to specific parameters replacing their default values.

    f(b=4) 'DEFAULT 'A' VALUE IS USED

    You can assign values to any or all of the parameters or none, and the parameters may be given in any order.


    Get the latest Oxygen here:

    http://community.thinbasic.com/index.php?topic=2517


    [code=thinbasic]

    '===================
    'FLEXI PARAM PASSING
    '===================

    uses "oxygen"
    dim src as string

    src = "

    basic

    cr=chr 13
    so="FLEXIBLE PARAMETER PASSING FOR FUNCTION f()" cr cr

    '---------
    function f
    '=========
    (
    byval a=1 as long, 'DEFAULT VALUE 1
    byval b=2 as long 'DEFAULT VALUE 2
    )
    as long
    '
    so+= "a=" a " b=" b cr
    '
    return a+b
    '
    end function


    f 'ALL DEFAULT VALUES ARE USED
    f() 'ALL DEFAULT VALUES ARE USED
    f(a=3) 'DEFAULT B VALUE USED
    f(b=4) 'DEFAULT A VALUE IS USED
    f(a=5,b=6) 'NO DEFAULT VALUES ARE USED
    f(b=6,a=5) 'AND PARAMS CAN BE SPECIFIED IN ANY ORDER

    print so

    "



    o2_asmo src

    'msgbox 0, o2_prep src
    if len(o2_error) then
    msgbox 0, o2_error : stop
    end if
    o2_exec

    [/code]

  2. #2
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    7,128
    Rep Power
    732

    Re: Oxygen Flexi Parameter Passing

    Very nice Charles,

    I am happy to see you continuing the Oxygen project!
    Example worked great here, only minor trouble was NOD32 thinks there is trojan in the DLL, but I presume it is another false positive, as it was not precisely identified.


    Petr
    Learn 3D graphics with ThinBASIC, learn TBGL!
    Windows 10 64bit - Intel Core i5-3350P @ 3.1GHz - 16 GB RAM - NVIDIA GeForce GTX 1050 Ti 4GB

  3. #3

    Re: Oxygen Flexi Parameter Passing


    Hi Petr,

    I think the core functionality of the language is nearly complete now. There are still C header trials, Linux and 64 bit compiling to go through, but these will require only minor additions to the command set.

    Not sure what to do about capricious antivirus software since the DLL internals are bound to change with every release. I hope you were able to tell it to calm down!

    Charles

  4. #4
    thinBasic MVPs danbaron's Avatar
    Join Date
    Jan 2010
    Location
    California
    Posts
    1,378
    Rep Power
    152

    Re: Oxygen Flexi Parameter Passing

    [font=courier new]I downloaded the latest Oxygen zip file.

    I extracted it into, "c:\thinBasic\SDK\".

    Then, I had two Oxygen folders.

    The old one, "thinBasic_o2h", and the new one, "thinBasic_Oxygen".

    I deleted "thinBasic_o2h".

    I ran two programs, "DO NOTHING", and "HELLO".

    Both worked.

    Inside the folder, "thinBasic_Oxygen", is another folder, "Examples".

    Inside the folder, "Examples", there are 19 more folders, with lots of examples on various topics.

    My first impression is that the capabilities of Oxygen can be determined, by running the examples.

    (Now must hurry for train.)


    Dan :P


    "You can't cheat an honest man. Never give a sucker an even break, or smarten up a chump." - W.C.Fields

  5. #5

    Re: Oxygen Flexi Parameter Passing


    Hi, Dan,

    I face the task of writing a manual with trepidation, so I hope the examples will suffice meanwhile.

    The simplest way to deploy the new thinBasic_Oxygen.dll is to transfer it into \thinBasic\Lib overwriting the previous version.

    Then the new examples will work from any folder on your PC.

    Whenever a thinBasic Beta is released, Eros incorporates the latest version of Oxygen in the thinBasic\lib folder , and the examples appear in thinBasic\SampleScripts\Oxygen.

    One warning: I have removed a few earlier examples which have become obsolete or broken - these may linger in your thinBasic\SampleScripts folder from previous installations.

    Charles


  6. #6
    thinBasic MVPs danbaron's Avatar
    Join Date
    Jan 2010
    Location
    California
    Posts
    1,378
    Rep Power
    152

    Re: Oxygen Flexi Parameter Passing

    [font=courier new][size=8pt]You've already got a ".chm" file, in, "\thinBasic\help". So, you have the format.

    I think, the best way is, don't try to make it good. Just write anything you feel like.

    Bit by bit, you can add little topics. Release it, and modify it as you go along. It doesn't have to be complete. Don't
    wait for the super-royal-grand release.

    When someone writes, it's bad if he becomes too self-conscious. Doesn't writer's block appear, when the creator feels
    too much pressure, whether internal or external? Who could write if he feels he has to live up to Shakespeare?

    Once begun, it's half done.

    (On the other hand, you have supplied many samples. I also procrastinate when I have doubt.)


    Dan :P
    "You can't cheat an honest man. Never give a sucker an even break, or smarten up a chump." - W.C.Fields

  7. #7

    Re: Oxygen Flexi Parameter Passing


    Good advice. Thanks Dan

    thinBasic O2 made its first appearance as a machine code module here

    http://community.thinbasic.com/index.php?board=149.0.

    We have come quite a long way since then.

    Charles

  8. #8
    thinBasic MVPs danbaron's Avatar
    Join Date
    Jan 2010
    Location
    California
    Posts
    1,378
    Rep Power
    152

    Re: Oxygen Flexi Parameter Passing

    [font=courier new][size=8pt]I only understand a tiny bit of what Oxygen does.

    I don't know how you learned all this stuff.

    Since I know so little, I'm not able to guess its future possibilities.

    For instance, I cannot estimate the probability that you will be able to combine it with DNA strands.

    If I'm correct, it has only existed for approximately two years; so who knows?

    I hope you are careful not to let anything dangerous escape from the laboratory.


    Dan :P
    "You can't cheat an honest man. Never give a sucker an even break, or smarten up a chump." - W.C.Fields

  9. #9

    Re: Oxygen Flexi Parameter Passing

    thanks Charles for the oxygen
    i have just discovered the example in the new posted oxygen file:
    thinBasic_Oxygen\Examples\DLLandEXE\ConsoleCompilerMaker
    i am sure dan will find this great for his research on mathematics:
    as an example the following text file fibo.bas: extracted from Eros example http://community.thinbasic.com/index.php?topic=2649.0
    [code=thinbasic]#file "fibo.exe"
    FUNCTION fibonacci(byval sequence as Dword) as Dword
    IF sequence < 2 THEN
    FUNCTION = sequence
    Else FUNCTION = fibonacci(sequence - 1) + fibonacci(sequence - 2)
    END IF
    END FUNCTION
    print fibonacci(40)
    terminate[/code]

    to compile this to a very small exe program type from console:
    co2 fibo.bas

    then run the exe fibo.exe it will give you 102334155
    four questions:
    1-how to print to a console instead a msgbox?
    2-how to make the above program to a dll to be called from other programming language such as thinbasic or vb6 as an example ?
    3-is it possible to attach an icon to the generated exe ?
    4-is it neccessary to use terminate, the code can run without using terminate but does it have unseen function?
    thanks

  10. #10

    Re: Oxygen Flexi Parameter Passing

    in addition to my above message using fibonacci(60) will not issue a message , and i have noticed that the cpu temperature increased very slowly from 40 centigrade to critical 55, in the task manager the numbers beside fibo.exe in the processes tab is as follows : fibo.exe 50 1320k,
    when i terminate the fibo.exe the temperature return normal.

Page 1 of 2 12 LastLast

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
  •