Author Topic: Scriptbasic Build Linux  (Read 994 times)

Online AIR

  • RETIRED
  • BASIC Developer
  • Posts: 409
Re: Scriptbasic Build Linux
« Reply #120 on: December 01, 2018, 12:53:59 PM »
There's nothing stopping YOU from implementing this....

Offline John

  • Forum Support / SB Dev
  • Posts: 2191
    • ScriptBasic Open Source Project
Re: Scriptbasic Build Linux
« Reply #121 on: December 01, 2018, 01:02:51 PM »
Sure there is.

Lack of skill level with bash shell scripting. I've always been envious of both Peter's shell scripting skills. On my TODO list when time permits.

Online AIR

  • RETIRED
  • BASIC Developer
  • Posts: 409
Re: Scriptbasic Build Linux
« Reply #122 on: December 01, 2018, 01:14:27 PM »
Sure there is.

Lack of skill level with bash shell scripting. I've always been envious of both Peter's shell scripting skills. On my TODO list when time permits.

I'm sorry, but that's a B.S. excuse.  You're not the only one who has to manage their time.

Offline John

  • Forum Support / SB Dev
  • Posts: 2191
    • ScriptBasic Open Source Project
Re: Scriptbasic Build Linux
« Reply #123 on: December 01, 2018, 01:23:12 PM »
I'm good where you left things. My focus right now is getting the addition extension modules in a new repo as well as sift through all the examples and build a repo for them as well. The html docs also need to be converted to markdown and pushed to the project sandbox wiki.

I'm still maintaining the Windows version and need to get it compliant with your source tree.

BETA
« Last Edit: December 01, 2018, 04:08:19 PM by John »

Online AIR

  • RETIRED
  • BASIC Developer
  • Posts: 409
Re: Scriptbasic Build Linux
« Reply #124 on: December 01, 2018, 02:10:35 PM »
The html docs also need to be converted to markdown a pushed to the project sandbox wiki.

Don't you already have the User Guide on the scriptbasic.org wiki?  It's a start....You could use MediaWiki to Markdown to convert.

Offline John

  • Forum Support / SB Dev
  • Posts: 2191
    • ScriptBasic Open Source Project
Re: Scriptbasic Build Linux
« Reply #125 on: December 01, 2018, 02:49:17 PM »
It should get the docs in better shape than they are now. The current docs make SB look aged.
« Last Edit: December 01, 2018, 03:56:27 PM by John »

Online AIR

  • RETIRED
  • BASIC Developer
  • Posts: 409
Re: Scriptbasic Build Linux
« Reply #126 on: December 01, 2018, 10:14:08 PM »
I've been wondering how to return an Associative Array from a module.

I looked at the sqlite module, and threw together a quick test:

Code: C
  1. besFUNCTION(test)
  2.   pModuleObject p;
  3.   VARIABLE x;
  4.   LEFTVALUE Lval;
  5.   unsigned long __refcount_;
  6.   char key[50], value[50];
  7.   int arraySize = 5;
  8.  
  9.   p = (pModuleObject)besMODULEPOINTER;
  10.  
  11.   x = besARGUMENT(1);
  12.  
  13.  
  14.   besLEFTVALUE(x,Lval);
  15.   besRELEASE(*Lval);
  16.   *Lval = NULL;
  17.  
  18.   *Lval = besNEWARRAY(0,arraySize);
  19.   if( *Lval == NULL )return COMMAND_ERROR_MEMORY_LOW;
  20.  
  21.  
  22.   for( int i= 0 ; i < arraySize-1 ; i++ ) {
  23.     sprintf(key,"%s%d","Hello",i);
  24.     sprintf(value,"%s #%d","World",i);
  25.     // value = "World";
  26.     ARRAYVALUE(*Lval,2*i) = besNEWSTRING(strlen(key));
  27.     if( ARRAYVALUE(*Lval,2*i) == NULL )return COMMAND_ERROR_MEMORY_LOW;
  28.     memcpy(STRINGVALUE(ARRAYVALUE(*Lval,2*i)),key, strlen(key));
  29.    
  30.     ARRAYVALUE(*Lval,2*i+1) = besNEWSTRING(strlen(value));
  31.     if( ARRAYVALUE(*Lval,2*i+1) == NULL )return COMMAND_ERROR_MEMORY_LOW;
  32.     memcpy(STRINGVALUE(ARRAYVALUE(*Lval,2*i+1)),value,strlen(value));
  33.   }
  34.  
  35.  
  36.   besALLOC_RETURN_LONG;
  37.   LONGVALUE(besRETURNVALUE) = -1;
  38. besEND

Using this:

Code: Script BASIC
  1. include blah.bas
  2.  
  3. blah::test(arr)
  4.  
  5. for x = 0 to 3
  6.   print arr{"Hello"&str(x)},"\n"
  7.  
  8. next

Resulted in this:
riveraa@nas:~/Projects/sb$ sb64/sb.sh testblah.bas
World #0
World #1
World #2
undef
riveraa@nas:~/Projects/sb$


Now, the reason that I wanted to do this is because the extension module documentation is seriously lacking.  I'm thinking of documenting how I go about putting a module together, and the particular c code I'm thinking of using would benefit from being able to provide an AA from a usage perspective.

The key is passing an SB variable to the function, which is configured as an AA by the module, which is then usable in the main script.

AIR.

Offline John

  • Forum Support / SB Dev
  • Posts: 2191
    • ScriptBasic Open Source Project
Re: Scriptbasic Build Linux
« Reply #127 on: December 01, 2018, 10:54:24 PM »
If you want to see a good example of internal SB array handling,  check out Dave's IDE/Debugger for Windows.



& Turns the expression to concatenation of strings

+ Does numeric addition of the variables

Code: Script BASIC
  1. print arr{"Hello"&str(x)},"\n"
  2.  

Very rarely do you need to use STR or VAL with SB variant variables. This works as well.

Code: Script BASIC
  1. print arr{"Hello"&x},"\n"
  2.  

Code: Script BASIC
  1. PRINT "12" / "2", "\n"
  2.  


jrs@jrs-laptop:~/sb/examples/test$ scriba strdiv.sb
6
jrs@jrs-laptop:~/sb/examples/test$



It dawned on me the HEB is very close to a PHP like environment.
« Last Edit: December 02, 2018, 04:12:47 PM by John »

Offline John

  • Forum Support / SB Dev
  • Posts: 2191
    • ScriptBasic Open Source Project
Re: Scriptbasic Build Linux
« Reply #128 on: December 02, 2018, 05:26:04 PM »
One of my goals for Script BASIC is to get the threaded proxy application server (sbhttpd) working with web sockets. The plan is to use SBT to create free running threads to handle the web socket tasks. They will terminate when the client bowser disconnects. In theory it should work. MT is the inter-thread communications link. Node.js alternative.

« Last Edit: December 02, 2018, 06:31:56 PM by John »