Mike is this what you are after.
Dim z As DWord z = Dothings(2,1) MsgBox 0, z Function Dothings(x As DWord, y As DWord) Return x+y End Function
I'm thinking of using ThinBasic as a front end Basic intrepreter
for GPIB instrument control -- just like the old Rocky Mountain Basic.
Anyway my question (suggestion) is as follows:
Is there anyway a user defined function can be called without having to preface it with CALL?
And can it assign the return value in the following way: y=sin(x)
- Mike Peralta
peralta_mike@hotmail.com
Mike is this what you are after.
Dim z As DWord z = Dothings(2,1) MsgBox 0, z Function Dothings(x As DWord, y As DWord) Return x+y End Function
Last edited by ErosOlmi; 18-03-2016 at 11:19.
Home Desktop : Windows 7 - Intel Pentium (D) - 3.0 Ghz - 2GB - Geforce 6800GS
Home Laptop : WinXP Pro SP3 - Intel Centrino Duo - 1.73 Ghz - 2 GB - Intel GMA 950
Home Laptop : Windows 10 - Intel(R) Core(TM) i5-4210U CPU @ 1.70GHz, 2401 Mhz, 2 Core(s), 4 Logical Processor(s) - 4 GB - Intel HD 4400
Work Desktop : Windows 10 - Intel I7 - 4 Ghz - 8GB - Quadro Fx 370
Thanks Michael,
That is what I needed.
- Mike
Hi Mike,
as Michael already replied, you can call sub and functions the way you like.
CALL statement it absolutely optional when calling a Sub or a function.
CALL statement can be handy when you need to call a function whose name is not know but you can compose it dynamically at runtime using a string expression.
Dim z As DWord Dim FunctionNumber As Long FunctionNumber = 1 '---Call a function name whose name is composed at runtime Call "Dothings" & Format$(FunctionNumber, "00") (2, 3) To z MsgBox 0, z Function Dothings01(x As DWord, y As DWord) Function = x + y End Function Function Dothings02(x As DWord, y As DWord) Function = x * y End Function
On returning a value from a function you can use different ways:
FUNCTION = <...value...>
RETURN <...value...>
NameOfTheFunction = <...value...>
Also remember you can pass parameters BYREF so changes to a parameter value will be applied to passed variable.Function Dothings(x As DWord, y As DWord) '---All thinBasic valid ways to return a value from a function Function = x + y '---Execution will continue to the next line Return x + y '---Execution of function will stop and value returned. Following line(s) will never be executed Dothings = x+y '---Execution will continue to the next line End Function
Last edited by ErosOlmi; 18-03-2016 at 11:20.
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
Thanks.
One of the primary goals in porting Rocky Mountain Basic (RMB) code to thinBasic is that any code (or as much as possible) of the RMB code works under thinBasic without any modification.
Over time this may mean some redundancy in thinBasic but hopefully this will not be too troublesome for the thinBasic developers. Ultimately (as much as possible) I would like to see the RMB language be a subset of the thinBasic language whereby any code in RMB can be run "as is" within thinBasic.
- Mike
If you drive me where I can get a RMB I can check syntax and see what I can do.
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
a commercial HTBasic provides the Rocky Mountain BASIC integrated program development environment including a syntax-sensitive, full screen editor and interactive execution and debugging statements.
http://www.htbasic.com/products/soft...c/development/
http://www.techsoft.de/documents/htbasic.html
demo download:
http://www.htbasic.com/index.asp 27 MB
Limitations of the Demo version:
- Save / store of program files not possible
- Demo quits after 30 minutes (can be restarted)
i am downloading now ( slow 512 KB/s)
Originally Posted by peralta_mike
This is definately something I would not like to see. If Eros wants to go that way then we can throw in some other Basic dialects. FreeBasic, BlitzBasic, DarkBasic, LibertyBasic. What the hell. Put it all in.
I'm with you Mike H. this is ThinBasic and not VB,Scriptbasic, Pascal,C if it was going to be compatible with anything then PowerBasic is the product of choice for obvious reasons.
Why have 10 different ways of doing the same thing
I think the interest HTbasic users has got something to do with the really poor support for customers of HTBasic i.e last update 2007 and I suspect Mike P is looking for an enviroment that is being developed, I dont want to speak for him I'm only guessing.
All that being said it is for Eros to decide its his baby.
Regards
Mike C
Home Desktop : Windows 7 - Intel Pentium (D) - 3.0 Ghz - 2GB - Geforce 6800GS
Home Laptop : WinXP Pro SP3 - Intel Centrino Duo - 1.73 Ghz - 2 GB - Intel GMA 950
Home Laptop : Windows 10 - Intel(R) Core(TM) i5-4210U CPU @ 1.70GHz, 2401 Mhz, 2 Core(s), 4 Logical Processor(s) - 4 GB - Intel HD 4400
Work Desktop : Windows 10 - Intel I7 - 4 Ghz - 8GB - Quadro Fx 370
Be sure I'm not going into RMB direction.
What I can do is to have more constructs without changing current syntax.
If this means changing current syntax, I will not add it.
If this means adding new control flow like the quite intuitive REPEAT ... UNTIL ... why not? It will not break any previous thinBasic compatibility and if not used will not change anything.
If this means just making a keyword optional (for example from SELECT CASE ... to SELECT [CASE] ...) than why not?
Haven't we added all C assignment statement (*=, -=, ...) and few month later PB developed them?
Haven't we added all UI controls specific keywords and again few month later PB developed most them?
All programming languages must evolve possibly not breaking compatibility with previous versions.
thinBasic evolved so much in recent years thanks to the requests all of you have asked. Why now we have to stop in this evolution?
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
Bookmarks