Recent Posts

Pages: [1] 2 3 ... 10
1
Scripting Languages / Re: ScriptBasic 3.0
« Last post by John on Today at 12:13:25 AM »
I found this Sokoban solver for my phone that is interesting. I would need to modify the game to allow this command string.
2
Scripting Languages / Re: ScriptBasic 3.0
« Last post by John on April 15, 2024, 07:24:56 PM »
I added the ScriptBasic games to the repository.

https://gitlab.com/scriptbasic/sb-dev-win32/-/tree/master/examples/games/Peter_Wirbelauer

Move the files in the lib and include directories to your ScriptBasic directories with the same name.

With the SBT / MT extension modules, you could use threads in your game design.

I've attached Peter's OxygenBasic include / source which this game engine is built on.

This should be a good start for those wishing to use ScriptBasic to develop games.
3
Open Forum / PlanetSquires Forum
« Last post by John on April 15, 2024, 01:42:41 PM »
Paul,

I would be happy to host a readonly version of your forum to preserve the work you have done. This would be hosted as a sub-domain of AllBASIC.info like the Retro BASIC forum and Charles's old OxygenBasic.org forum.

Send me an email if this is a direction that makes sense.

John
4
Scripting Languages / Re: ScriptBasic 3.0
« Last post by John on April 14, 2024, 10:53:28 PM »
If you're using the Windows 32 bit version of ScriptBasic then you might enjoy the games I converted to ScriptBasic but using DLLC to call Peter Wirbelauer's game DLL. I will push to the repo the five games I did using Peter's library.

The game has 30 Levels with each getting harder. If you push a box into a corner before covering a circle, game over. The spacebar resets the level.

The only thing I would like to see added to this game is storing the moves. If you achieve the level by coving all the circles,  you can save the game under your initials and play it back again. (single step or auto)

Quote
Designated storage locations: In Sokomind Plus, some boxes and target circles are uniquely numbered. In Block-o-Mania, the boxes have different colours, and the goal is to push them onto squares with matching colours.




Code: ScriptBasic
  1. ' ScriptBasic SokoMouse
  2.  
  3. INCLUDE "sbsw.inc"
  4.  
  5. SUB Initialize
  6.   SW_DrawBmp p1, 0, 0, 640, 480, 0
  7. ' SW_BmpText fo, 200, 8, "SokoMouse", 24, 24
  8.  zA = 0
  9.   Notified = FALSE
  10.   CALL ShowLevel
  11.   FOR bc = 0 TO 299
  12.     xBox[bc] = 0
  13.     yBox[bc] = 0
  14.     rBox[bc] = 0
  15.     zBox[bc] = 0
  16.     iBox[bc] = 0
  17.   NEXT
  18.   zR = 0
  19.   vR = 0
  20.   pHead = 3
  21.   Ready = 0
  22.   sl = 0
  23.   cV = 0
  24.   cR = 0
  25.   Steps = 0
  26.   RasReg = 0
  27.   KeyR = 0
  28.   KeyL = 0
  29.   KeyU = 0
  30.   KeyD = 0
  31.   BoxRas = 0
  32.   Turn = 1
  33.   zTurn = 0
  34. END SUB
  35.  
  36. SUB LoadMaps
  37.   SW_LoadBytes "Maps/Map" & lev & "-1.bin", Map1
  38.   SW_LoadBytes "Maps/Map" & lev & "-2.bin", Map2
  39.   SW_LoadBytes "Maps/Map" & lev & "-3.bin", Map3
  40. END SUB  
  41.  
  42. SUB ShowLevel
  43.   SW_Sprite s8, 480, 450, zA
  44.   SW_Sprite s9, 576, 450, zA
  45.   SW_BmpText fo, 520, 450, FORMAT("%~00~",lev), 24, 24
  46.   vA += 1
  47.   IF vA = 8 THEN
  48.     vA = 0
  49.     zA = zA + 1
  50.     IF zA = 4 THEN zA = 0
  51.   END IF
  52. END SUB
  53.  
  54. SUB ShowMaps
  55.   FOR icx = 0 TO 14
  56.     FOR idx = 0 TO 19
  57.       ibx = icx * 20 + idx
  58.       IF ASC(Map1[ibx]) = 3 THEN SW_Sprite s1, idx * 32, icx * 32, 3
  59.       IF ASC(Map3[ibx]) = 2 THEN SW_Sprite s1, idx * 32, icx * 32, 2
  60.       IF ASC(Map2[ibx]) = 5 THEN SW_Sprite s2, idx * 32, icx * 32, zR
  61.     NEXT
  62.   NEXT
  63.   vR += 1
  64.   IF vR = 10 THEN
  65.     vR = 0
  66.     zR += 1
  67.   END IF
  68.   IF zR = 4 THEN zR = 0
  69. END SUB
  70.  
  71. SUB FindHead
  72.   FOR icx = 0 TO 14
  73.     FOR idx = 0 TO 19
  74.       ibx = icx * 20 + idx
  75.       IF ASC(Map3[ibx]) = 6 THEN
  76.         xHead = idx * 32
  77.         yHead = icx * 32
  78.         rHead = 0
  79.         zHead = 0
  80.         EXIT SUB
  81.       END IF
  82.     NEXT
  83.   NEXT
  84. END SUB
  85.  
  86. SUB AllDone
  87.   IF Ready >= 1 THEN EXIT SUB
  88.   FOR icx = 0 TO 14
  89.     FOR idx = 0 TO 19
  90.       ibx = icx * 20 + idx
  91.       IF ASC(Map2[ibx]) = 5 AND ASC(Map3[ibx]) <> 4 THEN
  92.         EXIT SUB
  93.       END IF
  94.     NEXT
  95.   NEXT
  96.   Ready = 2
  97.   RasReg = 1
  98.   Turn = 0
  99.   pHead = 0
  100.   rTurn = SW_Rnd(1, 2)
  101.   xTurn = xHead
  102.   yTurn = yHead
  103. END SUB
  104.  
  105. SUB TurnHead
  106.   IF Turn > 0 THEN EXIT SUB
  107.   IF rTurn = 1 THEN
  108.     SW_Sprite s6, xTurn, yTurn, zTurn
  109.   ELSE IF rTurn = 2 THEN
  110.     SW_Sprite s7, xTurn, yTurn, zTurn
  111.   END IF
  112.   zTurn = zTurn + 1
  113.   IF zTurn = 64 THEN zTurn = 0
  114. END SUB
  115.  
  116. SUB FlashBox
  117.   FOR icx = 0 TO 14
  118.     FOR idx = 0 TO 19
  119.       ibx = icx * 20 + idx
  120.       IF ASC(Map2[ibx]) = 5 AND ASC(Map3[ibx]) = 4 THEN
  121.         SW_Sprite s4, idx * 32, icx * 32, cR
  122.       END IF
  123.     NEXT
  124.   NEXT
  125.   cV += 1
  126.   IF cV = 10 THEN
  127.     cV = 0
  128.     cR += 1
  129.   END IF
  130.   IF cR = 4 THEN cR = 0
  131. END SUB
  132.  
  133. SUB ScanBoxes
  134.   IF BoxRas > 0 THEN EXIT SUB
  135.   FOR icx = 0 TO 14
  136.     FOR idx = 0 TO 19
  137.       ibx = icx * 20 + idx
  138.       IF ASC(Map3[ibx]) = 4 THEN
  139.         iBox[ibx] = 1
  140.         xBox[ibx] = idx * 32
  141.         yBox[ibx] = icx * 32
  142.         rBox[ibx] = 0
  143.       END IF
  144.     NEXT
  145.   NEXT
  146. END SUB
  147.  
  148. SUB ShowBoxes
  149.   FOR ibx = 20 TO 280
  150.     IF iBox[ibx] = 1 AND rBox[ibx] = 0 THEN
  151.       SW_Sprite s1, xBox[ibx], yBox[ibx], 4
  152.     ELSE IF iBox[ibx] = 1 AND rBox[ibx] = 1 THEN
  153.       xBox[ibx] = xBox[ibx] + 2
  154.       SW_Sprite s1, xBox[ibx], yBox[ibx], 4
  155.       zBox[ibx] = zBox[ibx] + 2
  156.       IF zBox[ibx] = 32 THEN
  157.         zBox[ibx] = 0
  158.         iBox[ibx] = 0
  159.         icx = (yBox[ibx] * 20 + xBox[ibx]) / 32
  160.         Map3[icx] = CHR(4)
  161.       END IF
  162.     ELSE IF iBox[ibx] = 1 AND rBox[ibx] = 2 THEN
  163.       xBox[ibx] = xBox[ibx] - 2
  164.       SW_Sprite s1, xBox[ibx], yBox[ibx], 4
  165.       zBox[ibx] = zBox[ibx] + 2
  166.       IF zBox[ibx] = 32 THEN
  167.         zBox[ibx] = 0
  168.         iBox[ibx] = 0
  169.         icx = (yBox[ibx] * 20 + xBox[ibx]) / 32
  170.         Map3[icx] = CHR(4)
  171.       END IF
  172.     ELSE IF iBox[ibx] = 1 AND rBox[ibx] = 3 THEN
  173.       yBox[ibx] = yBox[ibx] - 2
  174.       SW_Sprite s1, xBox[ibx], yBox[ibx], 4
  175.       zBox[ibx] = zBox[ibx] + 2
  176.       IF zBox[ibx] = 32 THEN
  177.         zBox[ibx] = 0
  178.         iBox[ibx] = 0
  179.         icx = (yBox[ibx] * 20 + xBox[ibx]) / 32
  180.         Map3[icx] = CHR(4)
  181.       END IF
  182.     ELSE IF iBox[ibx] = 1 AND rBox[ibx] = 4 THEN
  183.       yBox[ibx] = yBox[ibx] + 2
  184.       SW_Sprite s1, xBox[ibx], yBox[ibx], 4
  185.       zBox[ibx] = zBox[ibx] + 2
  186.       IF zBox[ibx] = 32 THEN
  187.         zBox[ibx] = 0
  188.         iBox[ibx] = 0
  189.         icx = (yBox[ibx] * 20 + xBox[ibx]) / 32
  190.         Map3[icx] = CHR(4)
  191.       END IF
  192.     END IF
  193.   NEXT
  194. END SUB
  195.  
  196. SUB ScanHead
  197.   IF RasReg > 0 THEN EXIT SUB
  198.   idx = xHead / 32
  199.   icx = yHead / 32
  200.   ibx = icx * 20 + idx
  201.   IF ASC(Map3[ibx]) = 6 AND SW_Key(vk_right) AND ASC(Map3[ibx + 1]) = 4 AND ASC(Map3[ibx + 2]) = 0 AND KeyR = 0 THEN
  202.     Map3[ibx] = CHR(0)
  203.     Map3[ibx + 1] = CHR(6)
  204.     rHead = 1
  205.     pHead = 1
  206.     BoxRas = 0
  207.     xBox[ibx + 1] = xHead + 32
  208.     yBox[ibx + 1] = yHead
  209.     rBox[ibx + 1] = 1
  210.     iBox[ibx + 1] = 1
  211.     Steps += 1
  212.     SW_PlayWav w2
  213.   ELSE IF ASC(Map3[ibx]) = 6 AND SW_Key(vk_left) AND ASC(Map3[ibx - 1]) = 4 AND ASC(Map3[ibx - 2]) = 0 AND KeyL = 0 THEN
  214.     Map3[ibx] = CHR(0)
  215.     Map3[ibx - 1] = CHR(6)
  216.     rHead = 2
  217.     pHead = 2
  218.     BoxRas = 0
  219.     xBox[ibx - 1] = xHead - 32
  220.     yBox[ibx - 1] = yHead
  221.     rBox[ibx - 1] = 2
  222.     iBox[ibx - 1] = 1
  223.     Steps += 1
  224.     SW_PlayWav w2
  225.   ELSE IF ASC(Map3[ibx]) = 6 AND SW_Key(vk_up) AND ASC(Map3[ibx - 20]) = 4 AND ASC(Map3[ibx - 40]) = 0 AND KeyU = 0 THEN
  226.     Map3[ibx] = CHR(0)
  227.     Map3[ibx - 20] = CHR(6)
  228.     rHead = 3
  229.     pHead = 3
  230.     BoxRas = 0
  231.     xBox[ibx - 20] = xHead
  232.     yBox[ibx - 20] = yHead - 32
  233.     rBox[ibx - 20] = 3
  234.     iBox[ibx - 20] = 1
  235.     Steps += 1
  236.     SW_PlayWav w2
  237.   ELSE IF ASC(Map3[ibx]) = 6 AND SW_Key(vk_down) AND ASC(Map3[ibx + 20]) = 4 AND ASC(Map3[ibx + 40]) = 0 AND KeyD = 0 THEN
  238.     Map3[ibx] = CHR(0)
  239.     Map3[ibx + 20] = CHR(6)
  240.     rHead = 4
  241.     pHead = 4
  242.     BoxRas = 0
  243.     xBox[ibx + 20] = xHead
  244.     yBox[ibx + 20] = yHead + 32
  245.     rBox[ibx + 20] = 4
  246.     iBox[ibx + 20] = 1
  247.     Steps += 1
  248.     SW_PlayWav w2
  249.   ELSE IF ASC(Map3[ibx]) = 6 AND SW_Key(vk_right) AND ASC(Map3[ibx + 1]) = 0 AND KeyR = 0 THEN
  250.     rHead = 1
  251.     pHead = 1
  252.     Map3[ibx] = CHR(0)
  253.     Map3[ibx + 1] = CHR(6)
  254.     Steps += 1
  255.     SW_PlayWav w1
  256.   ELSE IF ASC(Map3[ibx]) = 6 AND SW_Key(vk_left) AND ASC(Map3[ibx - 1]) = 0 AND KeyL = 0 THEN
  257.     rHead = 2
  258.     pHead = 2
  259.     Map3[ibx] = CHR(0)
  260.     Map3[ibx - 1] = CHR(6)
  261.     Steps += 1
  262.     SW_PlayWav w1
  263.   ELSE IF ASC(Map3[ibx]) = 6 AND SW_Key(vk_up) AND ASC(Map3[ibx - 20]) = 0 AND KeyU = 0 THEN
  264.     rHead = 3
  265.     pHead = 3
  266.     Map3[ibx] = CHR(0)
  267.     Map3[ibx - 20] = CHR(6)
  268.     Steps += 1
  269.     SW_PlayWav w1
  270.   ELSE IF ASC(Map3[ibx]) = 6 AND SW_Key(vk_down) AND ASC(Map3[ibx + 20]) = 0 AND KeyD = 0 THEN
  271.     rHead = 4
  272.     pHead = 4
  273.     Map3[ibx] = CHR(0)
  274.     Map3[ibx + 20] = CHR(6)
  275.     Steps += 1
  276.     SW_PlayWav w1
  277.   ELSE
  278.     rHead = 0
  279.   END IF
  280. END SUB
  281.  
  282. SUB ShowHead
  283.   IF rHead = 0 AND pHead = 1 THEN
  284.     SW_Sprite s3, xHead, yHead, 3
  285.   ELSE IF rHead = 0 AND pHead = 2 THEN
  286.     SW_Sprite s3, xHead, yHead, 1
  287.   ELSE IF rHead = 0 AND pHead = 3 THEN
  288.     SW_Sprite s3, xHead, yHead, 0
  289.   ELSE IF rHead = 0 AND pHead = 4 THEN
  290.     SW_Sprite s3, xHead, yHead, 2
  291.   ELSE IF rHead = 1 THEN
  292.     xHead += 2
  293.     SW_Sprite s3, xHead, yHead, 3
  294.     RasReg += 2
  295.     IF RasReg = 32 THEN
  296.       RasReg = 0
  297.       rHead = 0
  298.     END IF
  299.   ELSE IF rHead = 2 THEN
  300.     xHead -= 2
  301.     SW_Sprite s3, xHead, yHead, 1
  302.     RasReg += 2
  303.     IF RasReg = 32 THEN
  304.       RasReg = 0
  305.       rHead = 0
  306.     END IF
  307.   ELSE IF rHead = 3 THEN
  308.     yHead -= 2
  309.     SW_Sprite s3, xHead, yHead, 0
  310.     RasReg += 2
  311.     IF RasReg = 32 THEN
  312.       RasReg = 0
  313.       rHead = 0
  314.     END IF
  315.   ELSE IF rHead = 4 THEN
  316.     yHead += 2
  317.     SW_Sprite s3, xHead, yHead, 2
  318.     RasReg += 2
  319.     IF RasReg = 32 THEN
  320.       RasReg = 0
  321.       rHead = 0
  322.     END IF
  323.   END IF
  324. END SUB
  325.  
  326. SUB MousePos
  327.   xPos = FIX(SW_xMouse() / 32)
  328.   yPos = FIX(SW_yMouse() / 32)
  329.   IF SW_MouseButton() = 1 THEN
  330.     IF xPos = 15 AND yPos = 14 AND lev > 1 AND ButtonC = 0 THEN
  331.       lev -= 1
  332.       ButtonC = 1
  333.       SW_PlayWav w4
  334.       Initialize
  335.       LoadMaps
  336.       FindHead
  337.       EXIT SUB
  338.     END IF
  339.   END IF
  340.   IF SW_MouseButton() = 1 THEN
  341.     IF xPos = 18 AND yPos = 14 AND lev < 30 AND ButtonC = 0 THEN
  342.       lev += 1
  343.       ButtonC = 1
  344.       SW_PlayWav w4
  345.       Initialize
  346.       LoadMaps
  347.       FindHead
  348.     END IF
  349.   END IF
  350.   IF SW_MouseButton() = 0 THEN ButtonC = 0
  351. END SUB
  352.  
  353.  
  354. ' MAIN
  355.  
  356. SW_Window 640, 480, 1
  357. SW_SetCaption "ScriptBasic SokoMouse"
  358.  
  359. SW_SetFps(60)
  360.  
  361. Q  = SW_LoadBmp("SokoMedia/sokomouse.bmp", 1)
  362. p1 = SW_LoadBmp("SokoMedia/smbg.bmp", 1)
  363. Fo = SW_LoadBmp("SokoMedia/FontStrip.bmp", 96)
  364. s1 = SW_LoadBmp("SokoMedia/SokoStrip.bmp", 5)
  365. s2 = SW_LoadBmp("SokoMedia/RundStrip.bmp", 4)
  366. s3 = SW_LoadBmp("SokoMedia/HeadStrip.bmp", 4)
  367. s4 = SW_LoadBmp("SokoMedia/BoxsStrip.bmp", 4)
  368. s6 = SW_LoadBmp("SokoMedia/HeadStripR.bmp", 64)
  369. s7 = SW_LoadBmp("SokoMedia/HeadStripL.bmp", 64)
  370. s8 = SW_LoadBmp("SokoMedia/ArroStripL.bmp", 4)
  371. s9 = SW_LoadBmp("SokoMedia/ArroStripR.bmp", 4)
  372.  
  373. w1 = "SokoMedia/move.wav"
  374. w2 = "SokoMedia/push.wav"
  375. w3 = "SokoMedia/done.wav"
  376. w4 = "SokoMedia/clic.wav"
  377.  
  378.  
  379. SW_Cls  0xCCCCCC
  380. SW_Sprite Q, 180, 60, 0
  381. SW_BmpText fo, 205, 32, "SOKOMOUSE", 24, 24
  382. SW_BmpText fo, 170, 428, "PRESS ANY KEY", 24, 24
  383. SW_WaitKey
  384.  
  385. lev = 1
  386. Initialize
  387. LoadMaps
  388. ShowLevel
  389. FindHead
  390.  
  391. WHILE SW_Key(27) = 0
  392.   ShowMaps
  393.   IF sl THEN ShowLevel
  394.   ScanBoxes
  395.   ScanHead
  396.   ShowBoxes
  397.   ShowHead
  398.   FlashBox
  399.   AllDone
  400.   MousePos
  401.   TurnHead
  402.   IF SW_Key(vk_space) THEN
  403.     SW_BmpText fo, 64, 420, "Wait...", 24, 24
  404.     Initialize
  405.     LoadMaps
  406.     FindHead
  407.   END IF
  408.   IF Ready = 2 AND NOT(Notified) THEN
  409.     SW_BmpText fo, 64, 450, Steps & " moves to solve.", 20, 20
  410.     SW_Sync
  411.     SW_PlayWav w3
  412.     sl = 1
  413.     Notified = TRUE
  414.   END IF
  415.   BoxRas += 2
  416.   IF BoxRas = 32 THEN BoxRas = 0
  417.   IF SW_Key(vk_right) = 0 THEN KeyR = 1
  418.   IF SW_Key(vk_right)THEN
  419.     KeyR = 0
  420.     SW_Wait(10)
  421.   END IF
  422.   IF SW_Key(vk_left) = 0 THEN KeyL = 1
  423.   IF SW_Key(vk_left) THEN
  424.     KeyL = 0
  425.     SW_Wait(10)
  426.   END IF
  427.   IF SW_Key(vk_up) = 0 THEN KeyU = 1
  428.   IF SW_Key(vk_up) THEN
  429.     KeyU = 0
  430.     SW_Wait(10)
  431.   END IF
  432.   IF SW_Key(vk_down) = 0 THEN KeyD = 1
  433.   IF SW_Key(vk_down) THEN
  434.     KeyD = 0
  435.     SW_Wait(10)
  436.   END IF
  437.   SW_Sync
  438. WEND
  439. SW_CloseWindow
  440.  

sbsw.inc
Code: ScriptBasic
  1. ' SIMPLE WINDOWS LIBRARY FOR SCRIPTBASIC (sw.inc) by PETER WIRBELAUER
  2.  
  3. DECLARE SUB LoadMap ALIAS "loadstring" LIB "t"
  4. DECLARE SUB DLLC_File ALIAS "dllfile" LIB "DLLC"
  5. DECLARE SUB DLLC_Proc ALIAS "dllproc" LIB "DLLC"
  6. DECLARE SUB DLLC_Call ALIAS "dllcall" LIB "DLLC"
  7. DECLARE SUB DLLC_OleStr ALIAS "dllostr" LIB "DLLC"
  8. DECLARE SUB DLLC_DelOle ALIAS "dlldelo" LIB "DLLC"
  9.  
  10. GLOBAL CONST WHITE = 0xFFFFFF
  11. GLOBAL CONST DKGRAY = 0x404040
  12. GLOBAL CONST BLUE = 0xFF0000
  13. GLOBAL CONST BOLD = 700
  14.  
  15. ' Key Defs
  16. GLOBAL CONST vk_space = 0x20
  17. GLOBAL CONST vk_right = 0x27
  18. GLOBAL CONST vk_left = 0x25
  19. GLOBAL CONST vk_up = 0x26
  20. GLOBAL CONST vk_down = 0x28
  21.  
  22. sw = DLLC_File("sw.dll")
  23. ms = DLLC_File("winmm.dll")
  24.  
  25. ' Simple Windows function definitions
  26.  
  27. Window = DLLC_Proc(sw, "Window i = (i width, i height, i mode)")
  28. SetCaption = DLLC_Proc(sw, "SetCaption i = (c*capText)")
  29. GetWidth = DLLC_Proc(sw, "GetWidth 1 = ()")
  30. GetHeight = DLLC_Proc(sw, "GetHeight i = ()")
  31. Key = DLLC_Proc(sw, "Key i = (i mKey)")
  32. WaitKey = DLLC_Proc(sw, "WaitKey i = ( )")
  33. GetKey = DLLC_Proc(sw, "GetKey i = ( )")
  34. xMouse = DLLC_Proc(sw, "xMouse i = ( )")
  35. Wait = DLLC_Proc(sw, "Wait i = (i msec)")
  36. yMouse = DLLC_Proc(sw, "yMouse i = ( )")
  37. MouseButton = DLLC_Proc(sw, "MouseButton i = ( )")
  38. Cls = DLLC_Proc(sw, "Cls i = (i color)")
  39. DrawLine = DLLC_Proc(sw, "Line i = (i xPos, i yPos, i a, i b, i thickness, i color)")
  40. DrawPoint = DLLC_Proc(sw, "DrawPoint i = (i xPos, i yPos, i width, i height, i color)")
  41. SetPixel = DLLC_Proc(sw, "SetPixel i = (i xPos, i yPos, i color)")
  42. Box = DLLC_Proc(sw, "Box i = (i xPos, i yPos, i w, i h, i thickness, i color)")
  43. Circle = DLLC_Proc(sw, "Circle i = (i xPos, i yPos, i r1, i thickness, i color)")
  44. FillCircle = DLLC_Proc(sw, "FillCircle i = (i xPos, i yPos, i r1, i color)")
  45. Ellipse = DLLC_Proc(sw, "Ellipse i = (i xPos, i yPos, i r1, i r2, i thickness, i color)")
  46. RGB = DLLC_Proc(sw, "RGB i = (i rValue, i gValue, i bValue)")
  47. Rand = DLLC_Proc(sw, "Rnd i = (i minNumber, i maxNumber)")
  48. SetText = DLLC_Proc(sw, "SetText i = (i xPos, i yPos, o text, i color)")
  49. SetFont = DLLC_Proc(sw, "SetFont i = (i width, i height, i style, c*fontName)")
  50. LoadBmp = DLLC_Proc(sw, "LoadBmp i = (c*bmpFile, i frames)")
  51. Sprite = DLLC_Proc(sw, "Sprite i = (i idBmp, i xPos, i yPos, i frames)")
  52. BmpText = DLLC_Proc(sw, "BmpText i = (i idBmp, i xPos, i yPos, o iText, i Zoom, i yZoom)")
  53. DrawBmp = DLLC_Proc(sw, "DrawBmp i = (i idBmp, i xPos, i yPos, i xZoom, i yZoom, i frames)")
  54. Sync = DLLC_Proc(sw, "Sync ( )")
  55. Redraw = DLLC_Proc(sw, "Redraw ( )")
  56. SetFps = DLLC_Proc(sw, "SetFps i = (i frames)")
  57. PlayWav = DLLC_Proc(ms, "sndPlaySoundA i = (c*wavFile, i sync)")
  58. CloseWindow = DLLC_Proc(sw, "CloseWindow i = ( )")
  59.  
  60.  
  61.  
  62. ' Simple Windows wrapper functions
  63.  
  64. SUB SW_Window(width, height, mode)
  65.   DLLC_Call(Window, width, height, mode)
  66. END SUB
  67.  
  68. SUB SW_SetCaption(capText)
  69.   DLLC_Call(SetCaption, capText)
  70. END SUB
  71.  
  72. FUNCTION SW_GetWidth
  73.   SW_GetWidth = DLLC_Call(GetWidth)
  74. END FUNCTION
  75.  
  76. FUNCTION SW_GetHeight
  77.   SW_GetHeight = DLLC_Call(GetHeight)
  78. END FUNCTION
  79.  
  80. FUNCTION SW_Key(mKey)
  81.   SW_Key = DLLC_Call(Key, mKey)
  82. END FUNCTION
  83.  
  84. SUB SW_WaitKey
  85.   DLLC_Call(WaitKey)
  86. END SUB
  87.  
  88. FUNCTION SW_GetKey
  89.   SW_GetKey = DLLC_Call(GetKey)
  90. END FUNCTION
  91.  
  92. SUB SW_Wait(msec)
  93.   DLLC_Call(Wait, msec)
  94. END SUB
  95.  
  96. FUNCTION SW_xMouse
  97.   SW_xMouse = DLLC_Call(xMouse)
  98. END FUNCTION  
  99.  
  100. FUNCTION SW_yMouse
  101.   SW_yMouse = DLLC_Call(yMouse)
  102. END FUNCTION  
  103.  
  104. FUNCTION SW_MouseButton
  105.   SW_MouseButton = DLLC_Call(MouseButton)
  106. END FUNCTION
  107.  
  108. SUB SW_Cls(color)
  109.   DLLC_Call(Cls, color)
  110. END SUB
  111.  
  112. SUB SW_Line(xPos, yPos, a, b, thickness, color)
  113.   DLLC_Call(DrawLine, xPos, yPos, a, b, thickness, color)
  114. END SUB
  115.  
  116. SUB SW_DrawPoint(xPos, yPos, width, height, color)
  117.   DLLC_Call(DrawPoint, xPos, yPos, width, height, color)
  118. END SUB
  119.  
  120. SUB SW_SetPixel(xPos, yPos, color)
  121.   DLLC_Call(SetPixel, xPos, yPos, color)
  122. END SUB
  123.  
  124. SUB SW_Box(xPos, yPos, w, h, thickness, color)
  125.   DLLC_Call(Box, xPos, yPos, w, h, thickness, color)
  126. END SUB
  127.  
  128. SUB SW_Circle(xPos, yPos, r1, thickness, color)
  129.   DLLC_Call(Circle, xPos, yPos, r1, thickness, color)
  130. END SUB
  131.  
  132. SUB SW_FillCircle(xPos, yPos, r1, color)
  133.   DLLC_Call(FillCircle, xPos, yPos, r1, color)
  134. END SUB
  135.  
  136. SUB SW_Ellipse(xPos, yPos, r1, r2, thickness, color)
  137.   DLLC_Call(Ellipse, xPos, yPos, r1, r2, thickness, color)
  138. END SUB
  139.  
  140. FUNCTION SW_RGB(rValue, gValue, bValue)
  141.   SW_RGB = DLLC_Call(RGB, rValue, gValue, bValue)
  142. END FUNCTION
  143.  
  144. FUNCTION SW_Rnd(minNumber, maxNumber)
  145.   SW_Rnd = DLLC_Call(Rand, minNumber, maxNumber)
  146. END FUNCTION
  147.  
  148. SUB SW_SetText(xPos, yPos, text, color)
  149.   LOCAL ole_text
  150.   ole_text = DLLC_OleStr(text)
  151.   DLLC_Call(SetText, xPos, yPos, ole_text, color)
  152.   DLLC_DelOle(ole_text)
  153. END SUB
  154.  
  155. SUB SW_SetFont(width, height, style, fontName)
  156.   DLLC_Call(SetFont, width, height, style, fontName)
  157. END SUB
  158.  
  159. FUNCTION SW_LoadBmp(bmpFile, frames)
  160.   SW_LoadBmp = DLLC_Call(LoadBmp, bmpFile, frames)
  161. END FUNCTION
  162.  
  163. SUB SW_LoadBytes(nName, Destination)
  164.   LOCAL tmpstr
  165.   tmpstr = LoadMap(nName)
  166.   SPLITA tmpstr BY "" TO Destination
  167. END SUB  
  168.  
  169. SUB SW_Sprite(idBmp, xPos, yPos, frames)
  170.   DLLC_Call(Sprite, idBmp, xPos, yPos, frames)
  171. END SUB
  172.  
  173. SUB SW_BmpText(idBmp, xPos, yPos, sb_iText, Zoom, yZoom)
  174.   LOCAL ole_iText
  175.   ole_iText = DLLC_OleStr(sb_iText)
  176.   DLLC_Call(BmpText, idBmp, xPos, yPos, ole_iText, Zoom, yZoom)
  177.   DLLC_DelOle(ole_iText)
  178. END SUB  
  179.  
  180. SUB SW_DrawBmp(idBmp, xPos, yPos, xZoom, yZoom, frames)
  181.   DLLC_Call(DrawBmp, idBmp, xPos, yPos, xZoom, yZoom, frames)
  182. END SUB
  183.  
  184. SUB SW_Sync
  185.   DLLC_Call(Sync)
  186. END SUB
  187.  
  188. SUB SW_Redraw
  189.   DLLC_Call(Redraw)
  190. END SUB
  191.  
  192. SUB SW_SetFps(frames)
  193.   DLLC_Call(SetFps, frames)
  194. END SUB
  195.  
  196. SUB SW_PlayWav(sfn)
  197.   DLLC_Call(PlayWav, sfn, 1)
  198. END SUB
  199.  
  200. SUB SW_CloseWindow
  201.   DLLC_Call(CloseWindow)
  202. END SUB
  203.  


5
Scripting Languages / Re: ScriptBasic 3.0
« Last post by John on April 14, 2024, 06:21:32 PM »
I figured out what the issue was with OxygenBasic calling functions with a 64 bit pointer. I replaced cdecl with ms64 and the program compiled and ran. There still is an issue passing a double (real) to O2.

Code: Text
  1. ' O2 SB Embed
  2.  
  3. % filename "o2sb64.exe"
  4. includepath "$/inc/"
  5. uses rtl64
  6.  
  7. % libScriba = "libScriba.dll"
  8. indexbase 0
  9.  
  10. type SbData
  11.   typ as dword
  12.   siz as dword
  13.   union {
  14.     dbl as double
  15.     lng as sys
  16.     str as char*
  17.     gen as sys
  18.   }
  19. end type
  20.  
  21. #define SBT_UNDEF  0
  22. #define SBT_DOUBLE 1
  23. #define SBT_LONG   2
  24. #define SBT_STRING 3
  25. #define SBT_ZCHAR  4
  26.  
  27. sys pProgram, iError, cArgs
  28. sys f1, f2, v
  29. sys n, m
  30. sys qdat
  31. SbData ReturnData, ArgData[3]
  32. sbData pdat
  33.  
  34. sys sb=LoadLibrary libScriba
  35.  
  36. extern ms64
  37.   bind sb
  38.   {
  39.   scriba_new
  40.   scriba_SetStdin()
  41.   scriba_SetStdout()
  42.   scriba_SetEmbedPointer()
  43.   scriba_LoadConfiguration
  44.   scriba_destroy
  45.   scriba_DestroySbData
  46.   scriba_SetFileName
  47.   scriba_LoadSourceProgram
  48.   scriba_LoadProgramString
  49.   scriba_Run
  50.   scriba_GetVariable
  51.   scriba_SetVariable
  52.   scriba_LookupVariableByName
  53.   scriba_LookupFunctionByName
  54.   scriba_Call
  55.   scriba_CallArg
  56.   scriba_NewSbArgs
  57.   scriba_CallArgEx
  58.   scriba_DestroySbArgs
  59.   scriba_DestroySbData
  60.   scriba_NewSbString
  61.   }
  62. end extern
  63.  
  64. function newmem ms64 (sys le) as sys, export
  65.   return getmemory le
  66. end function
  67.  
  68. function freemem ms64 (sys p) export
  69.   freememory p
  70. end function
  71.  
  72. pProgram = scriba_new(@newmem, @freemem)
  73. scriba_LoadConfiguration(pProgram, "C:\Windows\SCRIBA.INI")
  74. scriba_SetFileName(pProgram, "test.sb")
  75. scriba_LoadSourceProgram(pProgram)
  76. scriba_Run(pProgram,"")
  77.  
  78. ' Get Global Var  
  79. sbdata *p  
  80. v = scriba_LookupVariableByName(pProgram, "main::a")
  81. scriba_GetVariable(pProgram, v, @@p)
  82. print "A: " + str(p.lng)
  83.  
  84. ' Create SB Variant Array
  85. sbData *arg
  86. @arg = scriba_NewSbArgs(pProgram,"i r s", 1, .2, "three")
  87. print str(arg[0].lng) + " | " + str(arg[1].dbl) + " | " + arg[2].str
  88.  
  89. scriba_DestroySbArgs(pProgram, arg, 3)
  90. scriba_DestroySbData(pProgram, arg)  
  91. scriba_destroy(pProgram)
  92.  

test.sb
Code: ScriptBasic
  1. a = 99






Code: Text
  1. type SbData
  2.   typ as dword
  3.   siz as dword
  4.   union {
  5.     dbl as double
  6.     lng as sys
  7.     str as char*
  8.     gen as sys
  9.   }
  10. end type
  11.  

I tried all the other O2 floating point types besides double and nothing works.  :-[
6
Scripting Languages / Re: ScriptBasic 3.0
« Last post by John on April 14, 2024, 05:16:37 PM »
If there are any OxygenBasic pros out there it would helpful to get this OxgenBasic 32 bit example of ScriptBasic embedding LIBSCRIBA working in O2 64 bit.

O2 SB 32 bit embedding example
7
Scripting Languages / Re: ScriptBasic 3.0
« Last post by John on April 14, 2024, 02:29:48 PM »
I've added the ODBC FetchSchema() function to the sb-dev-msvc repository branch. I've pushed the code to the repo and attached a Windows 64 bit ODBC extension module DLL.

Linux
Code: ScriptBasic
  1. IMPORT odbc.bas
  2.  
  3. dbh = odbc::RealConnect("PSQL","postgres","<Password>")
  4. SQL = "SELECT * FROM film LIMIT 1"
  5. odbc::Query(dbh, SQL)    
  6. odbc::FetchSchema(dbh, col)
  7. odbc::Close(dbh)
  8.  
  9. FOR x = 0 TO UBOUND(col) STEP 5
  10.   PRINT FORMAT("Column Name: %s, Type: %i, Size: %i, Digits: %i, Nullable: %i\n", col[x], col[x + 1], col[x + 2], col[x + 3], col[x + 4])
  11. NEXT
  12.  


jrs@linux-dev:~/sb/examples$ scriba getschema.sb
Column Name: film_id, Type: 4, Size: 10, Digits: 0, Nullable: 0
Column Name: title, Type: 12, Size: 255, Digits: 0, Nullable: 0
Column Name: description, Type: -1, Size: 8190, Digits: 0, Nullable: 1
Column Name: release_year, Type: 4, Size: 10, Digits: 0, Nullable: 1
Column Name: language_id, Type: 5, Size: 5, Digits: 0, Nullable: 0
Column Name: rental_duration, Type: 5, Size: 5, Digits: 0, Nullable: 0
Column Name: rental_rate, Type: 2, Size: 4, Digits: 2, Nullable: 0
Column Name: length, Type: 5, Size: 5, Digits: 0, Nullable: 1
Column Name: replacement_cost, Type: 2, Size: 5, Digits: 2, Nullable: 0
Column Name: rating, Type: 12, Size: 255, Digits: 0, Nullable: 1
Column Name: last_update, Type: 93, Size: 26, Digits: 6, Nullable: 0
Column Name: special_features, Type: 12, Size: 255, Digits: 0, Nullable: 1
Column Name: fulltext, Type: 12, Size: 255, Digits: 0, Nullable: 0
jrs@linux-dev:~/sb/examples$


Windows 64 Bit
Code: ScriptBasic
  1. IMPORT odbc.bas
  2.  
  3. dbh = ODBC::RealConnect("SB64","","")
  4.  
  5. ODBC::query(dbh, "SELECT TOP 1 * FROM TaskEntry")
  6.  
  7. odbc::FetchSchema(dbh, col)
  8. odbc::Close(dbh)
  9.  
  10. FOR x = 0 TO UBOUND(col) STEP 5
  11.   PRINT FORMAT("Column Name: %s, Type: %i, Size: %i, Digits: %i, Nullable: %i\n", col[x], col[x + 1], col[x + 2], col[x + 3], col[x + 4])
  12. NEXT
  13.  


C:\ScriptBasic64\examples>scriba fetchschema.sb
Column Name: GridSort, Type: -9, Size: 40, Digits: 0, Nullable: 0
Column Name: ClientCode, Type: -9, Size: 25, Digits: 0, Nullable: 0
Column Name: TaskCode, Type: -9, Size: 30, Digits: 0, Nullable: 0
Column Name: TaskDate, Type: -9, Size: 15, Digits: 0, Nullable: 0
Column Name: Billable, Type: 2, Size: 4, Digits: 2, Nullable: 1
Column Name: NonBillable, Type: 2, Size: 4, Digits: 2, Nullable: 1
Column Name: DiscoveryDemo, Type: 2, Size: 4, Digits: 2, Nullable: 1
Column Name: Bill, Type: -8, Size: 1, Digits: 0, Nullable: 0
Column Name: TaskNotes, Type: -10, Size: 1073741823, Digits: 0, Nullable: 0
Column Name: BillingComplete, Type: -8, Size: 1, Digits: 0, Nullable: 0

C:\ScriptBasic64\examples>


ODBC SQL Column Type Values

ODBC    JDBC    Data Type
-11    -11    GUID
 -7     -7    BIT
 -6     -6    TINYINT
 -5     -5    BIGINT
 -4     -4    LONGVARBINARY
 -3     -3    VARBINARY
 -2     -2    BINARY
 -1     -1    LONGVARCHAR
  0      0    Unknown type
  1      1    CHAR
  2      2    NUMERIC
  3      3    DECIMAL
  4      4    INTEGER
  5      5    SMALLINT
  6      6    FLOAT
  7      7    REAL
  8      8    DOUBLE
  9     91    DATE
 10     92    TIME
 11     93    TIMESTAMP
 12     12    VARCHAR

Unicode SQL types for ODBC applications working with multibyte character sets, such as in Chinese, Hebrew, Japanese, or Korean locales.

ODBC          Data Type
-10          WLONGVARCHAR
 -9          WVARCHAR


Remember to add the FetchSchema DECLARE to your odbc.bas include file. It's added if you build from source.
8
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.
9
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>


10
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.  
Pages: [1] 2 3 ... 10