Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Sat 23 Aug 2014, 15:41
All times are UTC - 4
 Forum index » Off-Topic Area » Programming
BaCon - Bash-based Basic-to-C converter/compiler
Post new topic   Reply to topic View previous topic :: View next topic
Page 8 of 36 [526 Posts]   Goto page: Previous 1, 2, 3, ..., 6, 7, 8, 9, 10, ..., 34, 35, 36 Next
Author Message
seaside

Joined: 11 Apr 2007
Posts: 886

PostPosted: Sun 14 Nov 2010, 14:13    Post subject:  

Mechanic,

Quote:
Replace the function CAT(STRING FileName$): with....


Thanks, that is indeed somewhat different Very Happy Very Happy

Regards,
s
Back to top
View user's profile Send private message 
PjotAwake


Joined: 03 Nov 2010
Posts: 34
Location: The Hague, The Netherlands

PostPosted: Sun 14 Nov 2010, 17:16    Post subject:  

Hi jpeps,

Quote:

As noted, the gtk demo from website also gave the error:

~ $ sudo bacon ./gtk-server-new.bac
Starting conversion... done.
Starting compilation... done.
Program './gtk-server-new' ready.
~ $ ./gtk-server-new
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.


It seems you are referring to the GTK-server program? This is not a GTK demo, but a demo with the GTK-server.

Did you actually install GTK-server prior to running the BaCon program? Because for me this demo works fine.

Note that you will find actual GTK demo programs a little bit down below on the BaCon website.

BTW why are you using 'sudo'?

Regards
Peter
Back to top
View user's profile Send private message Visit poster's website 
ICQ Number 
jpeps

Joined: 31 May 2008
Posts: 3220

PostPosted: Sun 14 Nov 2010, 18:28    Post subject:  

PjotAwake wrote:



It seems you are referring to the GTK-server program? This is not a GTK demo, but a demo with the GTK-server.

ah...initially saw it in the gtk-demos dir of bacon.tar.gz, so thought it was independent.

Quote:

Note that you will find actual GTK demo programs a little bit down below on the BaCon website.


..just tried a few, everything working fine.

Quote:

BTW why are you using 'sudo'?


As Barry says, it's like religion. I don't run in root. Thanks for the great work!
Back to top
View user's profile Send private message 
big_bass

Joined: 13 Aug 2007
Posts: 1747

PostPosted: Sun 14 Nov 2010, 19:39    Post subject:  

Hey mechanic
I took your suggestion and used it for the speed increase (to compile faster)

and updated the bacon auto install script a bit more
updated again to make code much more compact to read a list
this way adding the bac files you need in a snap

thanks
Joe

@Thank you Peter van Eerten

get started on the right foot
one of the little gotchas is just getting the .bac file without the html so this is
only the .bac file
it will save as text hope its handy for some one

-------Demonstration programs---------------------------------------------

Base64 decoder http://www.basic-converter.org/b64dec.bac
The Zeller algorithm http://www.basic-converter.org/zeller.bac
UTF8 encoder http://www.basic-converter.org/utf8.bac
Simple calculator programhttp://www.basic-converter.org/calculator.bac
CGI demonstration http://www.basic-converter.org/cgi.bac
GTK-server demo http://www.basic-converter.org/gtk-server.bac



Brainfuck interpreter http://www.basic-converter.org/bf.bac
Respace files http://www.basic-converter.org/respace.bac
ROT13 encoder/decoder http://www.basic-converter.org/rot13.bac
Mastermind gamehttp://www.basic-converter.org/mastermind.bac
My favorite one liner http://www.basic-converter.org/hex.bac



Recursive http://www.basic-converter.org/fibonacci.bac and http://www.basic-converter.org/factorial.bac
Walk through a directory tree http://www.basic-converter.org/tree.bac
Generate prime numbers http://www.basic-converter.org/prime.bac
Generate m3u files http://www.basic-converter.org/m3u.bac



Convert decimal to Roman http://www.basic-converter.org/roman.bac
A Quine program http://www.basic-converter.org/quine.bac, an even smaller Quine http://www.basic-converter.org/quine2.bac, even smaller http://www.basic-converter.org/quine3.bac
DPI calculator http://www.basic-converter.org/dpicalc.bac created by Vovchik
A simple GOPHER client http://www.basic-converter.org/gopher.bac



System boot time http://www.basic-converter.org/bootime.bac
Binary file dumper http://www.basic-converter.org/bindump.bac
BaCon Bullshit Bingo http://www.basic-converter.org/bbb.tar.gz created by Vovchik
Password generator http://www.basic-converter.org/bpwgen.bac created by Vovchik
Testing randomness program http://www.basic-converter.org/prob.bac created by Vovchik



The Soundex algorithm http://www.basic-converter.org/soundex.bac created by Vovchik
The Metaphone algorithm http://www.basic-converter.org/metaphone.bac created by Vovchik
The Double Metaphone algorithm http://www.basic-converter.org/dbl-metaphone.bac created by Vovchik
BaCon On This Day http://www.basic-converter.org/botd.tar.gz created by Vovchik


Calculate netmask http://www.basic-converter.org/netmask.bac
Console sinus waves http://www.basic-converter.org/sinus.bac
Check remote site http://www.basic-converter.org/network.bac modified version http://www.basic-converter.org/bing.bac by Vovchik
Get the weather http://www.basic-converter.org/bweather.bac created by Vovchik



Benchmark program for http://www.basic-converter.org/benchmark.bac
Binary downloads http://www.basic-converter.org/download.bac
Simple BaCon Shell http://www.basic-converter.org/shell.bac
Some goniometric functions http://www.basic-converter.org/trig.bac created by Vovchik





User contributions

STRCMP function http://www.basic-converter.org/strcmp.bac

Last edited by big_bass on Wed 17 Nov 2010, 10:39; edited 3 times in total
Back to top
View user's profile Send private message 
vovchik


Joined: 23 Oct 2006
Posts: 1285
Location: Ukraine

PostPosted: Mon 15 Nov 2010, 05:10    Post subject: Screen size  

Dear Puppians,

I banged this together to demonstrate how you you can use GDK/GTK libs in a CLI program in BaCon to obtain, for instance, the size of the display.

Code:

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

' *********************
' DEF ERROR HANDER
' *********************

TRAP LOCAL
CATCH GOTO PRINT_ERROR

' *********************
' END DEF ERROR HANDER
' *********************


' *********************
' 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
' *********************


With kind regards,
vovchik

PS. Nice work, Joe.
PPS. Source and binary are in the attached archive.
screensize-src.tar.gz
Description 
gz

 Download 
Filename  screensize-src.tar.gz 
Filesize  10.88 KB 
Downloaded  275 Time(s) 
Back to top
View user's profile Send private message 
BarryK
Puppy Master


Joined: 09 May 2005
Posts: 7047
Location: Perth, Western Australia

PostPosted: Mon 15 Nov 2010, 10:53    Post subject:  

Hey guys, my first GTK application written in BaCon!!!!! Very Happy

http://bkhome.org/bacon/my-1st-gtk-app/index.html

I will be tweaking it a bit more, to get it integrated into Puppy, and with the network setup tools. It is expected to be in all future puppies.

Note, I'm not sure, but it might be necessary to also put this into /etc/wgetrc:

Code:
use_proxy = on


It was a fun experience.

Here is the binary executable, gunzip it, make sure it is executable and bung it somewhere in the path:
proxy-setup.gz
Description 
gz

 Download 
Filename  proxy-setup.gz 
Filesize  24.22 KB 
Downloaded  321 Time(s) 

_________________
http://bkhome.org/news/
Back to top
View user's profile Send private message Visit poster's website 
esmourguit


Joined: 17 Nov 2006
Posts: 1288
Location: Sur l'ile aux oiseaux.

PostPosted: Mon 15 Nov 2010, 12:32    Post subject:  

Bonjour à tous,

I tested it in Toutou Linux 4.3.1, it seems to work. At least, it opens.

As it seems we're at the beginning of the creation (and maybe later adaptation of old scripts) of programs, written with bacon, for new versions of Wary, Quirky, etc., would it be possible to localize them now with a .mo file?
If possible of course.

Cordialement Wink

_________________
Toutou Linux - Pets francisés
Back to top
View user's profile Send private message 
seaside

Joined: 11 Apr 2007
Posts: 886

PostPosted: Mon 15 Nov 2010, 18:23    Post subject:  

Barry,

Always nice to try something new....

I get the following problem of cut off characters, not only in your program, but in some of the gui demos as well. See below.

Regards,
s
proxy-server.png
 Description   
 Filesize   28.97 KB
 Viewed   1275 Time(s)

proxy-server.png

Back to top
View user's profile Send private message 
jpeps

Joined: 31 May 2008
Posts: 3220

PostPosted: Mon 15 Nov 2010, 18:44    Post subject:  

Looking forward to a directory of examples using various widgets, which will save a huge amount of trial & error.
MyFavorites.png
Description 
png

 Download 
Filename  MyFavorites.png 
Filesize  378.65 KB 
Downloaded  302 Time(s) 
Back to top
View user's profile Send private message 
BarryK
Puppy Master


Joined: 09 May 2005
Posts: 7047
Location: Perth, Western Australia

PostPosted: Mon 15 Nov 2010, 20:43    Post subject:  

seaside wrote:
Barry,

Always nice to try something new....

I get the following problem of cut off characters, not only in your program, but in some of the gui demos as well. See below.

Regards,
s


Vovchik has kindly looked through my code and made some refinements, including improving that problem with big fonts.
I will be updating the application soon.

_________________
http://bkhome.org/news/
Back to top
View user's profile Send private message Visit poster's website 
seaside

Joined: 11 Apr 2007
Posts: 886

PostPosted: Mon 15 Nov 2010, 21:48    Post subject:  

big_bass ,

Thanks for all that material on BaCon - it makes it very inviting to try out everything.

Also, perhaps a test of bash version would be useful in your script
Code:
BASHV=$(bash --version)
VN=$(echo $BASHV | cut -f1 -d. | sed 's/^.*\(.\)$/\1/')
[ $VN -lt 4 ] && gxmessage -title "Bash Version Problem" -center -bg orange "$BASHV installed
---------------> Bash must be version 4 <-------------------" & exit


Barry & Vovchik,

Thanks for all your efforts.

Regards,
s
Back to top
View user's profile Send private message 
jpeps

Joined: 31 May 2008
Posts: 3220

PostPosted: Tue 16 Nov 2010, 03:03    Post subject:  

Any demos of hug radiobuttons? Looks like it should be similar to check buttons with an added group number, but I get segmentation errors after compiling. 'btn_1 = RADIO("text", x, y, grp)' Thanks in advance.
Back to top
View user's profile Send private message 
vovchik


Joined: 23 Oct 2006
Posts: 1285
Location: Ukraine

PostPosted: Tue 16 Nov 2010, 05:11    Post subject: Raio buttons  

Dear jpeps,

In my tests, radio buttons in HUG work exactly as advertised. Try this code:

Code:

INCLUDE "hug.bac"

win_width = 200
win_height = 100
mainwin = WINDOW("Radio test", win_width, win_height)
my_radio1 = RADIO("On", 50, 30, my_radio2)
my_radio2 = RADIO("Off", 50, 30, my_radio1)
ATTACH(mainwin, my_radio1, 20, 20)
ATTACH(mainwin, my_radio2, 20, 50)
DISPLAY


With kind regards,
vovchik
Back to top
View user's profile Send private message 
jpeps

Joined: 31 May 2008
Posts: 3220

PostPosted: Tue 16 Nov 2010, 07:01    Post subject: Re: Raio buttons  

vovchik wrote:
Dear jpeps,

In my tests, radio buttons in HUG work exactly as advertised. Try this code:

Code:

INCLUDE "hug.bac"

win_width = 200
win_height = 100
mainwin = WINDOW("Radio test", win_width, win_height)
my_radio1 = RADIO("On", 50, 30, my_radio2)
my_radio2 = RADIO("Off", 50, 30, my_radio1)
ATTACH(mainwin, my_radio1, 20, 20)
ATTACH(mainwin, my_radio2, 20, 50)
DISPLAY


With kind regards,
vovchik


Thanks vovchik,

And for a group? Specifically, I was looking at:

FUNCTION RADIO (STRING text$, int xsize, int ysize, NUMBER group)

(I did something similar using checkbuttons with a reset function)
Back to top
View user's profile Send private message 
big_bass

Joined: 13 Aug 2007
Posts: 1747

PostPosted: Tue 16 Nov 2010, 10:03    Post subject:  

Hey seaside


I used your suggestion and code for the bash test
I just converted it to Xdialog to keep the theme the same
and cut the message down a bit




thanks I will add it to the down loader, compiler, tester

*I added a credit comment to the script for you and mechanic

thanks

Joe

Code:

BASHV=$(bash --version | head -1)
VN=$(echo $BASHV | cut -f1 -d. | sed 's/^.*\(.\)$/\1/')
[ $VN -lt 4 ] && Xdialog --title "bash version test " \
           --infobox "\nBash Version Problem $BASHV installed
---------------> Bash must be version 4 or above for BaCon <-------------------" "\n" 0 0

_________________
debian wheezy ,linux mint, slackware I use them all and they all have good points
Mint would be best for general users though
Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 8 of 36 [526 Posts]   Goto page: Previous 1, 2, 3, ..., 6, 7, 8, 9, 10, ..., 34, 35, 36 Next
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » Off-Topic Area » Programming
Jump to:  

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
[ Time: 0.1228s ][ Queries: 13 (0.0132s) ][ GZIP on ]