Oxygen Basic

Information => Open Forum => Topic started by: Charles Pegge on February 13, 2017, 07:02:40 AM

Title: Corrected DLLCtestDLL for John - Windows 10
Post by: Charles Pegge on February 13, 2017, 07:02:40 AM
Hi John,

My offending line:

static string s="greeting from stringbuf procedure / DLLtestDLL " le chr(13) chr(10)
static string s="greeting from stringbuf procedure / DLLtestDLL " chr(13) chr(10)

2 characters leading to a cascade of dysfunctionality in Windows 10  :o

Code: [Select]
function stringbuf(char*b,sys le)
=================================
static string s="greeting from stringbuf procedure / DLLtestDLL " chr(13) chr(10)
ls=len s+2 'include terminating chars
if ls>le then ls=le
copy strptr b,strptr s,ls
end function


.
Title: Re: Corrected DLLCtestDLL for John - Windows 10
Post by: JRS on February 13, 2017, 08:26:21 AM
Thanks Charles!

I'm also having a problem with showing a console and calling back to a SB function from IUP under Windows 10.

Title: Re: Corrected DLLCtestDLL for John - Windows 10
Post by: JRS on February 14, 2017, 03:26:18 PM
Hi Charles,

I posted a public release of Script BASIC for Window 32 bit in an Inno setup installer file on the www.scriptbasic.org forum.

Let me know if you can get DLLC working with this release so I can include it in the next build.
Title: Re: Corrected DLLCtestDLL for John - Windows 10
Post by: JRS on February 16, 2017, 07:57:42 PM
Charles,

I retested your DLLC examples with the latest O2 release on Windows 10 and all seems well.

I will include DLLC in the next Script BASIC Windows 32 bit build.

Thanks!

John
Title: Re: Corrected DLLCtestDLL for John - Windows 10
Post by: Charles Pegge on February 17, 2017, 07:17:52 AM
Hi John,

I have removed any path specifics in the DLLC tests and IUP tests. So the library invoked is now "IUP.dll".This works with your initial inno installation.

Likewise For the LibScriba embed tests, the programs use "librcriba.inc" without any specified Librarypath.
I can now throw several versions of Libscriba.dll, including a 64 bit version, into c:\scriptBasic\bin for testing.

One important cleanup:

In the boot programs, it is vital that the idat/bdat buffer is non volatile
  bdat=string(8192,chr(0))
  idat=dllsptr(bdat)


not

  idat=dllsptr(string(8192,chr(0)))


.
Title: Re: Corrected DLLCtestDLL for John - Windows 10
Post by: JRS on February 17, 2017, 08:52:14 AM
Charles,

Thanks for testing DLLC with the new Script BASIC Windows 32 bit release. I'm going to try and document the DLLC extension module and extract the testing code examples into a single demo script. I also plan to try using SBT for threaded SB instances and use DLLC for the callback only. The end goal is to get callbacks in the C IUP/SBT working like DLLC.

John

Update: - I wasn't able to get the DLLC callback/mainloop working with SBT.   :-\
Title: Re: Corrected DLLCtestDLL for John - Windows 10
Post by: JRS on February 17, 2017, 09:31:19 PM
I was able to use SBT and run multiple IUP threads. It seems under Windows multiple IUP loops are possible.

iup_3buttonsboot.sb
Code: Script BASIC
  1. IMPORT sbt.sbi
  2. IMPORT iup.sbi
  3.  
  4. sb1 = SB_ThreadStart("iup_3buttons_1.sb",undef,"C:/Windows/SCRIBA.INI")
  5. SB_msSleep(2500)
  6. sb2 = SB_ThreadStart("iup_3buttons_2.sb",undef,"C:/Windows/SCRIBA.INI")
  7.  
  8. LINE INPUT wait
  9.  
  10. Iup::Close()
  11.  
  12. SB_Destroy(sb1)
  13. SB_Destroy(sb2)
  14.  

iup_3buttons_1
Code: Script BASIC
  1. ' IUP Button / Event Example
  2.  
  3. IMPORT iup.sbi
  4.  
  5. SUB Btn1_clicked
  6.   PRINT "Thread 1 - Button 1\n"
  7. END SUB
  8.  
  9. SUB Btn2_clicked
  10.   PRINT "Thread 1 - Button 2\n"
  11. END SUB
  12.  
  13. SUB Btn3_clicked
  14.   PRINT "Thread 1 - Button 3\n"
  15. END SUB
  16.  
  17. SUB Win_exit
  18.   Iup::ExitLoop = TRUE
  19. END SUB
  20.  
  21. Iup::Open()
  22. win = Iup::Create("dialog")
  23. Iup::SetAttributes(win, "TITLE=\"IUP Thread 1\", SIZE=300x")
  24. horzbox = Iup::Create("hbox")
  25. Iup::SetAttributes(horzbox, "GAP=5")
  26. btn1 = Iup::Create("button")
  27. Iup::SetAttributes(btn1, "TITLE=Button1, EXPAND=HORIZONTAL")
  28. btn2 = Iup::Create("button")
  29. Iup::SetAttributes(btn2, "TITLE=Button2, EXPAND=HORIZONTAL")
  30. btn3 = Iup::Create("button")
  31. Iup::SetAttributes(btn3, "TITLE=Button3, EXPAND=HORIZONTAL")
  32. Iup::Append(horzbox, btn1)
  33. Iup::Append(horzbox, btn2)
  34. Iup::Append(horzbox, btn3)
  35. Iup::Append(win, horzbox)
  36. Iup::SetCallback(win,"CLOSE_CB",ADDRESS(Win_exit()))
  37. Iup::SetCallback(btn1,"ACTION",ADDRESS(Btn1_clicked()))
  38. Iup::SetCallback(btn2,"ACTION",ADDRESS(Btn2_clicked()))
  39. Iup::SetCallback(btn3,"ACTION",ADDRESS(Btn3_clicked()))
  40. Iup::Show(win)
  41. Iup::MainLoop()
  42.  

iup_3buttons_2
Code: Script BASIC
  1. ' IUP Button / Event Example
  2.  
  3. IMPORT iup.sbi
  4.  
  5. SUB Btn1_clicked
  6.   PRINT "Thread 2 - Button 1\n"
  7. END SUB
  8.  
  9. SUB Btn2_clicked
  10.   PRINT "Thread 2 - Button 2\n"
  11. END SUB
  12.  
  13. SUB Btn3_clicked
  14.   PRINT "Thread 2 - Button 3\n"
  15. END SUB
  16.  
  17. SUB Win_exit
  18.   Iup::ExitLoop = TRUE
  19. END SUB
  20.  
  21. Iup::Open()
  22. win = Iup::Create("dialog")
  23. Iup::SetAttributes(win, "TITLE=\"IUP Thread 2\", SIZE=300x")
  24. horzbox = Iup::Create("hbox")
  25. Iup::SetAttributes(horzbox, "GAP=5")
  26. btn1 = Iup::Create("button")
  27. Iup::SetAttributes(btn1, "TITLE=Button1, EXPAND=HORIZONTAL")
  28. btn2 = Iup::Create("button")
  29. Iup::SetAttributes(btn2, "TITLE=Button2, EXPAND=HORIZONTAL")
  30. btn3 = Iup::Create("button")
  31. Iup::SetAttributes(btn3, "TITLE=Button3, EXPAND=HORIZONTAL")
  32. Iup::Append(horzbox, btn1)
  33. Iup::Append(horzbox, btn2)
  34. Iup::Append(horzbox, btn3)
  35. Iup::Append(win, horzbox)
  36. Iup::SetCallback(win,"CLOSE_CB",ADDRESS(Win_exit()))
  37. Iup::SetCallback(btn1,"ACTION",ADDRESS(Btn1_clicked()))
  38. Iup::SetCallback(btn2,"ACTION",ADDRESS(Btn2_clicked()))
  39. Iup::SetCallback(btn3,"ACTION",ADDRESS(Btn3_clicked()))
  40. Iup::Show(win)
  41. Iup::MainLoop()
  42.  



.
Title: Re: Corrected DLLCtestDLL for John - Windows 10
Post by: JRS on February 18, 2017, 01:45:38 PM
Not so lucky on Linux 64 bit.


jrs@jrs-laptop:~/sb/examples/iup$ scriba iup_boot3buttons.sb

(scriba:6299): Gdk-WARNING **: scriba: Fatal IO error 11 (Resource temporarily unavailable) on X server :0.

jrs@jrs-laptop:~/sb/examples/iup$

Title: Re: Corrected DLLCtestDLL for John - Windows 10
Post by: JRS on February 18, 2017, 04:32:20 PM
At this point tt looks like Windows has taken the lead with a stable threaded IUP GUI over Linux. I'm thinking it's more of a Gtk issue than IUP being flaky.

I'm able to run IUP in one thread under Linux reliably. For the project I'm working on, only one thread needs to maintain the UI dialog processing.

.
Title: Re: Corrected DLLCtestDLL for John - Windows 10
Post by: JRS on February 20, 2017, 12:53:23 PM
You can start a SB thread in two ways. The first method gives you the option to run a script from a string and just load the script without running it.

sbt_2ways.sb
Code: Script BASIC
  1. IMPORT sbt.sbi
  2.  
  3. ' Thread 1
  4. sb1 = SB_New()
  5. SB_Configure sb1, "C:/Windows/SCRIBA.INI"
  6. SB_Load sb1, "hellothread.sb"
  7. SB_Run sb1, ""
  8.  
  9. ' Thread 2
  10. sb2 = SB_ThreadStart("hellothread.sb",undef,"C:/Windows/SCRIBA.INI")
  11.  
  12. SB_Destroy(sb2)
  13. SB_Destroy(sb1)
  14.  

hellothread.sb
Code: Script BASIC
  1. PRINT "Hello world from a thread\n"
  2.  


C:\ScriptBASIC\examples>scriba sbt_2ways.sb
Hello world from a thread
Hello world from a thread

C:\ScriptBASIC\examples>