Recent Posts

Pages: 1 2 [3] 4 5 ... 10
21
Scripting Languages / 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>

22
Scripting Languages / 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.
23
Scripting Languages / 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.

24
Scripting Languages / 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>

25
Scripting Languages / 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.
26
Scripting Languages / 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>

   
27
Scripting Languages / 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.

28
Scripting Languages / 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.
29
Scripting Languages / 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.
30
Scripting Languages / Re: ScriptBasic 3.0
« Last post by John on April 09, 2024, 12:46:41 AM »
Based on what I've read it looks like long is 32 bit on Windows 64 bit compiled C code. One would have to use long long for 64 bit values. It looks to me like a major refactoring job of the code. I'm hoping someone comes up which a better story.


[32-bit Linux]

me@u32:~$ ./sizes32
sizeof(char):      1
sizeof(short):     2
sizeof(int):       4
sizeof(long):      4
sizeof(long long): 8

[64-bit Linux]

me@u64:~$ ./sizes64
sizeof(char):      1
sizeof(short):     2
sizeof(int):       4
sizeof(long):      8
sizeof(long long): 8

[32-bit Windows]

C:\Users\me\Downloads>sizes32.exe
sizeof(char):      1
sizeof(short):     2
sizeof(int):       4
sizeof(long):      4
sizeof(long long): 8

[64-bit Windows]

C:\Users\me\Downloads>sizes64.exe
sizeof(char):      1
sizeof(short):     2
sizeof(int):       4
sizeof(long):      4
sizeof(long long): 8


Based on Linux LONG  being 8 bytes wide and ScriptBasic working fine, defining LONG  as long long would probably work but break interfacing with other 64 bit libraries passing 4 byte longs.

Quote

Windows x64 is a hybrid operating system, meaning many components (e.g. Internet Explorer, Windows Media Player, etc.) are present in both 32bit and 64bit variants and most 32bit programs work just as well with Windows x64.

is it worth to change? only if you have more than 4 GB RAM in your system.
Pages: 1 2 [3] 4 5 ... 10