Recent Posts

Pages: 1 ... 6 7 [8] 9 10
71
ScriptBasic Blog / Re: ScriptBasic 3.0
« Last post by John on April 11, 2024, 11:21:07 PM »
I put a print statement in the SB_Configure function in the SBT module. It looks like the correct name is being passed. The print statement is just before I call the scriba_LoadConfiguration  function. I'm done for tonight and I'll look into this further tomorrow.

On 64-bit Windows, all pointer types are 8 bytes, twice the size on 32-bit Windows.


C:\ScriptBasic64\examples>scriba sbt_demo.sb
sb = 755889768
Config: C:/Windows/SCRIBA.INI

C:\ScriptBasic64\examples>

72
ScriptBasic Blog / Re: ScriptBasic 3.0
« Last post by John on April 11, 2024, 10:35:38 PM »
I think I'm getting closer to pinning down the problem. I added a SB_hello function to the extension module that doesn't require any arguments be passed. It runs a SB script that has the wrapped REPLACE() as a function. These are the same calls I'm making with the SBT API functions with argument passing not fixed code. So it seems something isn't working correctly passing arguments to the extension module.

Code: ScriptBasic
  1. IMPORT sbt.bas
  2.  
  3. SBT::SB_hello()
  4.  

Code: C
  1. besFUNCTION(SB_hello)
  2.   DIM pSbProgram AS pProgram;
  3.   DIM pSbData AS ArgData;
  4.   DIM unsigned long AS fnsn;
  5.   DIM SbData AS FunctionResult;
  6.   pProgram = scriba_new(malloc,free);
  7.   scriba_SetFileName(pProgram, "sbfunctions");
  8.   scriba_LoadSourceProgram(pProgram);
  9.   scriba_Run(pProgram, "");
  10.   ArgData = scriba_NewSbArgs(pProgram,"s s s i i", "Hello World", "Hello", "Goodbye", 1, 1);
  11.   fnsn = scriba_LookupFunctionByName(pProgram, "main::sb_replace");
  12.   scriba_CallArgEx(pProgram, fnsn, AT FunctionResult, 5, ArgData);
  13.   PRINT("%s\n", FunctionResult.v.s);
  14.   scriba_destroy(pProgram);
  15.   besRETURNVALUE = NULL;
  16. besEND
  17.  

sbfunctions
Code: ScriptBasic
  1. ' sbfunctions - ScriptBasic CBASIC function wrappers
  2.  
  3. FUNCTION sb_replace(basestr, searchstr, replacestr, occurances, startpos)
  4.   sb_replace = REPLACE(basestr, searchstr, replacestr, occurances, startpos)
  5. END FUNCTION
  6.  

Output


C:\ScriptBasic64\examples>scriba sbt_min.sb
Goodbye World

C:\ScriptBasic64\examples>

73
ScriptBasic Blog / Re: ScriptBasic 3.0
« Last post by John on April 11, 2024, 07:43:12 PM »
I see more value with the Windows 32 bit version then what Windows 64 bit offers. Using 64 bit long (LongLong) seems rarely used and you have to go through a conversation process to assign smaller types for export to other resources. Linux does it right and is a true 64 bit OS.
74
ScriptBasic Blog / Re: ScriptBasic 3.0
« Last post by John on April 11, 2024, 06:00:45 PM »
I removed <windows.h> include and SBT compiled fine and ran my threaded examples without issue. My SBT API calls still aren't working.

I created a SBT module with TDM-GCC-64 and does the same thing the MSVC version does. I'm starting believe this is a flaky Windows 64 thing.

I guess I will have to be happy that I can run threads but have to use MT to communicate with them on Windows 64 bit.

75
ScriptBasic Blog / Re: ScriptBasic 3.0
« Last post by John on April 11, 2024, 03:45:42 PM »
This works as it should using the MSVC SBT.

sbt_main.sb
Code: ScriptBasic
  1. ' SBT Main
  2.  
  3. IMPORT mt.bas
  4. IMPORT sbt.bas
  5.  
  6. SBT::SB_ThreadStart("sbt_thread.sb", "","C:/Windows/SCRIBA.INI")
  7.  
  8. FOR x = 1 TO 10
  9.   PRINT "M:",x,"\n"
  10.   SBT::sb_msSleep(100)
  11. NEXT
  12.  
  13. SBT::SB_msSleep(1000)
  14.  
  15. PRINT "Thread ",mt::GetVariable("thread_status"),"\n"
  16.  

sbt_thread.sb
Code: ScriptBasic
  1. ' SBT Thread
  2.  
  3. IMPORT mt.bas
  4. IMPORT sbt.bas
  5.  
  6. FOR x = 1 TO 10
  7.   PRINT "T:",x,"\n"
  8.   SBT::SB_msSleep(100)
  9. NEXT
  10.  
  11. mt::SetVariable "thread_status","Completed"
  12.  
  13. SBT::SB_ThreadEnd
  14.  

Output


C:\ScriptBasic64\examples>scriba sbt_main.sb
T:1
T:2
T:3
T:4
T:5
M:1
T:6
M:2
T:7
M:3
T:8
M:4
T:9
M:5
T:10
M:6
M:7
M:8
M:9
M:10
Thread Completed

C:\ScriptBasic64\examples>

76
ScriptBasic Blog / Re: ScriptBasic 3.0
« Last post by John on April 11, 2024, 12:57:36 PM »
I noticed <io.h> was missing from the Windows 64 bit version of SBT but included in the 32 bit version. No luck getting it working. The Windows 32 bit and Linux 64 bit version were compiled using GCC not MSVC.

I tried using the TDM-GCC-64 version of SBT.DLL with the MSVC build but it still doesn't work. Interesting that the MSVC version of SBT is 119K and the GCC version is 577K. The Windows 64 version only allows me to use libscriba if I'm calling it from C and starting it as a thread. No libscriba API calls seem to work from SBT.  The GCC version runs mt thread test as does the MSVC version. Neither allows SBT to make API calls.

This is looking more like a Windows 64 environment issue than SBT being at fault.

Hopefully AIR will find a moment to have a look. I've tried everything I can think of.
77
ScriptBasic Blog / Re: ScriptBasic 3.0
« Last post by John on April 10, 2024, 11:44:56 PM »
Here is a Windows 32 bit example of using the SBT start as a thread feature and using the libscriba API to access it. This is what I can't get working on Windows 64 bit.

sbt_start
Code: ScriptBasic
  1. IMPORT mt.sbi
  2. IMPORT sbt.sbi
  3.  
  4. sb = SBT::SB_ThreadStart("sbt_base.sb", "","C:/Windows/SCRIBA.INI")
  5.  
  6. ' Assign variables values
  7. SBT::SB_SetInt(sb, "main::a", 123)
  8. SBT::SB_SetDbl(sb, "main::b", 12.3)
  9. SBT::SB_SetStr(sb, "main::c", "One,Two,Three" & CHR(0))
  10. ' Call function with variables assigned in the previous step
  11. SBT::SB_CallSubArgs(sb, "main::prtvars", _
  12.           SBT::SB_GetVar(sb, "main::a"), _
  13.           SBT::SB_GetVar(sb, "main::b"), _
  14.           SBT::SB_GetVar(sb, "main::c"))
  15. ' Terminate Thread
  16. SBT::SB_CallSub(sb, "main::end_thread")
  17.  

sbt_base - (thread)
Code: ScriptBasic
  1. IMPORT mt.sbi
  2. IMPORT sbt.sbi
  3.  
  4. FUNCTION prtvars(a, b, c)
  5.   PRINT a,"\n"
  6.   PRINT FORMAT("%g\n", b)
  7.   PRINT c,"\n"
  8.   prtvars = "Function Return"
  9. END FUNCTION
  10.  
  11. a = 0
  12. b = 0
  13. c = ""
  14.  
  15. SUB End_Thread
  16.   PRINT "Good-Bye\n"
  17.   SBT::SB_ThreadEnd
  18. END SUB
  19.  

Output


C:\ScriptBasic\test>sbc sbt_start.sb
123
12.3
One,Two,Three
Good-Bye

C:\ScriptBasic\test>

   
78
ScriptBasic Blog / Re: ScriptBasic 3.0
« Last post by John on April 10, 2024, 10:24:12 PM »
It seems my only option with using libscriba within ScriptBasic on Windows 64 is running as threads. The embedding of SB in SB doesn't want to work on Windows 64 bit. I can communicate with the threads using the MT extension module. It's good to know libscriba is working in Windows 64 bit.

79
ScriptBasic Blog / Re: ScriptBasic 3.0
« Last post by John on April 10, 2024, 06:56:03 PM »
At this point the only major outstanding issue is libscriba on Windows 64 bit. It works fine on 64 Linux and 32 Windows. It returns the object handle but fails with any further calls.

Running libscriba as threads work using the SBT extension module. I'm beginning to wonder if this is a SBT issue not libscriba. Writing a C program to call libscriba seems like the next step.

If another set of eyes could have a look, it would be appreciated.
80
ScriptBasic Blog / Re: ScriptBasic 3.0
« Last post by John on April 09, 2024, 11:39:02 AM »
This is a memory allocation test is both 64 and 32 bit Windows.

Code: ScriptBasic
  1. a = STRING(MAXINT - 4, " ")
  2. PRINT LEN(a), "\n"
  3.  


C:\ScriptBasic64\bin>scriba.exe bigstr.sb   <-- ScriptBasic Windows 64 Bit
2147483643

C:\ScriptBasic64\bin>sbc bigstr.sb   <-- ScriptBasic Windows 32 Bit
(0): error &H1:Not enough memory

C:\ScriptBasic64\bin>sbc bigstr.sb   <-- ScriptBasic Windows 32 Bit
1000000000

C:\ScriptBasic64\bin>

jrs@linux-dev:~/sb/examples$ scriba memtest.sb   <-- Linux 64 Bit
4000000000
jrs@linux-dev:~/sb/examples$


Quote
The LongLong data type is a signed 64-bit integer that is only available on 64-bit versions of Office. Use LongLong for 64-bit integrals. Conversion functions must be used to explicitly assign LongLong (including LongPtr on 64-bit platforms) to smaller integral types.
Pages: 1 ... 6 7 [8] 9 10