Recent Posts

Pages: 1 ... 4 5 [6] 7 8 ... 10
51
ScriptBasic Blog / Re: ScriptBasic 3.0
« Last post by John on April 21, 2024, 08:15:11 PM »
Here is an older IUP demo I converted to ScriptBasic. This shows some of the other controls and using code to create bitmap images for buttons.



Code: ScriptBasic
  1. ' IUP sample.sb
  2.  
  3. IMPORT iup.bas
  4.  
  5. GLOBAL CONST IUP_CENTER = 0xFFFF
  6. GLOBAL CONST IUP_TITLE = "TITLE"
  7. GLOBAL CONST IUP_VALUE = "VALUE"
  8. GLOBAL CONST IUP_SIZE = "SIZE"
  9. GLOBAL CONST IUP_EXPAND = "EXPAND"
  10. GLOBAL CONST IUP_DROPDOWN = "DROPDOWN"
  11. GLOBAL CONST IUP_POSX = "POSX"
  12. GLOBAL CONST IUP_POSY = "POSY"
  13. GLOBAL CONST IUP_BGCOLOR = "BGCOLOR"
  14. GLOBAL CONST IUP_MARGIN = "MARGIN"
  15. GLOBAL CONST IUP_ALIGNMENT = "ALIGNMENT"
  16. GLOBAL CONST IUP_GAP = "GAP"
  17. GLOBAL CONST IUP_MENU = "MENU"
  18.  
  19. img_bits1 = """
  20. 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1
  21. ,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1,1
  22. ,1,1,1,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1,1,1
  23. ,1,1,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1,1,1,1
  24. ,1,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1,1,1,1,1
  25. ,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1,1,1,1,1,1
  26. ,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1,1,1,1,1,1,1
  27. ,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1,1,1,1,1,1,1,1
  28. ,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2
  29. ,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2
  30. ,2,2,2,0,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2
  31. ,2,2,2,0,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2
  32. ,2,2,2,0,2,0,2,0,2,2,0,2,2,2,0,0,0,2,2,2,0,0,2,0,2,2,0,0,0,2,2,2
  33. ,2,2,2,0,2,0,0,2,0,0,2,0,2,0,2,2,2,0,2,0,2,2,0,0,2,0,2,2,2,0,2,2
  34. ,2,2,2,0,2,0,2,2,0,2,2,0,2,2,2,2,2,0,2,0,2,2,2,0,2,0,2,2,2,0,2,2
  35. ,2,2,2,0,2,0,2,2,0,2,2,0,2,2,0,0,0,0,2,0,2,2,2,0,2,0,0,0,0,0,2,2
  36. ,2,2,2,0,2,0,2,2,0,2,2,0,2,0,2,2,2,0,2,0,2,2,2,0,2,0,2,2,2,2,2,2
  37. ,2,2,2,0,2,0,2,2,0,2,2,0,2,0,2,2,2,0,2,0,2,2,0,0,2,0,2,2,2,0,2,2
  38. ,2,2,2,0,2,0,2,2,0,2,2,0,2,2,0,0,0,0,2,2,0,0,2,0,2,2,0,0,0,2,2,2
  39. ,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,0,2,2,2,2,2,2,2,2
  40. ,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,0,2,2,2,0,2,2,2,2,2,2,2,2
  41. ,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,0,0,0,2,2,2,2,2,2,2,2,2
  42. ,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2
  43. ,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2
  44. ,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1,1,1,1,1,1,1,1,1,1,1
  45. ,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1,1,1,1,1,1,1,1,1,1,1,1
  46. ,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1,1,1,1,1,1,1,1,1,1,1,1,1
  47. ,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1
  48. ,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
  49. ,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
  50. ,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
  51. ,2,2,2,2,2,2,2,2,2,2,2,2,2,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
  52. """
  53.  
  54. img_bits2 = """
  55. 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,2
  56. ,2,2,2,2,2,2,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,2,2
  57. ,2,2,2,2,2,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,2,2,2
  58. ,2,2,2,2,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,2,2,2,2
  59. ,2,2,2,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,2,2,2,2,2
  60. ,2,2,2,2,2,2,2,2,2,2,3,3,3,3,1,1,3,3,3,3,3,3,3,3,3,3,2,2,2,2,2,2
  61. ,2,2,2,2,2,2,2,2,2,3,3,3,3,3,1,1,3,3,3,3,3,3,3,3,3,2,2,2,2,2,2,2
  62. ,2,2,2,2,2,2,2,2,3,3,3,3,3,3,1,1,3,3,3,3,3,3,3,3,2,2,2,2,2,2,2,2
  63. ,3,3,3,3,3,3,3,3,3,3,3,3,3,3,1,1,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3
  64. ,3,3,3,3,3,3,3,3,3,3,3,3,3,3,1,1,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3
  65. ,3,3,3,0,3,3,3,3,3,3,3,3,3,3,1,1,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3
  66. ,3,3,3,0,3,3,3,3,3,3,3,3,3,3,1,1,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3
  67. ,3,3,3,0,3,0,3,0,3,3,0,3,3,3,1,1,0,3,3,3,0,0,3,0,3,3,0,0,0,3,3,3
  68. ,3,3,3,0,3,0,0,3,0,0,3,0,3,0,1,1,3,0,3,0,3,3,0,0,3,0,3,3,3,0,3,3
  69. ,3,3,3,0,3,0,3,3,0,3,3,0,3,3,1,1,3,0,3,0,3,3,3,0,3,0,3,3,3,0,3,3
  70. ,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
  71. ,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
  72. ,3,3,3,0,3,0,3,3,0,3,3,0,3,0,1,1,3,0,3,0,3,3,0,0,3,0,3,3,3,0,3,3
  73. ,3,3,3,0,3,0,3,3,0,3,3,0,3,3,1,1,0,0,3,3,0,0,3,0,3,3,0,0,0,3,3,3
  74. ,3,3,3,3,3,3,3,3,3,3,3,3,3,3,1,1,3,3,3,3,3,3,3,0,3,3,3,3,3,3,3,3
  75. ,3,3,3,3,3,3,3,3,3,3,3,3,3,3,1,1,3,3,3,0,3,3,3,0,3,3,3,3,3,3,3,3
  76. ,3,3,3,3,3,3,3,3,3,3,3,3,3,3,1,1,3,3,3,3,0,0,0,3,3,3,3,3,3,3,3,3
  77. ,3,3,3,3,3,3,3,3,3,3,3,3,3,3,1,1,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3
  78. ,3,3,3,3,3,3,3,3,3,3,3,3,3,3,1,1,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3
  79. ,2,2,2,2,2,2,2,3,3,3,3,3,3,3,1,1,3,3,3,3,3,2,2,2,2,2,2,2,2,2,2,2
  80. ,2,2,2,2,2,2,3,3,3,3,3,3,3,3,1,1,3,3,3,3,2,2,2,2,2,2,2,2,2,2,2,2
  81. ,2,2,2,2,2,3,3,3,3,3,3,3,3,3,3,3,3,3,3,2,2,2,2,2,2,2,2,2,2,2,2,2
  82. ,2,2,2,2,3,3,3,3,3,3,3,3,3,3,3,3,3,3,2,2,2,2,2,2,2,2,2,2,2,2,2,2
  83. ,2,2,2,3,3,3,3,3,3,3,3,3,3,3,3,3,3,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2
  84. ,2,2,3,3,3,3,3,3,3,3,3,3,3,3,3,3,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2
  85. ,2,3,3,3,3,3,3,3,3,3,3,3,3,3,3,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2
  86. ,3,3,3,3,3,3,3,3,3,3,3,3,3,3,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2
  87. """
  88.  
  89. SUB init_dialog
  90.  
  91.   img = Iup::Image(32,32, Iup::CreateImg(img_bits1))
  92.   Iup::SetHandle ("img1", img)
  93.   Iup::SetAttribute (img, "0", "0 0 0")
  94.   Iup::SetAttribute (img, "1", "BGCOLOR")
  95.   Iup::SetAttribute (img, "2", "255 0 0")
  96.  
  97.   img = Iup::Image(32,32, Iup::CreateImg(img_bits2))
  98.   Iup::SetHandle ("img2", img)
  99.   Iup::SetAttribute (img, "0", "0 0 0")
  100.   Iup::SetAttribute (img, "1", "0 255 0")
  101.   Iup::SetAttribute (img, "2", "BGCOLOR")
  102.   Iup::SetAttribute (img, "3", "255 0 0")
  103.  
  104.   mnu = Iup::Menu( _
  105.   Iup::Submenu("IupSubmenu 1",Iup::Menu( _
  106.       Iup::SetAttributes(Iup::Item("IupItem 1 Checked"), "VALUE=ON"), _
  107.       Iup::Separator(), _
  108.       Iup::SetAttributes(Iup::Item("IupItem 2 Disabled"), "ACTIVE=NO"))), _
  109.     Iup::Item("IupItem 3"), _
  110.     Iup::Item("IupItem 4"))
  111.   Iup::SetHandle("mnu",mnu)
  112.  
  113.   _frm_1 = Iup::Frame( _
  114.     Iup::Vbox( _
  115.       Iup::Button("Button Text"), _
  116.       Iup::SetAttributes(Iup::Button(), "IMAGE=img1"), _
  117.       Iup::SetAttributes(Iup::Button(), "IMAGE=img1,IMPRESS=img2")))
  118.   Iup::SetAttribute(_frm_1,IUP_TITLE,"IupButton")
  119.  
  120.   _frm_2 = Iup::Frame( _
  121.     Iup::Vbox( _
  122.       Iup::Label("Label Text"), _
  123.       Iup::SetAttributes(Iup::Label(""), "SEPARATOR=HORIZONTAL"), _
  124.       Iup::SetAttributes(Iup::Label(""), "IMAGE=img1")))
  125.   Iup::SetAttribute(_frm_2,IUP_TITLE,"IupLabel")
  126.  
  127.   _frm_3 = Iup::Frame( _
  128.     Iup::Vbox( _
  129.       Iup::SetAttributes(Iup::Toggle("Toggle Text"), "VALUE=ON"), _
  130.       Iup::SetAttributes(Iup::Toggle(""), "IMAGE=img1,IMPRESS=img2"), _
  131.       Iup::SetAttributes(Iup::Frame(Iup::Radio(Iup::Vbox( _
  132.         Iup::Toggle("Toggle Text"), _
  133.         Iup::Toggle("Toggle Text")))), "TITLE=IupRadio")))
  134.   Iup::SetAttribute(_frm_3,IUP_TITLE,"IupToggle")
  135.  
  136.   _text_1 = Iup::Text()
  137.   Iup::SetAttribute(_text_1,IUP_VALUE,"IupText Text")
  138.   Iup::SetAttribute(_text_1,IUP_SIZE,"80x")
  139.  
  140.   _ml_1 = Iup::MultiLine()
  141.   Iup::SetAttribute(_ml_1,IUP_VALUE,"IupMultiline Text\nSecond Line\nThird Line")
  142.   Iup::SetAttribute(_ml_1,IUP_EXPAND,"YES")
  143.   Iup::SetAttribute(_ml_1,IUP_SIZE,"80x60")
  144.  
  145.   _frm_4 = Iup::Frame(Iup::Vbox( _
  146.     _text_1, _
  147.     _ml_1))
  148.   Iup::SetAttribute(_frm_4,IUP_TITLE,"IupText/IupMultiline")
  149.  
  150.   _list_1 = Iup::List()
  151.   Iup::SetAttribute(_list_1,IUP_EXPAND,"YES")
  152.   Iup::SetAttribute(_list_1,IUP_VALUE,"1")
  153.   Iup::SetAttribute(_list_1,"1","Item 1 Text")
  154.   Iup::SetAttribute(_list_1,"2","Item 2 Text")
  155.   Iup::SetAttribute(_list_1,"3","Item 3 Text")
  156.  
  157.   _list_2 = Iup::List()
  158.   Iup::SetAttribute(_list_2,IUP_DROPDOWN,"YES")
  159.   Iup::SetAttribute(_list_2,IUP_EXPAND,"YES")
  160.   Iup::SetAttribute(_list_2,IUP_VALUE,"2")
  161.   Iup::SetAttribute(_list_2,"1","Item 1 Text")
  162.   Iup::SetAttribute(_list_2,"2","Item 2 Text")
  163.   Iup::SetAttribute(_list_2,"3","Item 3 Text")
  164.  
  165.   _list_3 = Iup::List()
  166.   Iup::SetAttribute(_list_3,"EDITBOX","YES")
  167.   Iup::SetAttribute(_list_3,IUP_EXPAND,"YES")
  168.   Iup::SetAttribute(_list_3,IUP_VALUE,"3")
  169.   Iup::SetAttribute(_list_3,"1","Item 1 Text")
  170.   Iup::SetAttribute(_list_3,"2","Item 2 Text")
  171.   Iup::SetAttribute(_list_3,"3","Item 3 Text")
  172.  
  173.   _frm_5 =  Iup::Frame(Iup::Vbox( _
  174.       _list_1, _
  175.       _list_2, _
  176.       _list_3))
  177.   Iup::SetAttribute(_frm_5,IUP_TITLE,"IupList")
  178.  
  179.   _hbox_1 = Iup::Hbox( _
  180.     _frm_1, _
  181.     _frm_2, _
  182.     _frm_3, _
  183.     _frm_4, _
  184.     _frm_5)
  185.  
  186.   _cnv_1 = Iup::Canvas()
  187.   Iup::SetAttribute(_cnv_1,IUP_POSX,"0.0")
  188.   Iup::SetAttribute(_cnv_1,IUP_POSY,"0.0")
  189.   Iup::SetAttribute(_cnv_1,IUP_BGCOLOR,"128 255 0")
  190.  
  191.   _vbox_1 = Iup::Vbox( _
  192.     _hbox_1, _
  193.     _cnv_1)
  194.   Iup::SetAttribute(_vbox_1,IUP_MARGIN,"5x5")
  195.   Iup::SetAttribute(_vbox_1,IUP_ALIGNMENT,"ARIGHT")
  196.   Iup::SetAttribute(_vbox_1,IUP_GAP,"5")
  197.  
  198.   dlg = Iup::Dialog(_vbox_1)
  199.   Iup::SetHandle("dlg",dlg)
  200.   Iup::SetAttribute(dlg,IUP_MENU,"mnu")
  201.   Iup::SetAttribute(dlg,IUP_TITLE,"IupDialog Title")
  202.  
  203. END SUB
  204.  
  205. ' MAIN
  206.  
  207.   Iup::Open()
  208.   init_dialog()
  209.   Iup::Show(Iup::GetHandle("dlg"))
  210.   Iup::MainLoop()
  211.   Iup::Close()
  212.  
52
ScriptBasic Blog / Re: ScriptBasic 3.0
« Last post by John on April 21, 2024, 06:36:00 PM »
A simple editor example.



Code: ScriptBasic
  1. ' IUP Simple Editor
  2.  
  3. IMPORT iup.bas
  4.  
  5. CONST IUP_CENTER = 0xFFFF
  6. CONST IUP_DEFAULT = -2
  7.  
  8.  
  9. FUNCTION Open_CB
  10.   LOCAL filedlg, filename, och, olen, fstr
  11.   filedlg = IUP::FileDlg()
  12.   IUP::SetAttribute(filedlg, "DIALOGTYPE", "OPEN")
  13.   IUP::SetAttribute(filedlg, "EXTFILTER", "Text Files|*.txt|All Files|*.*|")
  14.   IUP::Popup(filedlg, IUP_CENTER, IUP_CENTER)
  15.   IF IUP::GetInt(filedlg, "STATUS") <> -1 THEN
  16.     filename = IUP::GetAttribute(filedlg, "VALUE")
  17.     och = FREEFILE()
  18.     OPEN filename FOR BINARY AS och
  19.     olen = FILELEN(filename)
  20.     fstr = INPUT(olen, och)
  21.     IUP::StoreAttribute(multitext, "VALUE", fstr)
  22.     CLOSE(och)
  23.   END IF
  24.   IUP::Destroy(filedlg)
  25.   Open_CB = IUP_DEFAULT
  26. END FUNCTION
  27.  
  28.  
  29. FUNCTION SaveAs_CB
  30.   LOCAL filedlg, filename, sch, fstr
  31.   filedlg = IUP::FileDlg()
  32.   IUP::SetAttribute(filedlg, "DIALOGTYPE", "SAVE")
  33.   IUP::SetAttribute(filedlg, "EXTFILTER", "Text Files|*.txt|All Files|*.*|")
  34.   IUP::Popup(filedlg, IUP_CENTER, IUP_CENTER)
  35.   IF IUP::GetInt(filedlg, "STATUS") <> -1 THEN
  36.     filename = IUP::GetAttribute(filedlg, "VALUE")
  37.     fstr = IUP::GetAttribute(multitext, "VALUE")
  38.     sch = FREEFILE()
  39.     OPEN filename FOR BINARY AS sch
  40.     PRINT #sch, fstr
  41.     CLOSE(sch)
  42.   END IF
  43.   IUP::Destroy(filedlg)
  44.   SaveAs_CB = IUP_DEFAULT
  45. END FUNCTION
  46.  
  47.  
  48. FUNCTION Font_CB
  49.   LOCAL fontdlg, font
  50.   fontdlg = IUP::FontDlg()
  51.   font = IUP::GetAttribute(multitext, "FONT")
  52.   font &= CHR(0)
  53.   IUP::StoreAttribute(fontdlg, "VALUE", font)
  54.   IUP::Popup(fontdlg, IUP_CENTER, IUP_CENTER)
  55.   IF IUP::GetInt(fontdlg, "STATUS") = 1 THEN
  56.     font = IUP::GetAttribute(fontdlg, "VALUE")
  57.     IUP::StoreAttribute(multitext, "FONT", font)
  58.   END IF
  59.   IUP::Destroy(fontdlg)
  60.   Font_CB = IUP_DEFAULT
  61. END FUNCTION
  62.  
  63.  
  64. FUNCTION About_CB
  65.   IUP::Message("About", "   Simple Editor\n\nIUP ScriptBasic Binding")
  66.   About_CB = IUP_DEFAULT
  67. END FUNCTION
  68.  
  69.  
  70. FUNCTION TextPos
  71.   col = IUP::GetTextX()
  72.   lin = IUP::GetTextY()
  73.   IUP::SetAttribute(lbl_statusbar, "TITLE", "Lin " & lin & ", Col " & col)
  74. ' PRINT "Lin " & lin & ", Col " & col, "\n"
  75.  TextPos = IUP_DEFAULT
  76. END FUNCTION  
  77.  
  78. FUNCTION Find_CB
  79.   find_dlg = Iup::GetAttribute(item_find, "FIND_DIALOG")
  80.   config = Iup::GetAttribute(multitext, "CONFIG")
  81.   Iup::Show(config)
  82.   Find_CB = IUP_DEFAULT
  83. END FUNCTION  
  84.  
  85.  
  86. SUB Win_exit
  87.   Iup::ExitLoop = TRUE
  88. END SUB
  89.  
  90.  
  91. ' *** MAIN ***
  92.  
  93. IUP::Open
  94. IUP::ImageLibOpen()
  95.  
  96.  
  97. multitext = IUP::Text()
  98. tbox = IUP::Vbox(multitext)
  99. IUP::SetAttribute(multitext, "MULTILINE", "YES")
  100. IUP::SetAttribute(multitext, "EXPAND", "YES")
  101. ' IUP::SetAttribute(multitext, "VISIBLECOLUMNS", "20")
  102. Iup::SetCallback(multitext, "CARET_CB", ADDRESS(TextPos()))
  103.  
  104. lbl_statusbar = IUP::Label("Lin 1, Col 1")
  105. IUP::SetAttribute(lbl_statusbar, "NAME", "STATUSBAR")
  106. IUP::SetAttribute(lbl_statusbar, "EXPAND", "HORIZONTAL")
  107. IUP::SetAttribute(lbl_statusbar, "PADDING", "10x5")
  108.  
  109. item_open = IUP::Item("Open")
  110. btn_open = IUP::Button()
  111. IUP::SetAttribute(btn_open, "IMAGE", "IUP_FileOpen")
  112. IUP::SetAttribute(btn_open, "FLAT", "Yes")
  113. IUP::SetAttribute(btn_open, "CANFOCUS", "No")
  114.  
  115. item_saveas = IUP::Item("Save As")
  116. btn_save = IUP::Button("")
  117. IUP::SetAttribute(btn_save, "IMAGE", "IUP_FileSave")
  118. IUP::SetAttribute(btn_save, "FLAT", "Yes")
  119. IUP::SetAttribute(btn_save, "CANFOCUS", "No")
  120.  
  121. item_exit = IUP::Item("Exit")
  122.  
  123. item_find = IUP::Item("Find...")
  124. btn_find = IUP::Button("")
  125. IUP::SetAttribute(btn_find, "IMAGE", "IUP_EditFind")
  126. IUP::SetAttribute(btn_find, "FLAT", "Yes")
  127. IUP::SetAttribute(btn_find, "CANFOCUS", "No")
  128.  
  129. toolbar_hb = IUP::Hbox( _
  130.     btn_open, _
  131.     btn_save, _
  132.     IUP::SetAttributes(IUP::Label(), "SEPARATOR=VERTICAL"), _
  133.     btn_find)
  134.  
  135. IUP::SetAttribute(toolbar_hb, "MARGIN", "5x5")
  136. IUP::SetAttribute(toolbar_hb, "GAP", "2")
  137.  
  138. item_goto = IUP::Item("Go To...")
  139. item_font = IUP::Item("Font...")
  140. item_about = IUP::Item("About...")
  141.  
  142. Iup::SetCallback(item_exit,"ACTION", ADDRESS(Win_exit()))
  143. IUP::SetCallback(item_open, "ACTION", ADDRESS(Open_CB()))
  144. IUP::SetCallback(item_saveas, "ACTION", ADDRESS(SaveAs_CB()))
  145. IUP::SetCallback(item_font, "ACTION", ADDRESS(Font_CB()))
  146. IUP::SetCallback(item_about, "ACTION", ADDRESS(About_CB()))
  147. IUP::SetCallback(item_find, "ACTION", ADDRESS(Find_CB()))
  148.  
  149. file_menu = IUP::Menu( _
  150.     item_open, _
  151.     item_saveas, _
  152.     IUP::Separator(), _
  153.     item_exit)
  154. edit_menu = IUP::Menu( _
  155.     item_find, _
  156.     item_goto)
  157. format_menu = IUP::Menu(item_font)
  158. help_menu = IUP::Menu(item_about)
  159.  
  160. sub_menu_file = IUP::Submenu("File", file_menu)
  161. sub_menu_edit = IUP::Submenu("Edit", edit_menu)
  162. sub_menu_format = IUP::Submenu("Format", format_menu)
  163. sub_menu_help = IUP::Submenu("Help", help_menu)
  164.  
  165. menu = IUP::Menu( _
  166.     sub_menu_file, _
  167.     sub_menu_edit, _
  168.     sub_menu_format, _
  169.     sub_menu_help)
  170.  
  171.  
  172. vbox = IUP::Vbox(toolbar_hb, tbox, lbl_statusbar)
  173.  
  174. dlg = IUP::Dialog(vbox)
  175. IUP::SetAttributeHandle(dlg, "MENU", menu)
  176. IUP::SetAttribute(dlg, "TITLE", "Simple Editor")
  177. IUP::SetAttribute(dlg, "SIZE", "QUARTERxQUARTER")
  178. IUP::ShowXY(dlg, IUP_CENTER, IUP_CENTER)
  179. IUP::SetAttribute(dlg, "USERSIZE")
  180. Iup::SetCallback(dlg, "CLOSE_CB", ADDRESS(Win_exit()))
  181.  
  182. IUP::MainLoop
  183. IUP::Close
  184.  

53
ScriptBasic Blog / Re: ScriptBasic 3.0
« Last post by John on April 21, 2024, 04:39:18 PM »
I was able to get IUP working with ScriptBasic Windows 64 bit. This is an example is using sbw64.exe which has Windows styles support and runs as a true Windows app.

I don't plan on releasing IUP until it's tested on Linux and a direct callback method upgrade is done. I use VB6 + VBCCR to build COM form / class object DLLs that ScriptBasic uses on Windows 32 bit.



Code: ScriptBasic
  1. ' IUP Online Dictionary
  2.  
  3. IMPORT iup.bas
  4.  
  5. servers[0]="dict.org"
  6. servers[1]="dict1.us.dict.org"
  7. servers[2]="all.dict.org"
  8.  
  9. about="""This is a Demo
  10. of the IUP GUI Binding
  11. for Scriptbasic"""
  12.  
  13. ' Initialize IUP
  14. Iup::Open()
  15.  
  16. ' Create main window
  17.  
  18. win = Iup::Create("dialog")
  19.   Iup::SetAttributes(win, "TITLE=\"ScriptBasic IUP Online Dictionary\", SIZE=500x300")
  20.   Iup::SetCallback(win,"CLOSE_CB",ADDRESS(Win_exit()))
  21.  
  22. ' Create container to house ALL GUI objects
  23.  
  24. vbox = Iup::Create("vbox")
  25.   Iup::SetAttributes(vbox, "MARGIN=10x10")
  26.  
  27. ' Create server panel
  28.  
  29. topBox = Iup::Create("hbox")
  30.   Iup::SetAttributes(topBox, "GAP=10")
  31.   Iup::Append(vbox, topBox)
  32. serverFrame = Iup::Create("frame")
  33.   Iup::SetAttributes(serverFrame, "TITLE=Servers, EXPAND=YES")
  34.   Iup::Append(topBox, serverFrame)
  35. serverBox = Iup::Create("hbox")
  36.   Iup::SetAttributes(serverBox, "GAP=5")
  37.   Iup::Append(serverFrame, serverBox)
  38. serverCombo = Iup::Create("list")
  39.   Iup::SetAttributes(serverCombo, "DROPDOWN=YES, SIZE=120x, EXPAND=HORIZONTAL, VALUE=1")
  40.   Iup::Append(serverBox, serverCombo)
  41.   Iup::SetCallback(serverCombo, "ACTION", ADDRESS(serverCombo_selected()))
  42. btnFetch = Iup::Create("button")
  43.   Iup::SetAttributes(btnFetch, "TITLE=Fetch, SIZE = 50x")
  44.   Iup::Append(serverBox, btnFetch)
  45.   Iup::SetCallback(btnFetch, "ACTION", ADDRESS(btnFetch_clicked()))
  46.  
  47. ' Create control panel
  48.  
  49. controlFrame = Iup::Create("frame")
  50.   Iup::SetAttributes(controlFrame, "TITLE=Controls")
  51.   Iup::Append(topBox, controlFrame)
  52. controlBox = Iup::Create("hbox")
  53.   Iup::SetAttributes(controlBox, "GAP=5")
  54.   Iup::Append(controlFrame, controlBox)
  55. btnAbout = Iup::Create("button")
  56.   Iup::SetAttributes(btnAbout, "TITLE=About, SIZE = 50x")
  57.   Iup::Append(controlBox, btnAbout)
  58.   Iup::SetCallback(btnAbout, "ACTION", ADDRESS(btnAbout_clicked()))
  59. btnClear = Iup::Create("button")
  60.   Iup::SetAttributes(btnClear, "TITLE=Clear, SIZE = 50x")
  61.   Iup::Append(controlBox, btnClear)
  62.   Iup::SetCallback(btnClear, "ACTION", ADDRESS(btnClear_clicked()))
  63. btnExit = Iup::Create("button")
  64.   Iup::SetAttributes(btnExit, "TITLE=Exit, SIZE = 50x")
  65.   Iup::Append(controlBox, btnExit)
  66.   Iup::SetCallback(btnExit,"ACTION",ADDRESS(Win_exit()))
  67.  
  68. ' Create dictionary panel
  69.  
  70. dictFrame = Iup::Create("frame")
  71.   Iup::SetAttributes(dictFrame, "TITLE=Dictionaries")
  72.   Iup::Append(vbox, dictFrame)
  73. serverList = Iup::Create("list")
  74.   Iup::SetAttributes(serverList, "EXPAND=YES, VISIBLELINES=1")
  75.   Iup::Append(dictFrame, serverList)
  76.   Iup::SetCallback(serverList, "ACTION", ADDRESS(serverList_selected()))
  77.  
  78. ' Create text part
  79.  
  80. transFrame = IUP::Create("frame")
  81.   Iup::SetAttributes(transFrame, "TITLE=Translation")
  82.   Iup::Append(vbox, transFrame)
  83. text = Iup::Create("text")
  84.   Iup::SetAttributes(text, "MULTILINE=YES, EXPAND=YES")
  85.   Iup::Append(transFrame, text)
  86.  
  87. ' Create entry and search button
  88.  
  89. bottomBox = Iup::Create("hbox")
  90.   Iup::SetAttributes(bottomBox, "GAP=10")
  91.   Iup::Append(vbox, bottomBox)
  92. label = Iup::Create("label")
  93.   Iup::SetAttributes(label, "TITLE=\"Enter Word to Search For:\", SIZE=x12")
  94.   Iup::Append(bottomBox, label)
  95. entry = Iup::Create("text")
  96.   Iup::SetAttributes(entry, "EXPAND=HORIZONTAL")
  97.   Iup::Append(bottomBox, entry)
  98. btnSearch = Iup::Create("button")
  99.   Iup::SetAttributes(btnSearch,"TITLE=Search, SIZE=50x")
  100.   Iup::Append(bottomBox, btnSearch)
  101.   Iup::SetCallback(btnSearch, "ACTION", ADDRESS(btnSearch_clicked()))
  102. chkAll = Iup::Create("toggle")
  103.   Iup::SetAttributes(chkAll, "TITLE=ALL, SIZE=x12")
  104.   Iup::Append(bottomBox, chkAll)
  105. chkUTF = Iup::Create("toggle")
  106.   Iup::SetAttributes(chkUTF, "TITLE=UTF-8, SIZE=x12")
  107.   Iup::Append(bottomBox, chkUTF)
  108.  
  109. ' Add the main GUI container to the Window
  110.  
  111. Iup::Append(win, vbox)
  112.  
  113. ' Setup dialog defaults
  114.  
  115. Iup::Show(win)
  116. Iup::SetFocus(btnFetch)
  117. FOR i = 0 TO UBOUND(servers)
  118.   Iup::SetAttribute(serverCombo, "APPENDITEM", servers[i])
  119. NEXT
  120. Iup::SetAttribute(serverCombo, "VALUE", "1")
  121. Iup::Update(serverCombo)
  122. server_selection = servers[0]
  123.  
  124. ' Main processing loop
  125.  
  126. Iup::MainLoop()
  127. Iup::Close()
  128. END
  129.  
  130. ' Callback routines
  131.  
  132. SUB Win_exit
  133.   Iup::ExitLoop = TRUE
  134. END SUB
  135.  
  136. SUB btnAbout_clicked
  137.   Iup::Message("ABOUT", about)
  138. END SUB
  139.  
  140. SUB serverCombo_selected
  141.   server_selection = Iup::GetListText()
  142. END SUB
  143.  
  144. SUB serverList_selected
  145.   whichDictionary = Iup::GetListText()
  146. END SUB
  147.  
  148. SUB btnFetch_clicked
  149.   LOCAL dat, total, count
  150.   ON ERROR GOTO G_NetError
  151.   OPEN server_selection & ":2628" FOR SOCKET AS #1
  152.   PRINT#1,"SHOW DB\n"
  153.   LINE INPUT#1, dat
  154.   LINE INPUT#1, dat
  155.   count = 0
  156.   WHILE LEFT(dat, 1) <> "."
  157.     LINE INPUT#1, dat
  158.     IF LEFT(dat, 1) <> "." THEN total[count] = TRIM(dat)
  159.     count+=1
  160.   WEND
  161.   PRINT#1,"QUIT\n"
  162.   CLOSE(#1)
  163.   FOR cnt = 0 TO count - 2
  164.     Iup::SetAttribute(serverList, "APPENDITEM", total[cnt])
  165.   NEXT
  166.   Iup::SetAttribute(serverList, "VALUE", "1")
  167.   Iup::Update(serverCombo)
  168.   whichDictionary = total[0]
  169.   EXIT SUB
  170.  
  171.   G_NetError:
  172.   PRINT "Server ",server_selection," not available. (",ERROR,")\n"
  173. END SUB
  174.  
  175. SUB btnClear_clicked
  176.   Iup::ClearList(serverList)
  177.   Iup::SetAttribute(text, "VALUE", "")
  178.   Iup::SetAttribute(entry, "VALUE", "")
  179. END SUB
  180.  
  181. SUB btnSearch_clicked
  182.   LOCAL dict, dat, total, info
  183.   IUP::SetAttribute(text, "VALUE","Fetching....")
  184.   ON ERROR GOTO L_NetError
  185.   dict = LEFT(whichDictionary, INSTR(whichDictionary, " "))
  186.   OPEN server_selection & ":2628" FOR SOCKET AS 1
  187.   IF Iup::GetAttribute(chkAll, "VALUE") THEN
  188.     PRINT#1,"DEFINE * " & Iup::GetAttribute(entry,"VALUE") & "\n"
  189.   ELSE
  190.     PRINT#1,"DEFINE " & dict & " " & Iup::GetAttribute(entry,"VALUE") & "\n"
  191.   END IF
  192.   REPEAT
  193.     LINE INPUT#1, dat
  194.     IF LEFT(dat, 3) = "151" THEN
  195.       total$ &= "------------------------------\r\n"
  196.       total$ &= RIGHT(dat, LEN(dat) - LEN(Iup::GetAttribute(entry, "VALUE")) - LEN(dict))
  197.       total$ &= "------------------------------\r\n"
  198.       REPEAT
  199.         LINE INPUT#1, info
  200.         info = REPLACE(info, CHR(34), CHR(92) & CHR(34))
  201.         IF LEFT(info, 1) <> "." THEN total &= TRIM(info) & "\n"
  202.       UNTIL LEFT(info, 1) = "."
  203.       total &= "\n"
  204.     END IF
  205.   UNTIL LEFT(dat, 3) = "250" OR VAL(LEFT(dat, 3)) > 499
  206.   PRINT#1,"QUIT\n"
  207.   CLOSE(#1)
  208.   IF LEFT(dat, 3) = "552" THEN
  209.     total = "No match found."
  210.   ELSE IF LEFT(dat, 3) = "501" THEN
  211.     total = "Select a dictionary first!"
  212.   ELSE IF LEFT(dat, 3) = "550" THEN
  213.     total = "Invalid database!"
  214.   END IF
  215.   Iup::SetAttribute(text, "VALUE", total)
  216. EXIT SUB
  217.  
  218. L_NetError:
  219.   dat[0] = "Could not lookup word! (" & ERROR & ")"
  220.   Iup::SetAttribute(text, "VALUE", dat)
  221. END SUB
  222.  
54
ScriptBasic Blog / Re: ScriptBasic 3.0
« Last post by John on April 19, 2024, 03:45:00 PM »
If you would like to have both 32 and 64 bit versions of ScriptBasic for Windows installed, this is how I have my system setup.

ScriptBasic by default uses SCRIBA.INI as its compiled configuration file with both 32 and 64 bit versions. If you create a scriba.conf configuration file in your bin directory the SCRIBA.INI isn't needed. The other issue with using the C:\Windows directory is it requires ADMIN privileges to create/change/delete it.

1. Install the 32 bit version and move the SCRIBA.INI (C:\Windows) to your ScriptBasic install bin directory and rename it to scriba.conf. Rename SCRIBA.INI.txt to scriba.conf.txt.

2. Install the 64 bit version and do the same as the previous step. In addition rename the 64 bit sbw.exe version to sbwin.exe so it doesn't conflict with the 32 bit version.

To modify your configuration change directory to your bin and execute this command.  This assumes you installed ScriptBasic in the default directories.

32 Bit
sbc -f C:\ScriptBasic\bin\scriba.conf -k scriba.conf.txt

64 Bit
scriba -f C:\ScriptBasic64\bin\scriba.conf -k scriba.conf.txt

The 32 bit version uses xxxx.sbi for IMPORT / INCLUDE files. The 64 bit version uses .bas. Keep that in mind if you're sharing scripts between versions.


55
ScriptBasic Blog / Re: ScriptBasic 3.0
« Last post by John on April 17, 2024, 09:19:49 PM »
This OxygenBasic example embedding ScriptBasic (libscriab.dll) gets the current weather with the curl extension module and using the LIKE ScriptBasic function to parse the temperature from the JSON response.

weather.o2bas
Code: Text
  1. ' O2 SB cURL OpenWeather Example
  2.  
  3. % filename "weather.exe"
  4. includepath "$/inc/"
  5. uses rtl64
  6. include "sbembed.inc"
  7. #console
  8. uses console
  9.  
  10. sys pProgram, fnsn
  11. sbData *arg
  12. sbData *argr
  13. string cr = chr(13,10)
  14.  
  15. pProgram = scriba_new(@newmem, @freemem)
  16. scriba_LoadConfiguration(pProgram, "C:\Windows\SCRIBA.INI")
  17. scriba_SetFileName(pProgram, "weather.sb")
  18. scriba_LoadSourceProgram(pProgram)
  19. scriba_Run(pProgram, "")
  20.  
  21. @arg = scriba_NewSbArgs(pProgram, "s", "Lynden,US")
  22. fnsn = scriba_LookupFunctionByName(pProgram, "main::get_weather")
  23. @argr = scriba_NewSbArgs(pProgram,"s", "")
  24. scriba_CallArgEx(pProgram, fnsn, argr, 1, arg)
  25. string json = argr.str
  26. string mask = `*temp":*,*`
  27. @arg = scriba_NewSbArgs(pProgram, "s s", json, mask)
  28. fnsn = scriba_LookupFunctionByName(pProgram, "main::sb_like")
  29. @argr = scriba_NewSbArgs(pProgram,"i", 0)
  30. scriba_CallArgEx(pProgram, fnsn, argr, 2, arg)
  31. @arg = scriba_NewSbArgs(pProgram, "i", 2)
  32. fnsn = scriba_LookupFunctionByName(pProgram, "main::sb_match")
  33. @argr = scriba_NewSbArgs(pProgram,"s", "")
  34. scriba_CallArgEx(pProgram, fnsn, argr, 1, arg)
  35. print "Lynden WA Temperature is " + argr.str + " F" + cr
  36.  
  37. scriba_DestroySbArgs(pProgram, arg, 2)
  38. scriba_DestroySbArgs(pProgram, argr, 1)
  39. scriba_destroy(pProgram)
  40.  

weather.sb
Code: ScriptBasic
  1. ' OpenWeather - Embedded Example
  2.  
  3. IMPORT curl.bas
  4.  
  5. FUNCTION Get_Weather(place)
  6.   ch = curl::init()
  7.   curl::option(ch, "URL", "https://api.openweathermap.org/data/2.5/weather?q=" & place & "&units=imperial&appid=OpenWeather_API-KEY")
  8.   curl::option(ch, "CUSTOMREQUEST", "GET")
  9.   response = curl::perform(ch)
  10.   curl::finish(ch)
  11.   PRINT response,"\n\n"
  12.   Get_Weather = response
  13. END FUNCTION
  14.  
  15. ' REPLACE
  16. FUNCTION sb_replace(basestr, searchstr, replacestr, occurances, startpos)
  17.   sb_replace = REPLACE(basestr, searchstr, replacestr, occurances, startpos)
  18. END FUNCTION
  19.  
  20. ' LIKE
  21. FUNCTION sb_like(basestr, mask)
  22.   ok = basestr LIKE mask
  23.   sb_like = ok
  24. END FUNCTION
  25.  
  26. ' MATCH
  27. FUNCTION sb_match(segment)
  28.   sb_match = JOKER(segment)
  29. END FUNCTION  
  30.  

Output

C:\OxygenBasic\demos\ScriptBasic>weather
{"coord":{"lon":-122.4521,"lat":48.9465},"weather":[{"id":800,"main":"Clear","description":"clear sky","icon":"01n"}],"base":"stations","main":{"temp":46.13,"feels_like":46.13,"temp_min":43.59,"temp_max":48.63,"pressure":1028,"humidity":58},"visibility":10000,"wind":{"speed":1.01,"deg":166,"gust":3},"clouds":{"all":0},"dt":1713413156,"sys":{"type":2,"id":2090762,"country":"US","sunrise":1713359602,"sunset":1713409479},"timezone":-25200,"id":5802035,"name":"Lynden","cod":200}

Lynden WA Temperature is 46.13 F

C:\OxygenBasic\demos\ScriptBasic>

56
ScriptBasic Blog / Re: ScriptBasic 3.0
« Last post by John on April 16, 2024, 10:16:36 PM »
I found a workaround for the issue. It seems the problem is with assigning with double literals.

Code: Text
  1. double dp = 2.2
  2. scriba_SetVariable(pProgram, v_b, SBT_DOUBLE, 0, dp, "", 0)
  3.  

Output

C:\OxygenBasic\demos\ScriptBasic>getsetvars
1
0.2
Three

101
2.2000000000000002
Thirty Three

C:\OxygenBasic\demos\ScriptBasic>

57
ScriptBasic Blog / Re: ScriptBasic 3.0
« Last post by John on April 16, 2024, 08:44:00 PM »
I tried a different embedding example that was more complex and refined. (o2 embed include) The problem seems to be OxygenBasic setting a double in a structure. Getting a double seems to work.

Using SBT to develop your embedding scripts before using them in your development environment is handy.

Embedding ScriptBasic also gives you access to all the extension modules it supports including COM.

getsetvars.o2bas
Code: Text
  1. % filename "getsetvars.exe"
  2. includepath "$/inc/"
  3. uses rtl64
  4. include "sbembed.inc"
  5. #console
  6. uses console
  7.  
  8. sys pProgram
  9. sbData *arg
  10. string cr = chr(13,10)
  11.  
  12. string src = `IMPORT "testvars.sb"` + cr
  13.  
  14. pProgram = scriba_new(@newmem, @freemem)
  15. scriba_LoadConfiguration(pProgram, "C:\Windows\SCRIBA.INI")
  16. scriba_SetFileName(pProgram, "none")
  17. scriba_LoadProgramString(pProgram, src, len(src))
  18. scriba_Run(pProgram, "")
  19.  
  20. sys v_a = scriba_LookupVariableByName(pProgram, "main::a")
  21. sys v_b = scriba_LookupVariableByName(pProgram, "main::b")
  22. sys v_c = scriba_LookupVariableByName(pProgram, "main::c")
  23.  
  24. ' Get defined variable values
  25.  
  26. scriba_GetVariable(pProgram, v_a, @@arg)
  27. print arg.lng + cr
  28. scriba_GetVariable(pProgram, v_b, @@arg)
  29. print arg.dbl + cr
  30. scriba_GetVariable(pProgram, v_c, @@arg)
  31. print arg.str + cr + cr
  32.  
  33. ' Set variable values
  34.  
  35. scriba_SetVariable(pProgram, v_a, SBT_LONG, 101, 0.0, "", 0)
  36. scriba_SetVariable(pProgram, v_b, SBT_DOUBLE, 0, 2.2, "", 0)
  37. scriba_SetVariable(pProgram, v_c, SBT_STRING, 0, 0.0, "Thirty Three", 12)
  38.  
  39. ' Get changed variable values
  40.  
  41. scriba_GetVariable(pProgram, v_a, @@arg)
  42. print arg.lng + cr
  43. scriba_GetVariable(pProgram, v_b, @@arg)
  44. print arg.dbl + cr
  45. scriba_GetVariable(pProgram, v_c, @@arg)
  46. print arg.str + cr
  47.  
  48. scriba_DestroySbArgs(pProgram, arg, 1)
  49. scriba_destroy(pProgram)
  50.  

sbembed.inc
Code: Text
  1. ' ScriptBasic Embedding Include
  2.  
  3. % libScriba = "libScriba.dll"
  4.  
  5. type SbData
  6.   typ as dword
  7.   siz as dword
  8.   union {
  9.     undef as sys
  10.     dbl   as double
  11.     lng   as sys
  12.     str   as char*
  13.     strz  as char*
  14.   }
  15. end type
  16.  
  17. #define SBT_UNDEF  0
  18. #define SBT_DOUBLE 1
  19. #define SBT_LONG   2
  20. #define SBT_STRING 3
  21. #define SBT_ZCHAR  4
  22.  
  23. sys sb = LoadLibrary libScriba
  24. extern ms64
  25.   bind sb
  26.   {
  27.   scriba_new
  28.   scriba_SetStdin()
  29.   scriba_SetStdout()
  30.   scriba_SetEmbedPointer()
  31.   scriba_LoadConfiguration
  32.   scriba_destroy
  33.   scriba_DestroySbData
  34.   scriba_SetFileName
  35.   scriba_LoadSourceProgram
  36.   scriba_LoadProgramString
  37.   scriba_Run
  38.   scriba_GetVariable
  39.   scriba_SetVariable
  40.   scriba_LookupVariableByName
  41.   scriba_LookupFunctionByName
  42.   scriba_Call
  43.   scriba_CallArg
  44.   scriba_NewSbArgs
  45.   scriba_CallArgEx
  46.   scriba_DestroySbArgs
  47.   scriba_DestroySbData
  48.   scriba_NewSbString
  49.   }
  50. end extern
  51.  
  52. function newmem ms64 (sys le) as sys, export
  53.   return getmemory le
  54. end function
  55.  
  56. function freemem ms64 (sys p) export
  57.   freememory p
  58. end function
  59.  

testvars.sb
Code: ScriptBasic
  1. a = 1
  2. b = .2
  3. c = "Three"
  4.  

Output

C:\OxygenBasic\demos\ScriptBasic>getsetvars
1
0.2
Three

101
#qNAN
Thirty Three

C:\OxygenBasic\demos\ScriptBasic>

58
ScriptBasic Blog / Re: ScriptBasic 3.0
« Last post by John on April 16, 2024, 06:51:04 PM »
I gave the OxygenBasic embedding ScriptBasic libscriba.dll another try with Charles's update of a week ago. It still has the double (vision  :o) issue.


59
ScriptBasic Blog / Re: ScriptBasic 3.0
« Last post by John on April 15, 2024, 07:24:56 PM »
I added the ScriptBasic games to the repository.

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.
60
ScriptBasic Blog / 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.  


Pages: 1 ... 4 5 [6] 7 8 ... 10