Oxygen Basic

Information => Development => Topic started by: Brian Alvarez on October 11, 2020, 05:23:16 AM

Title: Functions that return arrays...
Post by: Brian Alvarez on October 11, 2020, 05:23:16 AM

 This is very interesting. I just implemented for the Oxygen compilations the feature from the attached screenshot. Functions that return arrays.
I still havent uploaded this feature, but i will as soon as i finish doing some tests for the rest of the platforms (PHP, Android, PowerBASIC etc.)

 Basically you can use the FUNCTION reserved word as an array (you can even pass if as a module parameter to other SUB's FUNCTION's etc..)
You can still use the function recursively by using its name.

 I implemented this because i am working on something very exciting for Android and i wanted it to be clearer, but i think it is a nice feature worthty
to be supported on all target platforms, specially because it is quite common on some of them, like PHP and Javascript.




Title: Re: Functions that return arrays...
Post by: Brian Alvarez on October 11, 2020, 02:10:46 PM

This now appears to compile fine for PowerBASIC and Oxygen. :)
Title: Re: Functions that return arrays...
Post by: JRS on October 11, 2020, 03:23:08 PM
How do you free the array resources used?
Title: Re: Functions that return arrays...
Post by: Brian Alvarez on October 11, 2020, 04:53:14 PM
 My code frees the array to return an empty array (if no resizing during the execution of the array funcion) and also
Oxygen frees the resources when exiting the module it is invoked in. No resource leaks as far as i know. :)

 By the way it now works also for PHP. Now working on the Java version...
Title: Re: Functions that return arrays...
Post by: JRS on October 11, 2020, 05:13:36 PM
Brian,

I'm looking for a compiler that supports both COM/OLE automation and ODBC. Thread support would be a plus. At this point ScriptBasic fills my requirements and if I need a speed boost I create a C extension module.

I couldn't be happier with my VB6 COM form DLLs that call back to Scriptbasic for event processing. Plus I get to define my own custom form related methods.

BASIC - A language that only exposes syntacily what is needed to accomplish a task.
Title: Re: Functions that return arrays...
Post by: Brian Alvarez on October 11, 2020, 05:55:56 PM
PluriBASIC has native database support, but no COM yet. Sorry.
Title: Re: Functions that return arrays...
Post by: JRS on October 11, 2020, 06:59:01 PM
I was surprised how well PHP COM/OLE automation works and it's a fast interpreter. I would give my VB6 forms a try with it if I could figure out how to callback to a PHP function.

ScriptBasic's extension API and variant type variables have kept me hooked on the language for over 15 years.
Title: Re: Functions that return arrays...
Post by: Brian Alvarez on October 12, 2020, 12:32:59 PM

Tackled this feature also for Java...  ;D This has been the hardest one.
Title: Re: Functions that return arrays...
Post by: JRS on October 12, 2020, 01:03:54 PM
Does your BASIC compile to C?
Title: Re: Functions that return arrays...
Post by: Brian Alvarez on October 12, 2020, 02:13:12 PM

Yes. But it needs a lot of work that anybody besides me can do, if you want to take on the task of creating the stock functions, be my guest.
Title: Re: Functions that return arrays...
Post by: Brian Alvarez on October 12, 2020, 02:29:16 PM

 John, Besides Android applications, PluriBASIC also generates code for JAR files. Java supports
COM automation via an external library... im not sure but maybe you can work it out?

https://stackoverflow.com/questions/6679810/is-there-ole-automation-in-java
Title: Re: Functions that return arrays...
Post by: JRS on October 13, 2020, 07:48:07 AM
The issue with COM is I need events to callback to its host. PHP would be great if there was a way to call functions.
Title: Re: Functions that return arrays...
Post by: JRS on October 13, 2020, 06:33:10 PM
Are you planning to do anything with associative arrays? (or a mix of both)

Code: Script BASIC
  1. something{"stupid"}[1000000] = TRUE
  2.  
  3. PRINT something{"stupid"}[1000000], "\n"
  4. PRINT LBOUND(something{"stupid"}), "\n"
  5. PRINT UBOUND(something{"stupid"}), "\n"
  6.  


C:\ScriptBASIC\examples>sbc dumb.sb
-1
1000000
1000000

C:\ScriptBASIC\examples>

Title: Re: Functions that return arrays...
Post by: Brian Alvarez on October 14, 2020, 08:43:49 AM

Im not sure, but i think i already implemented associative arrays. I havent needed them so far, i will check later.
Title: Re: Functions that return arrays...
Post by: JRS on October 14, 2020, 09:02:25 AM
Very handy as a key - value (hash) table.