Glad to see youa re so busy
![Smile :)](./images/smilies/icon_smile.gif)
http://208.109.22.214/puppy/viewtopic.p ... cb706abdd5
With kind regards,
vovchik
Code: Select all
SPLIT Txt$ BY NL$ TO File$ Size fileSz
Code: Select all
EDIT(xsize, ysize)
Type: directive
Defines a multiline text widget with a width of <xsize> and a height of <ysize>.
Returns the ID of the created text widget.
Code: Select all
' --------------------
FUNCTION CAT(STRING FILENAME$)
' --------------------
LOCAL fileline$, txt$ TYPE STRING
IF FILEEXISTS(FILENAME$) THEN
OPEN FILENAME$ FOR READING AS catfile
WHILE NOT(ENDFILE(catfile)) DO
READLN fileline$ FROM catfile
txt$ = CONCAT$(txt$, fileline$, NL$)
WEND
CLOSE FILE catfile
END IF
RETURN CHOP$(txt$)
END FUNCTION
x$ = CAT("/etc/profile")
PRINT x$
Code: Select all
' --------------
FUNCTION GETWORD$(STRING mystring$, NUMBER word_number, STRING delimiter$)
' --------------
LOCAL i, mypos, n TYPE NUMBER
LOCAL string_temp$ TYPE STRING
i = 0
mypos = 0
n = 1
string_temp$ = ""
mystring$ = CONCAT$(mystring$, delimiter$)
REPEAT
mypos = INSTR(mystring$, delimiter$, n)
INCR i
IF i = word_number THEN
string_temp$ = MID$(mystring$, n, (mypos - n))
END IF
n = mypos + 1
UNTIL mypos IS FALSE
RETURN string_temp$
END FUNCTION
x$ = CAT("/etc/profile")
' grab first line
y$ = GETWORD$(x$, 1, NL$)
PRINT y$
Code: Select all
bacon -o -s -o -Os -o -fdata-sections -o -ffunction-sections -o -Wl,--gc-sections psol-1
Code: Select all
TEXT for entering or changing text in a widget.
GRAB$ for getting text from a widget.
Code: Select all
TEXT(widget, GET(index))
Code: Select all
TEXT(widget, GRAB$(widget))
Code: Select all
webz$=GRAB$(webaddy)
IF LEFT$(webz$,7) = "http://" THEN doit
webz$=CONCAT$("http://",webz$)
END IF
LABEL doit
SYSTEM "exec defaultbrowser webz$ &"
Code: Select all
SUB LAUNCH_BROWSER(STRING my_url$)
SYSTEM CONCAT$("exec defaultbrowser ", my_url$, " &")
END SUB
webz$=GRAB$(webaddy)
IF LEFT$(webz$, 7) = "http://" AND LEN(CHOP$(webz)) > 7 THEN
LAUNCH_BROWSER(webz$)
ELIF LEN(CHOP$(webz$)) > 1 THEN
webz$ = CONCAT$("http://", webz$)
LAUNCH_BROWSER(webz$)
ELSE
PRINT "Bad URL. Try again."
END IF
Code: Select all
killmsg$=CONCAT$("You are about to delete ",kilme$," !")
kilme_dlg= MSGDIALOG(killmsg$,350,110,1,1)
SHOW(kilme_dlg)
CALLBACK(kilme_dlg,killme_btn)
PRINT kmv
Code: Select all
FUNCTION killme_btn( NUMBER value)
HIDE (kilme_dlg)
IF value = GTK_RESPONSE_OK THEN
kmv = 0
ELIF value = GTK_REPONSE_DELETE_EVENT THEN
kmv=1
END IF
RETURN kmv
END FUNCTION
Code: Select all
CONFIRM"Delete this file?";a$
LOWERCASE$(a$)
IF a$ = "y" OR a$ = 'yes" THEN dmv=0:GOTO next
dmv=1
[next]
Your function def isThe dialog can be connected to a callback function which should have two arguments, the first for the dialog and the second for the button.
SUB HandleError(NUMBER dialog, int button)
Code: Select all
FUNCTION killme_btn( NUMBER value)
Code: Select all
killmsg$=CONCAT$(Are yo usure you want to delete ",kilme$," ?")
kilme_dlg=MSGDIALOG(killmsg$,300,110,1,4)
SHOW(kilme_dlg)
CALLBACK(kilme_dlg,killme_btn)
IF kmv = 1 THEN
GOTO findrec
END IF
GOTO nokill
LABEL findrec
PRINT "at finding record"
LABEL nokill
PRINT "ending"
END SUB
Code: Select all
dmv = 3
REPEAT
SHOW(kilme_dlg)
CALLBACK(kilme_dlg,killme_btn)
dmv=WAIT(killme_btn, 30)
UNTIL dmv < 3
Code: Select all
dmv = 3
WHILE dmv >= 3
SHOW(kilme_dlg)
CALLBACK(kilme_dlg,killme_btn)
WEND
Code: Select all
killmsg$=CONCAT$("Are yo sure you want to delete record ",kilme$," ?")
kill_dlg=MSGDIALOG(killmsg$,300,100,1,4)
SHOW(kill_dlg)
CALLBACK(kill_dlg,killit)
END SUB
SUB killit (NUMBER kill_dlg, int button)
HIDE(kill_dlg)
IF button = GTK_RESPONSE_YES THEN
CALL kilrec
END IF
END SUB
SUB kilrec
PRINT "killing record"
END SUB