Recent Posts

Pages: 1 2 [3] 4 5 ... 10
21
Scripting Languages / Re: ScriptBasic 3.0
« Last post by John on April 13, 2024, 06:41:15 PM »
I have made some progress with the ODBC extension module on Linux. This 64-bit ODBC driver support guide was helpful to find the issue.

Code: C
  1.   SQLLEN cbCol,cbrCol; //JRS
  2.   // SQLINTEGER cbCol,cbrCol;
  3.  

This allowed me to get FetchArray to work. FethchHash still isn't working and I believe it might be a type issue as well.

Code: ScriptBasic
  1. IMPORT odbc.bas
  2.  
  3. ON ERROR GOTO Ouch
  4. dbh = ODBC::RealConnect("PSQL","postgres","<Password>")
  5.  
  6. ODBC::Query(dbh, "SELECT * FROM film LIMIT 25")
  7.  
  8. WHILE ODBC::FetchArray(dbh,column)
  9.   ' PRINT column{"title"}," - ",column{"description"}, "\n"
  10.  PRINT column[0],"\t",column[1],"\t",column[2],"\n"
  11. WEND
  12.  
  13. Done:
  14. ODBC::Close(dbh)
  15. END
  16.  
  17. Ouch:
  18. PRINT "DEBUG: ", ODBC::Error(dbh), "\n"
  19. GOTO Done
  20.  

Code: Text
  1. jrs@linux-dev:~/sb/examples$ scriba sql_odbc.sb
  2. 133     Chamber Italian A Fateful Reflection of a Moose And a Husband who must Overcome a Monkey in Nigeria
  3. 384     Grosse Wonderful        A Epic Drama of a Cat And a Explorer who must Redeem a Moose in Australia
  4. 8       Airport Pollock A Epic Tale of a Moose And a Girl who must Confront a Monkey in Ancient India
  5. 98      Bright Encounters       A Fateful Yarn of a Lumberjack And a Feminist who must Conquer a Student in A Jet Boat
  6. 1       Academy Dinosaur        A Epic Drama of a Feminist And a Mad Scientist who must Battle a Teacher in The Canadian Rockies
  7. 2       Ace Goldfinger  A Astounding Epistle of a Database Administrator And a Explorer who must Find a Car in Ancient China
  8. 3       Adaptation Holes        A Astounding Reflection of a Lumberjack And a Car who must Sink a Lumberjack in A Baloon Factory
  9. 4       Affair Prejudice        A Fanciful Documentary of a Frisbee And a Lumberjack who must Chase a Monkey in A Shark Tank
  10. 5       African Egg     A Fast-Paced Documentary of a Pastry Chef And a Dentist who must Pursue a Forensic Psychologist in The Gulf of Mexico
  11. 6       Agent Truman    A Intrepid Panorama of a Robot And a Boy who must Escape a Sumo Wrestler in Ancient China
  12. 7       Airplane Sierra A Touching Saga of a Hunter And a Butler who must Discover a Butler in A Jet Boat
  13. 9       Alabama Devil   A Thoughtful Panorama of a Database Administrator And a Mad Scientist who must Outgun a Mad Scientist in A Jet Boat
  14. 10      Aladdin Calendar        A Action-Packed Tale of a Man And a Lumberjack who must Reach a Feminist in Ancient China
  15. 11      Alamo Videotape A Boring Epistle of a Butler And a Cat who must Fight a Pastry Chef in A MySQL Convention
  16. 12      Alaska Phantom  A Fanciful Saga of a Hunter And a Pastry Chef who must Vanquish a Boy in Australia
  17. 213     Date Speed      A Touching Saga of a Composer And a Moose who must Discover a Dentist in A MySQL Convention
  18. 13      Ali Forever     A Action-Packed Drama of a Dentist And a Crocodile who must Battle a Feminist in The Canadian Rockies
  19. 14      Alice Fantasia  A Emotional Drama of a A Shark And a Database Administrator who must Vanquish a Pioneer in Soviet Georgia
  20. 15      Alien Center    A Brilliant Drama of a Cat And a Mad Scientist who must Battle a Feminist in A MySQL Convention
  21. 16      Alley Evolution A Fast-Paced Drama of a Robot And a Composer who must Battle a Astronaut in New Orleans
  22. 17      Alone Trip      A Fast-Paced Character Study of a Composer And a Dog who must Outgun a Boat in An Abandoned Fun House
  23. 18      Alter Victory   A Thoughtful Drama of a Composer And a Feminist who must Meet a Secret Agent in The Canadian Rockies
  24. 19      Amadeus Holy    A Emotional Display of a Pioneer And a Technical Writer who must Battle a Man in A Baloon
  25. 20      Amelie Hellfighters     A Boring Drama of a Woman And a Squirrel who must Conquer a Student in A Baloon
  26. 21      American Circus A Insightful Drama of a Girl And a Astronaut who must Face a Database Administrator in A Shark Tank
  27. jrs@linux-dev:~/sb/examples$
  28.  
22
Scripting Languages / Re: ScriptBasic 3.0
« Last post by John on April 12, 2024, 05:48:47 PM »
The new version of MSVC SBT works on Linux as well. I will push the new SBT code to the repo and attach a Windows 64 bit compiled version for those that chose to download the runtime rather than build from source.

You may have noticed the main::<function / var name> reference. If you were using modules (name spaces) then you can use the name of your module instead of main (default name space) All names must be in lower case.

sbt_demo.sb
Code: ScriptBasic
  1. ' SBT 64 bit Linux Demo
  2.  
  3. IMPORT sbt.bas
  4.  
  5. sb_code = """
  6. FUNCTION prtvars(a, b, c)
  7.  PRINT a,"\\n"
  8.  PRINT FORMAT("%g\\n", b)
  9.  PRINT c,"\\n"
  10.  prtvars = "Function Return"
  11. END FUNCTION
  12.  
  13. a = 0
  14. b = 0
  15. c = ""
  16. """
  17.  
  18. sb = sbt::SB_New()
  19. sbt::SB_Configure sb, "/etc/scriba/basic.conf"
  20. sbt::SB_Loadstr sb, sb_code
  21. sbt::SB_NoRun sb
  22. ' Call function before running script
  23. funcrtn = sbt::SB_CallSubArgs(sb,"main::prtvars", 123, 1.23, "One, Two, Three")
  24. PRINT funcrtn,"\n"
  25. ' Run script initializing globals
  26. sbt::SB_Run sb, ""
  27. ' Assign variables values
  28. sbt::SB_SetInt sb, "main::a", 321
  29. sbt::SB_SetDbl sb, "main::b", 32.1
  30. sbt::SB_SetStr sb, "main::c", "Three,Two,One" & CHR(0)
  31. ' Call function again with variables assigned in the previous step
  32. sbt::SB_CallSubArgs sb, "main::prtvars", _
  33.           sbt::SB_GetVar(sb, "main::a"), _
  34.           sbt::SB_GetVar(sb, "main::b"), _
  35.           sbt::SB_GetVar(sb, "main::c")
  36. sbt::SB_Destroy sb
  37.  

Output

jrs@linux-dev:~/sb/examples$ scriba sbt_demo.sb
123
1.23
One, Two, Three
Function Return
321
32.1
Three,Two,One
jrs@linux-dev:~/sb/examples$


23
Scripting Languages / Re: ScriptBasic 3.0
« Last post by John on April 12, 2024, 04:48:37 PM »
I got the threaded version of SBT API calling working. It also works with the MT module which I use as thread status flags. This way you don't have to make continuous calls to the thread to get its status.

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

sbt_base.sb
Code: ScriptBasic
  1. IMPORT mt.bas
  2. IMPORT sbt.bas
  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. mt::SetVariable("thread_status","Running")
  16.  
  17. SUB End_Thread
  18.   SBT::SB_ThreadEnd()
  19. END SUB
  20.  

Output

C:\ScriptBasic64\examples>scriba sbt_start.sb
123
12.3
One,Two,Three
Thread Running

C:\ScriptBasic64\examples>

24
Scripting Languages / Re: ScriptBasic 3.0
« Last post by John on April 12, 2024, 03:10:41 PM »
I was able to get SBT working after my pointer based rewrite. I still have to test this on Linux before I push it to the repo.

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

Output


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

C:\ScriptBasic64\examples>

25
Scripting Languages / Re: ScriptBasic 3.0
« Last post by John on April 12, 2024, 10:09:12 AM »
I think I know what the problem is. I need to pass the sb object as a Pointer not an Integer (signed long). I got away with it on Windows 32 bit and Linux but Windows 64 bit has a greater memory range and is overflowing returning a negative value.

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

27
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>

28
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.
29
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.

30
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>

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