Hi vovchik
Thanks for the assistance - I'm sure I tried appending an ampersand (as per my earlier post re the terminal) but I must have done something wrong.
Anyway, I used the syntax you suggested and it worked fine ie the program was launching in it's own thread and not tying up my program.
However, since I added some more code (the part dealing with postfix$ in the callback) it has reverted to the original problem.
Anyway, the program is designed to speed up searching on the net for Puppy related stuff - enter search terms, choose the search target and hit search. I just got tired of typing 'puppy linux' for every search!
I've attached the full source, perhaps you could cast an eye over it?
Many thanks
Paul
PS Is there a way to make the search button the default event when someone hits enter?
PPS I know there's a warning I need to sort out regarding a label/caption
EDIT: I've fixed the warning and edited the code below - the xalign property requires a value of '0.0' rather than '0' ... quirky! (personally I would have used -1/0/1 to indicate aligment, or better yet have LEFT, RIGHT, CENTER #defined - I'm going to do that now!).
Code: Select all
' Simple utility to google (with firefox) for Puppy Linux terms
' (hard-coded for Firefox/Google but easy to change for other browser/search engine)
' By Paul Robinson 2013
'include the BaCon GUI library
INCLUDE "/usr/share/BaCon/hug_imports.bac"
'this is required when using library above
INIT
versionNo$ = "1.0"
'create the window and widgets
'set window title once name has been supplied?
appWindow = WINDOW(CONCAT$("Psearch ", versionNo$), 220, 180)
'label and text box for user's search terms
markSearchLabel=MARK("Search for", 100, 15)
PROPERTY(markSearchLabel, "xalign", 0.0)
ATTACH(appWindow, markSearchLabel, 10, 10)
entrySearchTerms=ENTRY("", 130, 15)
ATTACH(appWindow, entrySearchTerms, 80, 10)
'radio buttons for search target choice
'put in a frame
rbFrame = FRAME(200, 100)
TEXT(rbFrame, "Target: ")
ATTACH(appWindow, rbFrame, 8, 35)
radioG = RADIO("Google", 200, 15, radioG)
ATTACH(appWindow, radioG, 10, 55)
radioP = RADIO("Puppylinux.org", 200, 15, radioG)
ATTACH(appWindow, radioP, 10, 80)
radioF = RADIO("Puppy Linux Forum", 200, 15, radioG)
ATTACH(appWindow, radioF, 10, 105)
'set default target to google
SET(radioG, TRUE)
'button to run search
searchButton=BUTTON("Search", 50, 30)
ATTACH(appWindow, searchButton, 160, 140)
'button to quit
quitButton=BUTTON("Exit", 50, 30)
ATTACH(appWindow, quitButton, 10, 140)
'define callbacks
'ie functions for widget events
CALLBACK(quitButton, QUIT)
CALLBACK(searchButton, subSearch)
'show the window
DISPLAY
'search button callback
SUB subSearch
'specify new tab in case Firefox is already open
searchURL$ = "firefox -new-tab http://www.google.com/search?q="
IF GET(radioG) THEN
postfix$ = ""
ELIF GET(radioP) THEN
postfix$ = "+site:puppylinux.org"
ELSE
postfix$ = "+site:murga-linux.com/puppy"
END IF
'get user input, replacing any spaces with '+' signs
searchTerms$ = REPLACE$(GRAB$(entrySearchTerms), " ", "+")
'TODO add code to remove or escape single/double quotes
'concat the user's search terms to hard-wired "puppy linux"
searchTerms$ = CONCAT$("puppy+linux+", searchTerms$)
'add any site specific search requirement
searchTerms$ = CONCAT$(searchTerms$, postfix$)
'add that to the basic url string
commandLine$ = CONCAT$(searchURL$, searchTerms$)
'start firefox in it's own thread
result$ = EXEC$(commandLine$ & " &")
END SUB