Author Topic: Functions that return arrays...  (Read 1440 times)

0 Members and 1 Guest are viewing this topic.

Brian Alvarez

  • Guest
Functions that return arrays...
« 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.





Brian Alvarez

  • Guest
Re: Functions that return arrays...
« Reply #1 on: October 11, 2020, 02:10:46 PM »

This now appears to compile fine for PowerBASIC and Oxygen. :)

JRS

  • Guest
Re: Functions that return arrays...
« Reply #2 on: October 11, 2020, 03:23:08 PM »
How do you free the array resources used?

Brian Alvarez

  • Guest
Re: Functions that return arrays...
« Reply #3 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...

JRS

  • Guest
Re: Functions that return arrays...
« Reply #4 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.
« Last Edit: October 11, 2020, 05:36:34 PM by John »

Brian Alvarez

  • Guest
Re: Functions that return arrays...
« Reply #5 on: October 11, 2020, 05:55:56 PM »
PluriBASIC has native database support, but no COM yet. Sorry.

JRS

  • Guest
Re: Functions that return arrays...
« Reply #6 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.
« Last Edit: October 11, 2020, 07:07:33 PM by John »

Brian Alvarez

  • Guest
Re: Functions that return arrays...
« Reply #7 on: October 12, 2020, 12:32:59 PM »

Tackled this feature also for Java...  ;D This has been the hardest one.

JRS

  • Guest
Re: Functions that return arrays...
« Reply #8 on: October 12, 2020, 01:03:54 PM »
Does your BASIC compile to C?

Brian Alvarez

  • Guest
Re: Functions that return arrays...
« Reply #9 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.

Brian Alvarez

  • Guest
Re: Functions that return arrays...
« Reply #10 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

JRS

  • Guest
Re: Functions that return arrays...
« Reply #11 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.

JRS

  • Guest
Re: Functions that return arrays...
« Reply #12 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>

« Last Edit: October 13, 2020, 06:43:31 PM by John »

Brian Alvarez

  • Guest
Re: Functions that return arrays...
« Reply #13 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.

JRS

  • Guest
Re: Functions that return arrays...
« Reply #14 on: October 14, 2020, 09:02:25 AM »
Very handy as a key - value (hash) table.