The time now is Wed 19 Jun 2013, 11:04
All times are UTC - 4 |
|
Page 28 of 36 [526 Posts] |
Goto page: Previous 1, 2, 3, ..., 26, 27, 28, 29, 30, ..., 34, 35, 36 Next |
| Author |
Message |
big_bass

Joined: 13 Aug 2007 Posts: 1736
|
Posted: Tue 29 Nov 2011, 12:16 Post subject:
|
|
bacon2html UPDATED NOV -28-2011
http://www.murga-linux.com/puppy/viewtopic.php?t=48901&start=400
I will keep it updated here
http://basic-converter.proboards.com/index.cgi?board=code&action=display&thread=179
_________________ slackware 14
|
|
Back to top
|
|
 |
big_bass

Joined: 13 Aug 2007 Posts: 1736
|
Posted: Thu 01 Dec 2011, 02:47 Post subject:
|
|
html tools
indenthtml
compliment to bacon2html
it pre indents the html
it could be used as a stand alone for any file or code
it doesnt have to be bacon code
it auto indents justifies in spaces of five
| Code: |
'--- ***************************************************** '
'--- PROGRAM: indenthtml.bac '
'--- PURPOSE: indent html code '
'--- AUTHOR: big_bass Joe Arose '
'--- DEPENDS: gcc, bacon, '
'--- PLATFORM: linux '
'--- DATE: Nov-28-2011'
'--- NOTES:
'--- LICENSE: GPL version 3 or later '
'--- *****************************************************'
'--- this is only for modifing of code with justified indentation
'--- USUAGE: ./indenthtml /path-and-filename" ---'
'--- note the file will get a .indent added to the filename ---'
'--- on error print usage ---'
'--- this part was added to for variables to be passed at command line ---'
TRAP LOCAL
SPLIT ARGUMENT$ BY " " TO arg$ SIZE dim
IF LEN(arg$[1]) EQ 0 THEN
PRINT "USUAGE: ./indenhtml /path-and-filename"
END
END IF
Tab$ = CHR$(9)
FIVE_BLANKS$ = SPC$(5)
'--- Non-Breaking Space ---'
'--- set the default line indents ---'
FIVE_SPACES$ = " "
TEN_SPACES$ = " "
FIFTEEN_SPACES$ = " "
TWENTY_SPACES$ = " "
TWENTY_FIVE_SPACES$ = " "
THIRTY_SPACES$= " "
THIRTY_FIVE_SPACES$= " "
FORTY_SPACES$= " "
FORTY_FIVE_SPACES$= " "
FIFTY_SPACES$= " "
FIFTY_FIVE_SPACES$= " "
'--- copy_this$ is the first argument passed from the command line ---'
'--- path-and-filename is arg$[1] this is a valid bacon argument ---'
'--- give it a string name for clarity ---'
copy_this$ = arg$[1]
'--- another code snippet from GatorDog thanks ---'
IF ISFALSE(FILEEXISTS(copy_this$)) THEN
PRINT NL$, "=>> ", copy_this$, " <<== not found."
PRINT "Please check your directory for assistance ;>)", NL$
END FALSE
END IF
'--- thanks GatorDog ---'
COPY copy_this$ TO CONCAT$(copy_this$,".indent")
'--- Rename working file to TMP ext.
RENAME CONCAT$(copy_this$,".indent") TO CONCAT$(copy_this$,".indentTMP")
OPEN CONCAT$(copy_this$,".indent") FOR WRITING AS my_outfile
OPEN CONCAT$(copy_this$,".indentTMP") FOR READING AS my_infile
WHILE NOT(ENDFILE(my_infile))
READLN txt$ FROM my_infile
'--- pre step replace tabs with five spaces ---'
txt$ = REPLACE$(txt$, Tab$, FIVE_BLANKS$)
'--- check if line of text starts with spaces or tabs ---'
IF REGEX(txt$, "^ ") OR REGEX(txt$, "^FIVE_BLANKS$") THEN
PRINT "Yep, ", txt$, "--> starts with spaces !"
PRINT
PRINT
full_count = LEN(txt$)
'--- a chop left is used here to remove only left spaces ---'
chopped_count = LEN(CHOP$(txt$," ",1))
start_space_count = full_count - chopped_count
'--- error checking ---'
'--- blue is ok yellow is error with a limit of 55 spaces ---'
IF start_space_count < 53 THEN
PRINT "you have ";
COLOR FG TO BLUE
PRINT start_space_count," leading space(s)"
COLOR RESET
ELSE
PRINT "you have ";
COLOR FG TO YELLOW
PRINT start_space_count," leading space(s)"
COLOR RESET
END IF
'--- start main ---'
IF start_space_count < 3 THEN
PRINT "will chop off this < 3 spaced indented "
PRINT CHOP$(txt$," ",1)
WRITELN CHOP$(txt$," ",1) TO my_outfile
END IF
IF start_space_count >= 3 AND start_space_count <= 6 THEN
PRINT "will shift you to five so it looks good "
PRINT FIVE_SPACES$, txt$
WRITELN FIVE_SPACES$, txt$ TO my_outfile
END IF
IF start_space_count >= 7 AND start_space_count <= 12 THEN
PRINT "will shift you to ten so it looks good "
PRINT TEN_SPACES$, txt$
WRITELN TEN_SPACES$, txt$ TO my_outfile
END IF
IF start_space_count >= 13 AND start_space_count <= 17 THEN
PRINT "will shift you to fifteen so it looks good "
PRINT FIFTEEN_SPACES$, txt$
WRITELN FIFTEEN_SPACES$, txt$ TO my_outfile
END IF
IF start_space_count >= 18 AND start_space_count <= 22 THEN
PRINT "will shift you to twenty so it looks good "
PRINT TWENTY_SPACES$, txt$
WRITELN TWENTY_SPACES$, txt$ TO my_outfile
END IF
IF start_space_count >= 23 AND start_space_count <= 27 THEN
PRINT "will shift you to twenty five so it looks good "
PRINT TWENTY_FIVE_SPACES$, txt$
WRITELN TWENTY_FIVE_SPACES$, txt$ TO my_outfile
END IF
IF start_space_count >= 28 AND start_space_count <= 32 THEN
PRINT "will shift you to thirty so it looks good "
PRINT THIRTY_SPACES$, txt$
WRITELN THIRTY_SPACES$, txt$ TO my_outfile
END IF
IF start_space_count >= 33 AND start_space_count <= 37 THEN
PRINT "will shift you to thirty five so it looks good "
PRINT THIRTY_FIVE_SPACES$, txt$
WRITELN THIRTY_FIVE_SPACES$, txt$ TO my_outfile
END IF
IF start_space_count >= 38 AND start_space_count <= 42 THEN
PRINT "will shift you to forty so it looks good "
PRINT FORTY_SPACES$, txt$
WRITELN FORTY_SPACES$, txt$ TO my_outfile
END IF
IF start_space_count >= 43 AND start_space_count <= 47 THEN
PRINT "will shift you to forty five so it looks good "
PRINT FORTY_FIVE_SPACES$, txt$
WRITELN FORTY_FIVE_SPACES$, txt$ TO my_outfile
END IF
IF start_space_count >= 48 AND start_space_count <= 52 THEN
PRINT "will shift you to fifty so it looks good "
PRINT FIFTY_SPACES$, txt$
WRITELN FIFTY_SPACES$, txt$ TO my_outfile
END IF
'--- if over 53 spaces force all 55 spaces ---'
IF start_space_count > 53 THEN
PRINT "ERROR more than 53 spaces indented you have " ;
COLOR FG TO RED
PRINT start_space_count ," indent limit 55 forced !"
COLOR RESET
WRITELN FIFTY_FIVE_SPACES$, txt$ TO my_outfile
END IF
ELSE
PRINT "no leading spaces "
PRINT txt$
WRITELN txt$ TO my_outfile
WEND
END IF
CLOSE FILE my_infile
CLOSE FILE my_outfile
DELETE FILE CONCAT$(copy_this$,".indentTMP")
PRINT
PRINT
PRINT "The indent conversion is done!"
PRINT copy_this$,".indent", " <--- is the modified file "
|
_________________ slackware 14
|
|
Back to top
|
|
 |
sunburnt

Joined: 08 Jun 2005 Posts: 4016 Location: Arizona, U.S.A.
|
Posted: Sun 04 Dec 2011, 03:40 Post subject:
|
|
Hi guys... I just installed Puppy528 and BaConGUI won`t run a file.
Error: Could not open library ./hug.so: cannot open shared object file: No such file or directory
hug.so is in: /usr/share/BaCon as usual.
Don`t know why it`s looking in the current dir.
I`m sure it`s something simple I`m missing...
|
|
Back to top
|
|
 |
big_bass

Joined: 13 Aug 2007 Posts: 1736
|
Posted: Sun 04 Dec 2011, 16:03 Post subject:
|
|
bb2bbpress
http://www.puppy2.org/slaxer/bb2bbpress-1.0-4_SLXR.tgz
a command line tool that converts murga forum to puppylinux.info code
in technical terms phpBBcode to bbpress code
so you can pass your posts to puppylinux.info
and back up your valuable data there
written in pure BaConwhich compiles in C code so its fast fast
already compiled and packaged the source is included as always
if you look at my txz thread you can see the results of running the tool
it is 95% working correctly in automatically correcting the code
the other 5%
what doesnt work are all those http bla bla see here links
they look neater but they are terrible to convert from one forum to another and should be avoided
the full url is the best format for passing threads from one forum to another
and the list ,list = I still have to do some more testing on that to get it to convert to bbpress format
enjoy
you must be the author of the thread
open your thread you want to edit on murga
select all the text then save it to a file
at the command line type
bb2bbpress /the name of the file to correct
then paste *.bbpress-fixed in puppylinux.info
Joe
_________________ slackware 14
Last edited by big_bass on Mon 05 Dec 2011, 12:23; edited 3 times in total
|
|
Back to top
|
|
 |
GatorDog

Joined: 12 Sep 2006 Posts: 136
|
Posted: Sun 04 Dec 2011, 19:47 Post subject:
|
|
| Quote: | | Error: Could not open library ./hug.so: cannot open shared object file: No such file or directory |
Hey Sunburnt,
How is your IMPORT statement in your program set up?
GatorDog
_________________

|
|
Back to top
|
|
 |
sunburnt

Joined: 08 Jun 2005 Posts: 4016 Location: Arizona, U.S.A.
|
Posted: Sun 04 Dec 2011, 22:19 Post subject:
|
|
Hey GatorDog; Same as always...
| Code: | | INCLUDE "/usr/share/BaCon/hug_imports.bac" |
Is there something that is setup upon installing BaCon ( I don`t recall any...)?
I thought BaCon hard coded the file path /usr/share/BaCon/hug.so
| Code: | sh-4.1# find /usr/share/BaCon/h*.so
/usr/share/BaCon/hug.so |
|
|
Back to top
|
|
 |
GatorDog

Joined: 12 Sep 2006 Posts: 136
|
Posted: Sun 04 Dec 2011, 22:26 Post subject:
|
|
Sunburnt,
If you're using the default devx, then check the hug_imports.bac file.
Probably change the top line (or close to top) to
CONST HUG_lib$ = "/usr/lib/hug.so"
And you may want to make sure you have the latest hug.so (in /usr/lib/...)
rod
_________________

|
|
Back to top
|
|
 |
sunburnt

Joined: 08 Jun 2005 Posts: 4016 Location: Arizona, U.S.A.
|
Posted: Sun 04 Dec 2011, 23:57 Post subject:
|
|
Still the same error: Could not open library ./hug.so
/usr/share/BaCon/hug_imports.bac
| Code: | ' Imports when HUG is used as shared object
'CONST HUG_lib$ = "./hug.so"
'CONST HUG_lib$ = "/usr/share/BaCon/hug.so"
CONST HUG_lib$ = "/usr/lib/hug.so" |
I see why the error says ./hug.so ( the original CONST declare ).
But why didn`t it change with my two edits?
|
|
Back to top
|
|
 |
big_bass

Joined: 13 Aug 2007 Posts: 1736
|
Posted: Mon 05 Dec 2011, 00:34 Post subject:
|
|
Hey sunburnt
hug.so is a run time dependency
this means you can move it around
to debug where it needs to be
which is determined by what was used at compile time
if you place hug.so in the same directory as your compiled bin
which is the bacon gui
it will work
you can recompile placing
hug.so where you want
but to maintain a standard
it should be placed in /usr/lib
move it around till it works
then recompile
Joe
_________________ slackware 14
|
|
Back to top
|
|
 |
sunburnt

Joined: 08 Jun 2005 Posts: 4016 Location: Arizona, U.S.A.
|
Posted: Mon 05 Dec 2011, 01:25 Post subject:
|
|
Don`t know why it started working, though sketchy.
And Xterm pops up with the title bar: xterm_simulate_hold.sh
It seems the shell script is being run with the exec.
Is this correct? Is this a new improvement for the BaConGUI ?
|
|
Back to top
|
|
 |
sunburnt

Joined: 08 Jun 2005 Posts: 4016 Location: Arizona, U.S.A.
|
Posted: Mon 05 Dec 2011, 23:12 Post subject:
|
|
Can`t remember if this has been asked/answered yet...
How to get pixel width of a string to set width of buttons, etc.
A tricky thing as it has to do with font, font size, bold, and italic.
A simple fix would be to use only mono-spaced fonts.
btnWidth = character count + pixels per character + padding
In V.B. I use to just have a hidden text box with the "snap to size" set.
So I`d fill it with text and read it`s width property.
# If a MARK could be made and set it`s "snap to size" property...
|
|
Back to top
|
|
 |
vovchik

Joined: 23 Oct 2006 Posts: 1239 Location: Ukraine
|
Posted: Fri 09 Dec 2011, 06:32 Post subject:
pixel width |
|
Dear Terry,
It is possible with pango, but you will have to recode this bit in BaCon (not hard):
| Code: | extern GttWidget * curdlg; // of current dialog
void gettextwdht ( char * family , int ptsize , int weight , bool normalstyle ,
char * stringtomeasure ,
int * wdret , int * htret )
{
PangoFontDescription * fd = pango_font_description_new ( );
pango_font_description_set_family (fd, family );
pango_font_description_set_style (fd, normalstyle ? PANGO_STYLE_NORMAL :
PANGO_STYLE_ITALIC );
pango_font_description_set_variant (fd, PANGO_VARIANT_NORMAL);
pango_font_description_set_weight (fd, (PangoWeight)weight );
pango_font_description_set_stretch (fd, PANGO_STRETCH_NORMAL);
pango_font_description_set_size (fd, ptsize * PANGO_SCALE);
PangoContext * context = gtk_widget_get_pango_context ( curdlg ) ;
PangoLayout * layout = pango_layout_new ( context );
pango_layout_set_text ( layout, stringtomeasure, -1 );
pango_layout_set_font_description ( layout, fd );
pango_layout_get_pixel_size (layout, wdret , htret );
g_object_unref ( layout );
}
|
If I have time, I will do this and make it a BaCon function. If you have time and do it first, please post it.
With kind regards,
vovchik
PS. Here is a URL: http://www.gtk.org/api/2.6/pango/pango-Layout-Objects.html#pango-layout-get-pixel-size
|
|
Back to top
|
|
 |
vovchik

Joined: 23 Oct 2006 Posts: 1239 Location: Ukraine
|
Posted: Fri 09 Dec 2011, 10:38 Post subject:
EXTRACT$ function Subject description: useful for splitting argument lines |
|
Dear puppians,
Here is a string function (also attached) for BaCon that I just coded and you might also find useful. I haven't tested it extensively, but it seems to work fine. The notes in the code explain what it does.
| Code: | ' *****************************************************
' PROGRAM: extract.bac
' PURPOSE: EXTRACT$ function for BaCon (see NOTES)
' AUTHOR: vovchik (Puppy Linux forum)
' DEPENDS: gcc, bacon
' PLATFORM: Puppy Linux (actually, any *nix)
' DATE: 09-12-2011
' LICENSE: GPL3
' *****************************************************
' NOTES
'
' EXTRACT$(STRING src$, STRING match$, NUMBER mode) where
'
' src$ is a string of length > 1 that is to be
' examined and split
'
' match$ is a string of chars for testing the presence
' of ANY of which in src$ and whose earliest position in
' src$ (starting from the left) represents the point for
' substring delimitation.
'
' mode is a flag toggling "extract" and "remain" modes of
' the EXTRACT$ function
'
' If mode = 0, then
'
' EXTRACT$ returns a substring of src$ starting with the first
' character of src$ and up to (but not including) the first
' occurrence of match$. If match$ is not present in src$,
' all of src$ is returned.
'
' If mode = 1, then
'
' EXTRACT$ returns a substring of src$ starting with the first
' character in src$ that matches any string within match$ to the
' end of src$.
'
' In summary, src$ is a string expression from which to
' extract a substring and match$ is a string of chars
' against which matches will be attempted. mode determines
' whether the left part (mode 0) or right part (mode 1)
' of src$ will be returned.
' EXTRACT$ is case-sensitive.
'
' The function is especially useful when parsing a
' string containing arguments to a program.
'
' This implementation combines the functions of typical
' EXTRACT$ and REMAIN$ functions in other languages.
' *****************************************************
' -------------
FUNCTION EXTRACT$(STRING src$, STRING match$, NUMBER mode)
' -------------
LOCAL tst$, ret$, tmp$ TYPE STRING
LOCAL i TYPE NUMBER
' check to see whether there is really something to be split
IF LEN(src$) > 1 THEN
tst$ = ""
tmp$ = ""
' create REGEX compound "OR" type string from match$ string
FOR i = 1 TO LEN(match$)
tst$ = CONCAT$(tst$, MID$(match$, i, 1), "|")
NEXT i
tst$ = LEFT$(tst$, LEN(tst$) - 1)
' if one of the REGEX chars is found in src$,
' then determine the first instance (position) of any of
' the match$ chars within src$
IF REGEX(src$, tst$) THEN
FOR i = 1 TO LEN(match$)
IF INSTR(src$, MID$(match$, i, 1)) THEN
tmp$ = CONCAT$(tmp$, RIGHT$(CONCAT$("0000000000", STR$(INSTR(src$, MID$(match$, i, 1)))), 8), " ")
END IF
NEXT i
tmp$ = CHOP$(tmp$)
SPLIT tmp$ BY " " TO tmp_array$ SIZE tmp_size
SORT tmp_array$
' make substring to return based on mode
SELECT mode
' everything from the left except that which matches
CASE 0
ret$ = LEFT$(src$, VAL(tmp_array$[0]) - 1)
' everything from the right that matches
CASE 1
ret$ = RIGHT$(src$, LEN(src$) - VAL(tmp_array$[0]) + 1)
' placeholder for additional/new modes
DEFAULT
ret$ = src$
END SELECT
ELSE
ret$ = src$
END IF
ELSE
ret$ = src$
END IF
RETURN ret$
END FUNCTION |
Here is how to invoke it:
| Code: | source$ = "abcedf"
test$ = "xyz"
PRINT EXTRACT$(source$, test$, 0)
PRINT "--------"
source$ = "zsdabcedf"
test$ = "bc"
PRINT EXTRACT$(source$, test$, 0)
PRINT "--------"
source$ = "zsdabcedf"
test$ = "bz"
PRINT EXTRACT$(source$, test$, 0)
PRINT "--------"
source$ = "zsdabcedf"
test$ = "bz"
PRINT EXTRACT$(source$, test$, 1)
PRINT "--------"
source$ = "There is only trouble ahead"
test$ = "bzt"
PRINT EXTRACT$(source$, test$, 0)
PRINT "--------"
source$ = "There is only trouble ahead"
test$ = "but"
PRINT EXTRACT$(source$, test$, 0)
PRINT "--------"
source$ = "There is only trouble ahead"
test$ = "but"
PRINT EXTRACT$(source$, test$, 1)
PRINT "--------"
source$ = "bnice -t -g 80x90"
test$ = "-gt"
PRINT EXTRACT$(source$, test$, 1)
PRINT "--------"
source$ = "IF x$ > 10 THEN"
test$ = ">"
PRINT EXTRACT$(source$, test$, 1)
PRINT "--------"
source$ = "IF x$ > 10 THEN"
test$ = ">"
PRINT EXTRACT$(source$, test$, 0) |
With kind regards,
vovchik
| Description |
|

Download |
| Filename |
extract.bac.tar.gz |
| Filesize |
1.51 KB |
| Downloaded |
172 Time(s) |
|
|
Back to top
|
|
 |
sunburnt

Joined: 08 Jun 2005 Posts: 4016 Location: Arizona, U.S.A.
|
Posted: Thu 15 Dec 2011, 16:42 Post subject:
|
|
Hi guys; Anyway to get mouse info ( button, scroll, X, Y ) from Xwin.?
The gtkDialog threads probably have something on this, but they`re five miles long.
BaCon only gets mouse info if the cursor is over a canvas I think, but not over other controls.
Right-click would be nice for BaCon, but Xwin. controls the window, so click action starts there.
|
|
Back to top
|
|
 |
BarryK
Puppy Master

Joined: 09 May 2005 Posts: 6874 Location: Perth, Western Australia
|
Posted: Thu 15 Dec 2011, 18:09 Post subject:
|
|
Heh heh, I lobbied for BaCon in the Raspberry Pi forum:
http://www.raspberrypi.org/forum?mingleforumaction=viewtopic&t=1474
...well, I have introduced BaCon into their awareness, I probably should back-off now.
_________________ http://bkhome.org/blog2/
|
|
Back to top
|
|
 |
|
|
Page 28 of 36 [526 Posts] |
Goto page: Previous 1, 2, 3, ..., 26, 27, 28, 29, 30, ..., 34, 35, 36 Next |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|