Author Topic: ScriptBasic 3.0 w/GUI  (Read 23463 times)

Support

  • Administrator
  • *****
  • Posts: 19
    • View Profile
ScriptBasic 3.0 w/GUI
« on: July 19, 2010, 09:42:10 PM »
This ScriptBasic 3.0 Windows 32-bit runtime download includes the first release of the IUP GUI extension module.

DOWNLOAD

The Thesaurus IUP demo by Armando Rivera was based on Peter van Eerten's Gtk-Server Thesaurus demo.



Code: [Select]
import IUP.bas

GLOBAL CONST title = "Thesaurus!"

'Servers = "1=dict.org, 2=test.dict.org, 3=dict.die.net"
Servers[0]="dict.org"
Servers[1]="dict1.us.dict.org"
Servers[2]="all.dict.org"

about=""" This is a Demo
of the IUP GUI Binding
for Scriptbasic"""

const nl = "\n"

SUB CLEAR
IUP::AddItem(serverList,"")
END SUB

SUB Get_Dicts(svrAddr)

LOCAL dat$, total, count

ON ERROR GOTO G_NetError

OPEN svrAddr & ":2628" FOR SOCKET AS 1
PRINT#1,"SHOW DB\n"

LINE INPUT#1, dat$
LINE INPUT#1, dat$

count = 0
WHILE LEFT(dat$, 1) <> "."
LINE INPUT#1, dat$
IF LEFT(dat$, 1) <> "." THEN total[count] = TRIM(dat$)
count+=1
WEND
PRINT#1,"QUIT\n"
CLOSE 1


for cnt = 0 to count
IUP::AddItem(serverList, total[cnt])
next

EXIT SUB

G_NetError:
'IUP::Message("ERROR Connecting" , svrAddr & " is not available!")
print "Server not available",nl


END SUB

SUB Lookup_Word

LOCAL dict$, dat$, total$, info$

IUP::SetText(win, title & " -  " & IUP::GetText(entry))

IUP::SetText(text, "Fetching....")


ON ERROR GOTO L_NetError

selectedServer = Servers[IUP::GetSelection(serverCombo) -1]

'THIS DOESN'T WORK YET
'whichDictionary = IUP::GetText(serverList)

'print whichDictionary

'dict$ = LEFT(whichDictionary, INSTR(whichDictionary, " "))

'print dict$

OPEN selectedServer & ":2628" FOR SOCKET AS 1

IF IUP::GetState(chkAll) = "ON" THEN
PRINT#1,"DEFINE * " & IUP::GetText(entry) & "\n"
ELSE
PRINT#1,"DEFINE " & dict$ & " " & IUP::GetText(entry)& "\n"
END IF

REPEAT
LINE INPUT#1, dat$
'dat$ = REPLACE(dat$, CHR$(34), CHR$(92) & CHR$(34))
IF LEFT(dat$, 3) = "151" THEN
total$ &= "------------------------------\n"
total$ &= RIGHT(dat$, LEN(dat$) - LEN(IUP::GetText(entry)) - 9)
total$ &= "------------------------------\n"
REPEAT
LINE INPUT#1, info$
'info$ = REPLACE(info$, CHR$(34), CHR$(92) & CHR$(34))
IF LEFT(info$, 1) <> "." THEN total$ &= TRIM(info$) & nl
UNTIL LEFT(info$, 1) = "."
total$ &= "\n"
END IF
UNTIL LEFT(dat$, 3) = "250" OR VAL(LEFT(dat$, 3)) > 499

PRINT#1,"QUIT\n"
CLOSE 1

IF LEFT(dat$, 3) = "552" THEN
total$ = "No match found."
ELSE IF LEFT(dat$, 3) = "501" THEN
total$ = "Select a dictionary first!"
ELSE IF LEFT(dat$, 3) = "550" THEN
total$ = "Invalid database!"
END IF

IUP::SetText(text, total$)

EXIT SUB

L_NetError:
        dat$[0] = "Could not lookup word!"

        IUP::SetText(text, dat$)

END SUB

REM Initialize IUP
IUP::Init()

REM Create Main Window
win = IUP::Create("dialog","TITLE=Thesaurus, SIZE=500x300")

REM create container to house ALL GUI objects
vbox = IUP::Create("vbox","MARGIN=10x10")

REM Create Server panel
topBox = IUP::Create("hbox", " GAP=10", vbox)
serverFrame = IUP::Create("frame", "TITLE=Servers, EXPAND=YES", topBox)
serverBox= IUP::Create("hbox", "GAP=5", serverFrame)
serverCombo = IUP::Create("list", "DROPDOWN=YES, SIZE=120x, EXPAND=HORIZONTAL, VALUE=1", serverBox)
btnFetch = IUP::Create("button", "TITLE=Fetch, SIZE = 50x", serverBox)



REM Create control panel
controlFrame = IUP::Create("frame", "TITLE=Controls", topBox)
controlBox = IUP::Create("hbox", "Margin=6x6, GAP=5", controlFrame)
btnAbout = IUP::Create("button", "TITLE=About, SIZE = 50x", controlBox)
btnClear = IUP::Create("button", "TITLE=Clear, SIZE = 50x", controlBox)
btnExit = IUP::Create("button", "TITLE=Exit, SIZE = 50x", controlBox)

REM Create dictionary panel
dictFrame = IUP::Create("frame", "TITLE=Dictionaries", vbox)
serverList = IUP::Create("list", "EXPAND=YES, VISIBLELINES=1", dictFrame)

REM Create text part
transFrame = IUP::Create("frame", "TITLE=Translation", vbox)
text = IUP::Create("text", "MULTILINE=YES, EXPAND=YES", transFrame)

REM Create entry and search button
bottomBox = IUP::Create("hbox", "GAP=10", vbox)
label = IUP::Create("label", "TITLE=\"Enter Word to Search For:\", SIZE=x12", bottomBox)
entry = IUP::Create("text", " EXPAND=HORIZONTAL",bottomBox)
btnSearch = IUP::Create("button","TITLE=Search, SIZE=50x", bottomBox)
chkAll = IUP::Create("toggle", "TITLE=ALL, VALUE=ON,SIZE=x12", bottomBox)
chkUTF = IUP::Create("toggle", "TITLE=UTF-8, SIZE=x12", bottomBox)

REM Add the main GUI container to the Window
IUP::AddChild(win, vbox)

REM Show the Window
IUP::Show(win)

IUP::SetFocus(btnFetch)
for i = 0 to 2
IUP::AddItem(serverCombo, Servers[i])
next

repeat
IUP::Wait()

action = IUP::Event()
eventtype = IUP::EventType()

if action = btnAbout then
IUP::Message("ABOUT", about)
end if

if action = btnFetch then
selection = IUP::GetSelection(serverCombo)
Get_Dicts(Servers[selection-1])
end if

if action = btnClear then

end if

if action = btnSearch then
Lookup_Word()
end if

until action = win or action = btnExit


Print "All Done"

Code: [Select]
module iup

REM """
The module iup.bas is based on the iup library.
"""
' FUNCTION DECLARATIONS
declare sub     ::Init          alias "Init"        lib "iup"
declare sub     ::Show          alias "Show"        lib "iup"
declare sub     ::Destroy       alias "Destroy"     lib "iup"
declare sub     ::Close         alias "Close"       lib "iup"
declare sub     ::Create        alias "Create"      lib "iup"
declare sub     ::AddChild      alias "AddChild"    lib "iup"
declare sub     ::Wait          alias "Wait"        lib "iup"
declare sub     ::ExitLoop      alias "ExitLoop"    lib "iup"
declare sub     ::Event         alias "GetEvent"    lib "iup"
declare sub     ::SetText       alias "SetText"     lib "iup"
declare sub     ::GetText       alias "GetText"     lib "iup"
declare sub     ::SetItem       alias "SetItem"     lib "iup"
declare sub     ::GetItem       alias "GetItem"     lib "iup"
declare sub     ::GetState      alias "GetItem"     lib "iup"
declare sub     ::SetFocus      alias "Focus"       lib "iup"
declare sub     ::Message       alias "Message"     lib "iup"
declare sub     ::GetClass      alias "GetClass"    lib "iup"
declare sub     ::GetSelection  alias "GetItem"     lib "iup"
declare sub     ::AddItem       alias "AddItem"     lib "iup"
declare sub     ::EventType     alias "EventType"   lib "iup"
end module
« Last Edit: July 20, 2010, 10:20:33 PM by support »

Airr

  • Guest
Re: ScriptBasic 3.0 w/GUI
« Reply #1 on: July 22, 2010, 06:03:05 PM »
Updated version of the IUP module attached.

Thing to note about the 30 release:

It's somewhere between Alpha and Beta stages.  This came about because John wondered if it could be compiled using MinGW.


Now the IUP module:

All of the GUI elements in the example now work (the UTF checkbox is unused, however).  Look at the iup.bas file to see what's available function-wise.

At the moment, it's Windows only because I had to resort to WinApi to get things (retrieving text values in Listbox/Combobox, for example) working with Scriptbasic.


Which leads me to this:  How interested are people in this module?  I need a "show of hands" here, otherwise this is all that's gonna be done.  Scriptbasic was never designed to interface with a GUI library, although this proof-of-concept shows that it can be done.  I'm not willing to commit the time required to bring this all the way home if only a few people will be using it.

A.

Support

  • Administrator
  • *****
  • Posts: 19
    • View Profile
Re: ScriptBasic 3.0 w/GUI
« Reply #2 on: July 23, 2010, 01:52:54 PM »
I'm 100% behind your efforts and see this as putting ScriptBasic on the map.

Let me know if there is anything I can do to help.  (testing, documentation and project promotion is something I can contribute )

John
« Last Edit: July 23, 2010, 08:47:32 PM by support »

Support

  • Administrator
  • *****
  • Posts: 19
    • View Profile
Re: ScriptBasic 3.0 w/GUI
« Reply #3 on: July 25, 2010, 12:16:45 PM »
Hey Guys, wake up!

There have been 50 or so downloads of ScriptBasic in the last few days and Armando needs your feedback. This is an incredible effort on Armando's part so don't let it die off because no one can find a couple minutes to reply to his request for feedback. It has taken me 5 years to find someone like Armando to get ScriptBasic moving forward again. PLEASE HELP the effort and participate.

 
« Last Edit: July 25, 2010, 05:36:11 PM by support »

GSAC3

  • Guest
Re: ScriptBasic 3.0 w/GUI
« Reply #4 on: July 26, 2010, 09:51:59 AM »
Armando --

Your GUI module looks very interesting.

I will certainly give it a try.

Don