Recent Posts

Pages: 1 [2] 3 4 ... 10
11
Scripting Languages / Re: SBOCX
« Last post by John on January 17, 2019, 07:48:54 PM »
Works great under Windows.

This is a quick proof of concept for the SBOCX control. Script BASIC would be loaded by the OCX and the worker script creates threads for object MODULEs. The main SB process can call functions/subs (METHODS) and access global variables not defined with the LOCAL keyword. (PROPERTIES)


This example is like doing a RUN in other interpretive BASIC languages. With SB you can load the script without running it, run it multiple times and clearing or leaving the variables as is with the next run command.

Code: Script BASIC
  1. ' SBOCX Proof of Concept
  2.  
  3. IMPORT sbt.sbi
  4.  
  5. sb_code = """
  6. MODULE JRS
  7. FUNCTION prtvars(a, b, c)
  8.  PRINT a,"\\n"
  9.  PRINT FORMAT("%g\\n", b)
  10.  PRINT c,"\\n"
  11.  prtvars = "Function Return"
  12. END FUNCTION
  13.  
  14. a = 0
  15. b = 0
  16. c = ""
  17.  
  18. END MODULE
  19. """
  20.  
  21. sb = SB_New()
  22. SB_Configure sb, "C:/Windows/SCRIBA.INI"
  23. SB_Loadstr sb, sb_code
  24. SB_NoRun sb
  25. ' Call function before running script
  26. funcrtn = SB_CallSubArgs(sb,"jrs::prtvars", 123, 1.23, "One, Two, Three")
  27. PRINT funcrtn,"\n"
  28. ' Run script initializing globals
  29. SB_Run sb, ""
  30. ' Assign variables values
  31. SB_SetInt sb, "jrs::a", 321
  32. SB_SetDbl sb, "jrs::b", 32.1
  33. SB_SetStr sb, "jrs::c", "Three,Two,One"
  34. ' Call function again with variables assigned in the previous step
  35. SB_CallSubArgs sb, "jrs::prtvars", _
  36.           SB_GetVar(sb, "jrs::a"), _
  37.           SB_GetVar(sb, "jrs::b"), _
  38.           SB_GetVar(sb, "jrs::c")
  39. SB_Destroy sb
  40.  


C:\ScriptBASIC\examples>scriba sbt_module.sb
123
1.23
One, Two, Three
Function Return
321
32.1
Three,Two,One

C:\ScriptBASIC\examples>



This example is running the script as a self running thread. The main SB process can still make calls and return global variables like the run example above. The MT extension module can be used to post status info to R/W lockable shared memory space.

Code: Script BASIC
  1. IMPORT sbt.sbi
  2.  
  3. sb = SB_ThreadStart("tcall.sb",undef,"C:\\Windows\\SCRIBA.INI")
  4. SB_SetInt sb, "main::a", 123
  5. SB_SetDbl sb, "main::b", 1.23
  6. SB_SetStr sb, "main::c", "One, Two, Three"
  7. funcrtn = SB_CallSubArgs(sb, "main::prtvars", _
  8.           SB_GetVar(sb, "main::a"), _
  9.           SB_GetVar(sb, "main::b"), _
  10.           SB_GetVar(sb, "main::c"))      
  11. PRINT funcrtn,"\n"
  12. SB_Destroy sb
  13.  

Code: Script BASIC
  1. FUNCTION prtvars(a, b, c)    
  2.   PRINT a,"\n"              
  3.   PRINT FORMAT("%g\n", b)  
  4.   PRINT c,"\n"              
  5.   prtvars = "Function Return"
  6. END FUNCTION                
  7.                              
  8. a = 0                        
  9. b = 0                        
  10. c = ""                      
  11.  


C:\ScriptBASIC\examples>scriba t_thread.sb
123
1.23
One, Two, Three
Function Return

C:\ScriptBASIC\examples>


12
Scripting Languages / Re: SBOCX
« Last post by John on January 17, 2019, 07:23:20 PM »
For some reason my SBT extension module is segment faulting under Ubuntu 18.10. I rebuilt the extension module (no errors) and it still does the same.  :-[

I'll give it a try under Windows 7 which is where is going to run anyway. I confused why my Linux version of SBT no long works.
13
Scripting Languages / Re: SBOCX
« Last post by John on January 17, 2019, 09:08:05 AM »
Thanks Mike!

I'll try putting a proof of concept together and get a copy to you. I think the idea has a lot of merit.

MT will be the shared memory means of communication. SB as a COM OLE OCX running in a thread safe model could make the language more attractive under Windows 32 bit.

I will clean  up this thread today.
14
Scripting Languages / Re: SBOCX
« Last post by Mike Lobanovsky on January 17, 2019, 02:24:47 AM »
For all intents and purposes, an OCX is just a DLL which means its single disk copy can be reused concurrently by an infinite number of memory images in an infinite number of processes, each image for its own purpose. However that also means that interprocess communication restrictions apply.

A COM-aware DLL (OCX) is an inproc (in-process) server, and though it is theoretically possible to set up a common "shared" memory store for numeric values through the DLL, the trick won't work for handles or pointers to objects, UDTs, strings, functions, etc. because each process has its own address space whose pointer values are meaningless for another concurrent process. Thus generally speaking, you can't use the DLL for interprocess communication.

OTOH if a call to an SB callback is programmed within the OCX as a means to implement some of its particular functionalities, then the scheme will most likely work if SB is compiled as a DLL as well. It will then be mapped into the memory space of the process that's calling the "parent" OCX.

(Why not use an SB specific thread for such a question, John?)
15
Scripting Languages / Re: Script BASIC Windows 64
« Last post by John on January 16, 2019, 10:13:50 PM »
Understand.

What compiler method would you recommend for SB Win64?
16
Scripting Languages / Re: Script BASIC Windows 64
« Last post by AIR on January 16, 2019, 10:02:47 PM »
Sorry, no time.
17
Scripting Languages / SBOCX
« Last post by John on January 16, 2019, 09:37:53 PM »
Mike,

If I load an OCX with a SB script, can another OLE process connect to the OCX and have it callback to a SB function. Nothing visuall, just a OLE SB interface.

I don't see this much different than Sage's PVXCOM OLE interface to the language.

The cool part is SB could run out of a DLL. (libscriba) MODULEs could be objects created as SBT threads.
18
Open Forum / Re: BASIC
« Last post by John on January 16, 2019, 07:02:44 PM »
Quote
I'm just trolling.

We sure could use you coding instead. ;D
19
Open Forum / Re: BASIC
« Last post by Mike Lobanovsky on January 16, 2019, 01:16:34 PM »
While they post on their Android Linux or Apple Unix phones to a website running the same.

Well, they must have something to do some sanitation for them after all, mustn't they? ;D

( Take it easy man, I'm just trolling. :) )
20
Scripting Languages / Script BASIC Windows 64
« Last post by John on January 16, 2019, 12:50:34 PM »
I would like to get a Window 64 bit distribution going and in the sandbox.

AIR,

Would you have time to seed that effort with an initial build?

What is the best development enviornment to use?
gcc
Peter's build system with VC?  - Windows SDK C++ compiler
Visual Studio Community Edition

Maybe have a branch for each compiler direction.

I would ike to see the Windows version be more of a community effort.

Pages: 1 [2] 3 4 ... 10