Recent Posts

Pages: 1 [2] 3 4 ... 10
11
Scripting Languages / Re: ScriptBasic 3.0
« Last post by John on April 13, 2024, 09:44:10 PM »
All the modules released on all platforms are now working. If you have time to give ScriptBasic a try and let me know if you find any issue that would be great. I need to get back to a project I'm working on so that's it from me for a while.
12
Scripting Languages / Re: ScriptBasic 3.0
« Last post by John on April 13, 2024, 08:40:34 PM »
Everything works fine with the changes I made on the Linux side on Windows 64 bit MSVC. I pushed the change to the ScriptBasic repository.

Code: ScriptBasic
  1. IMPORT odbc.bas
  2.  
  3. dbh = ODBC::RealConnect("SB64","","")
  4.  
  5. ODBC::query(dbh, "SELECT * FROM TaskEntry")
  6.  
  7. WHILE ODBC::FetchHash(dbh,column)
  8.   PRINT column{"ClientCode"}," - ",column{"TaskCode"},"\n"
  9. WEND
  10.  
  11. ODBC::Close(dbh)
  12.  


C:\ScriptBasic64\examples>scriba sql_odbc.sb
3FCONST - SPI-100-SERVICE
AC PRO - SPI-100-SERVICE
AC PRO - SPI-100-NC
AC PRO - SPI-100-DIS/DEM
AC PRO - SPI-100-SERVICE
AC PRO - SPI-100-DIS/DEM
AC PRO - SPI-100-DIS/DEM
AC PRO - SPI-100-SERVICE
AC PRO - SPI-100-SERVICE
AC PRO - SPI-100-NC
BACKLAN - SPI-100-SERVICE
BACKLAN - SPI-100-DIS/DEM
BACKLAN - SPI-100-NC

C:\ScriptBasic64\examples>


13
Scripting Languages / Re: ScriptBasic 3.0
« Last post by John on April 13, 2024, 07:53:43 PM »
I found the the issue with FetchHash(). I'm going to try these changes on the Windows 64 MSVC version to make sure it works there as well. If all is good, I'll push the changes to the repo.
Code: C
  1.   SQLULEN ColSize; // JRS
  2. // SQLUINTEGER ColSize;
  3.  

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 10")
  7.  
  8. WHILE ODBC::FetchHash(dbh,column)
  9.   PRINT column{"title"}," - ",column{"description"}, "\n"
  10. WEND
  11.  
  12. Done:
  13. ODBC::Close(dbh)
  14. END
  15.  
  16. Ouch:
  17. PRINT "DEBUG: ", ODBC::Error(dbh), "\n"
  18. GOTO Done
  19.  

Code: Text
  1. jrs@linux-dev:~/sb/examples$ scriba sql_odbc.sb
  2. Chamber Italian - A Fateful Reflection of a Moose And a Husband who must Overcome a Monkey in Nigeria
  3. Grosse Wonderful - A Epic Drama of a Cat And a Explorer who must Redeem a Moose in Australia
  4. Airport Pollock - A Epic Tale of a Moose And a Girl who must Confront a Monkey in Ancient India
  5. Bright Encounters - A Fateful Yarn of a Lumberjack And a Feminist who must Conquer a Student in A Jet Boat
  6. Academy Dinosaur - A Epic Drama of a Feminist And a Mad Scientist who must Battle a Teacher in The Canadian Rockies
  7. Ace Goldfinger - A Astounding Epistle of a Database Administrator And a Explorer who must Find a Car in Ancient China
  8. Adaptation Holes - A Astounding Reflection of a Lumberjack And a Car who must Sink a Lumberjack in A Baloon Factory
  9. Affair Prejudice - A Fanciful Documentary of a Frisbee And a Lumberjack who must Chase a Monkey in A Shark Tank
  10. 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. Agent Truman - A Intrepid Panorama of a Robot And a Boy who must Escape a Sumo Wrestler in Ancient China
  12. jrs@linux-dev:~/sb/examples$
  13.  
14
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.  
15
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$


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

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

18
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.

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

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

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