BaCon - Bash-based Basic-to-C converter/compiler

For discussions about programming, programming questions/advice, and projects that don't really have anything to do with Puppy.
Message
Author
jpeps
Posts: 3179
Joined: Sat 31 May 2008, 19:00

#161 Post by jpeps »

BarryK wrote:

Code: Select all

ATTACH(mainwin, label_http, 10, 100)
FONT(label_http,font_sans$)
I don't know if this idea of keeping the text always the same size regardless, would appeal to everybody.
Thanks Barry...keep the examples coming!

seaside
Posts: 934
Joined: Thu 12 Apr 2007, 00:19

#162 Post by seaside »

This is how the formula renders in pup431 at 96dpi....
Attachments
96dpi.png
(27.54 KiB) Downloaded 1176 times

User avatar
PjotAwake
Posts: 34
Joined: Wed 03 Nov 2010, 20:58
Location: The Hague, The Netherlands
Contact:

#163 Post by PjotAwake »

The editor works fine using ubuntu however, using puppy, it fails to find the gtksourceview libs even though they exist.
That may happen - the SO lookup algorithm checks until the sequence number of 50 (so from libgtksourceview-2.0.so.0 until libgtksourceview-2.0.so.50). This may not be enough.

Can you show the output of 'ls -l /usr/lib/libgtksourceview-2.0.so*' ? On my system:
peter@Solarstriker:~/programming/bacon$ ls -l /usr/lib/libgtksourceview-2.0.so*
lrwxrwxrwx 1 root root 29 2010-11-05 13:16 /usr/lib/libgtksourceview-2.0.so.0 -> libgtksourceview-2.0.so.0.0.0
-rw-r--r-- 1 root root 426824 2010-10-01 11:43 /usr/lib/libgtksourceview-2.0.so.0.0.0
So on my system the editor works because there is a libgtksourceview-2.0.so.0.

Thanks,
Peter

User avatar
vovchik
Posts: 1507
Joined: Tue 24 Oct 2006, 00:02
Location: Ukraine

screensize and dpi

#164 Post by vovchik »

Dear puppians,

HUG has a function to deliver screensize:

Code: Select all

SCREENSIZE(0)
SCREENSIZE(1)
for x and y.

If not using HUG, I wrote a little cli routine that uses gtk/gdk libs:

Code: Select all

' *************************************************************
' PROGRAM:	screensize.bac
' PURPOSE:	get X screen size in pixels from default display
' AUTHOR:		vovchik (Puppy Linux forum)
' COMMENTS:	GPL		
' DEPENDS:	bacon 0.19, gtk, gdk libs
' PLATFORM:	Linux (actually, any *nix)
' DATE:		03-10-2010
' VERSION:	0.1a
' *************************************************************

' *********************
' DEF ERROR HANDLER
' *********************

TRAP LOCAL
CATCH GOTO PRINT_ERROR

' *********************
' END DEF ERROR HANDLER
' *********************


' *********************
' CONSTANTS
' *********************

CONST Gtk$ = "libgtk-x11-2.0.so.0"
CONST Gdk$ = "libgdk-x11-2.0.so.0"

' *********************
' END CONSTANTS
' ********************


' *********************
' DECLARATIONS
' *********************

DECLARE MyScreen$ TYPE STRING

' *********************
' END DECLARATIONS
' *********************


' *********************
' IMPORTS
' *********************

IMPORT "gtk_init(int*,void*)" FROM Gtk$ TYPE void
IMPORT "gtk_exit(int)" FROM Gtk$ TYPE void
IMPORT "gtk_window_get_size(long,int*,int*)" FROM Gtk$ TYPE void
IMPORT "gdk_screen_get_default" FROM Gdk$ TYPE long
IMPORT "gdk_screen_get_width(long)" FROM Gdk$ TYPE int
IMPORT "gdk_screen_height(long)" FROM Gdk$ TYPE int

' *********************
' END IMPORTS
' *********************


' *********************
' FUNCTIONS
' *********************

' ------------------
FUNCTION SCREENSIZE(NUMBER mode)
' ------------------
	' mode = 0 returns x (width)
	' mode = 1 returns y (height)
	' mode = 2 returns space-delimited x (width) and y (height)
	' otherwise function returns error message
	LOCAL x, y TYPE int
	LOCAL myresult$ TYPE STRING
	y = gdk_screen_height(gdk_screen_get_default())
	x = gdk_screen_get_width(gdk_screen_get_default())
	SELECT mode
		CASE 0
			myresult$ = STR$(x)
		CASE 1
			myresult$ = STR$(y)
		CASE 2
			myresult$ = CONCAT$(STR$(x), " ", STR$(y))
		DEFAULT
			myresult$ = CONCAT$("Error: SCREENSIZE(", STR$(mode), ") mode is bad: 0 = w, 1 = h and 2 = h and w.")
	END SELECT
	RETURN CHOP$(myresult$)
END FUNCTION


' *********************
' END FUNCTIONS
' *********************


' *********************
' MAIN
' *********************

gtk_init(0, 0)
MyScreen$ = SCREENSIZE(0)
PRINT MyScreen$
MyScreen$ = SCREENSIZE(1)
PRINT MyScreen$
MyScreen$ = SCREENSIZE(2)
PRINT MyScreen$
MyScreen$ = SCREENSIZE(3)
PRINT MyScreen$
gtk_exit(0)
END

' *********************
' END MAIN
' *********************


' *********************
' ERROR HANDLER
' *********************

LABEL PRINT_ERROR
    PRINT "GTK library ", Gtk$, " is not available on this platform!"
    END

' *********************
' END ERROR HANDLER
' *********************
I also one ported a python script that calculated dpi, but it relies on knowing the diagonal of the screen:

Code: Select all

' ***********************************************************
' PROGRAM:      dpicalc.bac
' PURPOSE:      to calculate dpi for a given screen resolution
'                       and size
' AUTHOR:               vovchik (Puppy Linux forum)
' COMMENTS:     ported from an Arch Linux python script                
' DEPENDS:      bash, bacon
' PLATFORM:     Puppy Linux (actually, any *nix)
' DATE:         22-01-2010
' VERSION:      0.1
' ***********************************************************

' *****************
' DECLARATIONS
' *****************

GLOBAL hres, vres, dsize, dpi, mydpi TYPE FLOATING
GLOBAL version$ TYPE STRING

' *****************
' END DECLARATIONS
' *****************

' *****************
' INIT VARS
' *****************

version$ = "v. 0.1"

' *****************
' END INIT VARS
' *****************


' *****************
' FUNCTIONs
' *****************

FUNCTION CALCDPI(FLOATING hres, FLOATING vres, FLOATING dsize)
        dpi = hres/(hres / SQR(POW(hres,2) + POW(vres,2)) * dsize)
        RETURN dpi
END FUNCTION

FUNCTION USAGE()
        PRINT NL$,"BaCon DPI Calculator - ", version$,NL$
        PRINT "Usage: dpicalc hres vres size", NL$
        PRINT "Where:"
        PRINT "  hres = horizontal resolution in pixels"
        PRINT "  vres = vertical resolution in pixels"
        PRINT "  size = diag. size of screen in inches",NL$
        PRINT "Example: dpicalc 1280 1024 19", NL$
        END
        RETURN TRUE
END FUNCTION

FUNCTION GETARGS()
        SPLIT ARGUMENT$ BY " " TO array$ SIZE dimension
        IF dimension < 4 THEN
                USAGE
        ELSE
                IF VAL(array$[1]) > 0 AND VAL(array$[2]) > 0 AND VAL(array$[3]) > 0 THEN
                        hres   = VAL(array$[1])
                        vres   = VAL(array$[2])
                        dsize  = VAL(array$[3])
                ELSE
                        PRINT NL$, "DPI Calculator: Input arguments contain bad values."
                        USAGE
                END IF
        END IF
        RETURN TRUE
END FUNCTION

FUNCTION SHOWRESULTS()
        STR1$ = "Calculated DPI for screen resolution of "
        PRINT NL$, STR1$, hres,"x",vres," pixels and ",dsize, " in."," diagonal = ", mydpi, NL$
        RETURN TRUE
END FUNCTION

' *****************
' END FUNCTIONS
' *****************


' *****************
' MAIN
' *****************

GETARGS
mydpi = CALCDPI(hres, vres, dsize)
SHOWRESULTS
END

' *****************
' END MAIN
' *****************
If we could get the physical monitor dimensions somewhere, the entire business could be made automatic. :( Barry or Peter to the rescue????

Any ideas?

With kind regards,
vovchik
Last edited by vovchik on Tue 30 Nov 2010, 14:31, edited 1 time in total.

User avatar
vovchik
Posts: 1507
Joined: Tue 24 Oct 2006, 00:02
Location: Ukraine

pnotify results

#165 Post by vovchik »

Dear puppians (and seaside),

Does pnotify work for you? I am interested, because we could probably use such a thing in Puppy and I want to know whether it is worth my while to (1) add a user-supplied icon to the mix and (2) to make the calling syntax relatively gnome notify compatible. Any thoughts, guys and gals?

With kind regards,
vovchik

seaside
Posts: 934
Joined: Thu 12 Apr 2007, 00:19

Re: pnotify results

#166 Post by seaside »

vovchik wrote:Dear puppians (and seaside),

Does pnotify work for you?
vovchik
vovchik,

As I mentioned, in pup431, it requires some unknown (at least to me :D ) items from the 431 devx to run. I've checked the lib names required by pnotify and they are all available in the pup431.sfs file??????

As soon as I load the 431devx, all of the pnotiify execs run, no matter which bash is installed or which bash compiled it.

Best Regards,
s
(And, yes, I think this would be a very nice addition :D :D )

User avatar
vovchik
Posts: 1507
Joined: Tue 24 Oct 2006, 00:02
Location: Ukraine

#167 Post by vovchik »

Dear seaside,

I am wondering about your problem with the devx files. I have done all my stuff without probs in 3.01 (my mods) and 4x using devx and in Ubuntu and SUSE, too. You must be missing some essential binaries and libs. All of this should compile fine if you have a normal dev environment. Please list the missing libs or binaries. Bacon will scream about what it can't find, which gives and indication about what has to be installed. I'll really try to help. I think we can get your system running without too much difficulty. Come on folks, let's get seaside working......

With kind regards,
vovchik

jpeps
Posts: 3179
Joined: Sat 31 May 2008, 19:00

#168 Post by jpeps »

Seaside: Did you check after pfix=ram? All apps I've tried work in Lucid with no dev & bash 3

seaside
Posts: 934
Joined: Thu 12 Apr 2007, 00:19

#169 Post by seaside »

jpeps wrote:Seaside: Did you check after pfix=ram? All apps I've tried work in Lucid with no dev & bash 3
jpeps,

All apps work on pup431 as well EXCEPT pnotify. And when the 431 devx file is loaded, pnotify works, but does not when the 431 devx isn't loaded.

I tried copying the files from the 431 devx/usr/lib files to /usr/lib and it works - so one or more of the files in 431 devx/usr/lib area are needed.

Since no complaints of missing libs are made, it is very odd indeed.

I've also tested pnotify in the pup5 series and it works....

I'm interested in seeing if anyone can run pnotify in pup431 without the 431 devx files.

Cheers,
s

2lss
Posts: 225
Joined: Sun 20 Sep 2009, 23:54

#170 Post by 2lss »

PjotAwake wrote:Can you show the output of 'ls -l /usr/lib/libgtksourceview-2.0.so*' ?

Code: Select all

# ls -l /usr/lib/libgtksourceview-2.0.so*
lrwxrwxrwx 1 root root     29 2010-11-14 11:22 /usr/lib/libgtksourceview-2.0.so -> libgtksourceview-2.0.so.0.0.0
lrwxrwxrwx 1 root root     29 2010-11-17 22:07 /usr/lib/libgtksourceview-2.0.so.0 -> libgtksourceview-2.0.so.0.0.0
-rwxr-xr-x 1 root root 238184 2009-10-15 20:24 /usr/lib/libgtksourceview-2.0.so.0.0.0
I'm not sure which version of gtksourceview is used in 4.3, so I compiled version 2.11.2 and gave it a try. Unfortunately no luck.

I then tried adding some debugging lines to the source code and discovered that for some reason, the functions are getting imported from the wrong gtk library.

Code: Select all

Symbol not found in library /usr/lib/libgtk-x11-2.0.so: undefined symbol: gtk_source_buffer_new_with_language
After playing with the code, I was unable to determine the problem. So I replaced lib$ with "libgtksourceview-2.0.so" for every import function in the Find_GtkSource_Library sub and (cue drum roll)........ the editor works!

Its funny because I added a line; "PRINT lib$" before the first import function, and got "libgtksourceview-2.0.so" as a result.

I'm stumped, any ideas Peter??

2lss
Posts: 225
Joined: Sun 20 Sep 2009, 23:54

#171 Post by 2lss »

seaside wrote:I'm interested in seeing if anyone can run pnotify in pup431 without the 431 devx files.
I can confirm your problem using puppeee 4.3

pnotify works with devx loaded however after after removing I get:

Code: Select all

ERROR: signal for SEGMENTATION FAULT received - memory invalid or array out of bounds? Try to compile the program with TRAP LOCAL to find the cause.

User avatar
PjotAwake
Posts: 34
Joined: Wed 03 Nov 2010, 20:58
Location: The Hague, The Netherlands
Contact:

#172 Post by PjotAwake »

I then tried adding some debugging lines to the source code and discovered that for some reason, the functions are getting imported from the wrong gtk library.

Code: Select all

Symbol not found in library /usr/lib/libgtk-x11-2.0.so: undefined symbol: gtk_source_buffer_new_with_language
After playing with the code, I was unable to determine the problem. So I replaced lib$ with "libgtksourceview-2.0.so" for every import function in the Find_GtkSource_Library sub and (cue drum roll)........ the editor works!
Strange - OR you are using an older version of BaCon to compile the program, OR your 'source.bac' file was corrupted some way or another...? Are you using the latest Editor...? And of course, the latest BaCon?

Thanks,
Peter

User avatar
vovchik
Posts: 1507
Joined: Tue 24 Oct 2006, 00:02
Location: Ukraine

#173 Post by vovchik »

Dear PjotAwake,

Could this also be the problem afflicting some users trying to compile pnotify in Puppy 4.3.1 (seaside and 2lss)? I can also change all the lib refs to direct names as you have may have tried and not use the variables....

Ideas?

With kind regards,
vovchik

PS. I did not experience problems compiling the IDE (source.bac) in Ubuntu or in Puppy 4.10 with all the development libs present. Funny.

seaside
Posts: 934
Joined: Thu 12 Apr 2007, 00:19

#174 Post by seaside »

WORKING ......

I did a diff between 431devx/usr/lib and pup431.sfs/usr/lib and found that the pup431.sfs/usr/lib does not have these links.

"libgtk-x11-2.0.so"
"libgdk-x11-2.0.so"
"libglib-2.0.so"
"libgobject-2.0.so"

When linked it works, even though the pnotify code has this

Code: Select all

CONST hug_Gtk$ = "libgtk-x11-2.0.so.0"
CONST hug_Gdk$ = "libgdk-x11-2.0.so.0"
CONST hug_Glib$ = "libglib-2.0.so.0"
CONST hug_Gobject$ = "libgobject-2.0.so.0"
I guess the coding looks for xxx.so and if not found it faults.

The pup5 series pup.sfs files all have the above links, which is why it works there.

All is well :D
s

User avatar
vovchik
Posts: 1507
Joined: Tue 24 Oct 2006, 00:02
Location: Ukraine

#175 Post by vovchik »

Dear seaside,

BRILLIANT.... Thanks.

With kind regards,
vovchik

2lss
Posts: 225
Joined: Sun 20 Sep 2009, 23:54

#176 Post by 2lss »

PjotAwake wrote:Strange - OR you are using an older version of BaCon to compile the program, OR your 'source.bac' file was corrupted some way or another...? Are you using the latest Editor...? And of course, the latest BaCon?

Thanks,
Peter
:oops:

I probably should have checked that first. It seems that I copied the wrong binary between machines.

The editor now works! ...... along with syntax highlighting! 8)

User avatar
PjotAwake
Posts: 34
Joined: Wed 03 Nov 2010, 20:58
Location: The Hague, The Netherlands
Contact:

#177 Post by PjotAwake »

The editor now works! ...... along with syntax highlighting!
Thanks for letting know!

By the way, I created a small program which allows you to download all original BaCon files from the BaCon website. If you consequently use this program all should be fine :)

Regards
Peter

seaside
Posts: 934
Joined: Thu 12 Apr 2007, 00:19

Lib Error

#178 Post by seaside »

I was just wondering why Peter's "editor" program did not fail in pup431 because it called the same libs as "pnotify" did. And so I looked at the "editor.bac" code and found that there was this sequence checking where the lib suffix was incremented and then retryed.

Code: Select all

lib$ = "libgtk-x11-2.0.so"
    seq = -1

    LABEL import_retry
	INCR seq
	retry = FALSE
	IMPORT "gtk_init(int*,void*)" FROM lib$ TYPE void
	IF retry THEN GOTO import_retry



LABEL handle_error
	ERROR = 0
	IF seq IS 0 THEN lib$ = "libgtk-x11-2.0.so.0"
	ELSE lib$ = CONCAT$(LEFT$(lib$, INSTRREV(lib$, ".")), STR$(seq))
	IF seq < 50 THEN retry = TRUE
	ELSE
	    PRINT "Gtk library not found!"
	    END
	END IF

Perhaps this checking would be useful in programs to avoid a "seg fault error" which isn't very informative.

Thanks Peter and Vochik for bringing BaCon to such rapid and improving development.

Regards,
s

big_bass
Posts: 1740
Joined: Mon 13 Aug 2007, 12:21

#179 Post by big_bass »

PjotAwake
By the way, I created a small program which allows you to download all original BaCon files from the BaCon website. If you consequently use this program all should be fine

thank you for the program !
there was a very minor edit needed for it to work
on my box



ERROR: argument to OPTION at line 7 in file 'fetch.bac' not recognized!

so I just commented out line 7 which was this

Code: Select all

'OPTION COLLAPSE TRUE
and it worked perfectly !


P.S this could be modified to fetch files elsewhere too :D

BTW I ended up with a total of 124 files downloaded
and very quickly

Code: Select all

# ./bacon.bash -v 

BaCon version 1.0 build 19 - BASH - (c) Peter van Eerten - GPL v3.
Joe
Last edited by big_bass on Fri 03 Dec 2010, 06:48, edited 1 time in total.

User avatar
PjotAwake
Posts: 34
Joined: Wed 03 Nov 2010, 20:58
Location: The Hague, The Netherlands
Contact:

#180 Post by PjotAwake »

Hi big_bass,
so I just commented out line 7 which was this

Code: Select all

'OPTION COLLAPSE TRUE
and it worked perfectly !
Well the OPTION COLLAPSE was introduced in BaCon 1.0 build 18, for me it works fine. What version are you using? Maybe you are still with the previous build12 which was shipped with Puppy?

Best regards
Peter

Post Reply