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.
Post Reply
Message
Author
User avatar
vovchik
Posts: 1507
Joined: Tue 24 Oct 2006, 00:02
Location: Ukraine

Lobster's woes

#81 Post by vovchik »

Dear Lobster,

I am attaching the latest hug.bac and glade.bac as an archive. I know they work fine. Just unpack and replace your old files with these.

With kind regards,
vovchik
Attachments
hug-glade.tar.gz
(12.63 KiB) Downloaded 378 times

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

#82 Post by jpeps »

I'm probably doing something wrong, but:

Code: Select all

~/Downloads/bacon/cli-demos $ sudo bacon c mastermind.bac 
Starting conversion... done.   
Applying indentation... sh: indent: command not found
Unable to delete file: No such file or directory
I'm using Lucid 2.3.5, with GNU bash, version 4.1.0(1)-release (i686-pc-linux-gnu).

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

indent binary

#83 Post by vovchik »

Dear jpes,

Looks as if you are missing the indent binary (and who knows what else). In any case, here is the indent binary. Place it in /usr/bin and give it another try.

With kind regards,
vovchik

PS. And just run "bacon mastermind" for compilation of the source.
Attachments
indent.tar.gz
(28.46 KiB) Downloaded 387 times

NinerSevenTango
Posts: 186
Joined: Sun 17 Jun 2007, 18:25

#84 Post by NinerSevenTango »

Who dares to attempt to compile and run the gtk-server demo on the BaCon website?

Or the Glade example calculator.

--97T--

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

gtk server demo

#85 Post by vovchik »

Dear NinerSevenTango,

The program compiles fine and will work if you first install Peter's gtk-server (http://www.gtk-server.org/). Get the latest version and compile it. Make certain your /etc/gtk-server.cfg file corresponds to your version of gtk, otherwise you will have problems. Gtk-server is very picky about correspondences between the config file and the version of gtk you are running.

With kind regards,
vovchik

NinerSevenTango
Posts: 186
Joined: Sun 17 Jun 2007, 18:25

#86 Post by NinerSevenTango »

Thanks, vovchik.

I did download and install the latest version of gtk-server.

This is a full install of Quirky 1.3.

I installed it as a 'shared object', after installing FFCall.

There is no /etc/gtk-server.cfg. I found it at /usr/local/etc/gtk-server.cfg. Should I move it, reinstall with some different options, or add a path variable? Hmmmm.

Edit: The file lists a bunch of libraries. I could find them all except:

libgtkgl-2.0.so, libgtkglext-x11-1.0.so, libgdkglext-x11-1.0.so, libgtkembedmoz.so, libpoppler-glib.so

Now I'm wondering, if the program calling it can actually find it, will it bomb if these libraries are not present?

I appreciate your response, thanks again,

--97T--

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

Re: indent binary

#87 Post by jpeps »

vovchik wrote:Dear jpes,

Looks as if you are missing the indent binary (and who knows what else). In any case, here is the indent binary. Place it in /usr/bin and give it another try.
Thanks vovchik; working now, although "calc.bac" has strange way of adding: 20 + 35 = 2035 :D

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

#88 Post by vovchik »

Dear NinerSevenTango,

I seem to have all the libs you list installed and I also have a the .cfg file in your location, in addition to /etc. If I remove the .cfg file in /etc, then gtk-server refuses to run, so in my installation that is the correct location. I remember from my previous gtk-server experiments (quite a few), that the libs called for in the config file had to be on your system. I will look into this tomorrow, since I am trying to finish an urgent job....

With kind regards,
vovchik

NinerSevenTango
Posts: 186
Joined: Sun 17 Jun 2007, 18:25

#89 Post by NinerSevenTango »

Thanks, vovchik, I believe that's enough information to save me a bunch of time fixing it. I can hunt those libs down and install them.

Happy coding!

--97T--

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

#90 Post by jpeps »

Math '+' function in calc.bac needs () to add.

PRINT (f+g)

User avatar
BarryK
Puppy Master
Posts: 9392
Joined: Mon 09 May 2005, 09:23
Location: Perth, Western Australia
Contact:

#91 Post by BarryK »

Thanks vovchik for the .bac files. I have fixed them all in /usr/share/BaCon.

Wary 0.9.8 is now released:
http://bkhome.org/blog/?viewDetailed=01964
[url]https://bkhome.org/news/[/url]

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

#92 Post by PjotAwake »

Folks,
~/Downloads/bacon/cli-demos $ sudo bacon c mastermind.bac
Starting conversion... done.
Applying indentation... sh: indent: command not found
Unable to delete file: No such file or directory
The 'c' is not needed - if you run 'bacon' without any arguments you'll see the correct usage.

The 'indent' only will be invoked if you use the '-p' option.

If you encounter 'broken' files then please note that there are plain 'bac' files on the website of BaCon also. So for each program listed simply remove the '.html' extension and download the original source.

For example:
working now, although "calc.bac" has strange way of adding: 20 + 35 = 2035
I am not able to reproduce this. Did you correctly download the .bac files (see above)?

Regards
Peter

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

#93 Post by jpeps »

PjotAwake wrote:Folks,
~/Downloads/bacon/cli-demos $ sudo bacon c mastermind.bac
Starting conversion... done.
Applying indentation... sh: indent: command not found
Unable to delete file: No such file or directory
The 'c' is not needed - if you run 'bacon' without any arguments you'll see the correct usage.

The 'indent' only will be invoked if you use the '-p' option.

If you encounter 'broken' files then please note that there are plain 'bac' files on the website of BaCon also. So for each program listed simply remove the '.html' extension and download the original source.

For example:
working now, although "calc.bac" has strange way of adding: 20 + 35 = 2035
I am not able to reproduce this. Did you correctly download the .bac files (see above)?

Regards
Peter
Hi Peter,

Seemed to need 'indent' either way.

Code: Select all

~/Downloads/bacon/cli-demos $ sudo bacon calc.bac
Starting conversion... done.   
Applying indentation... sh: indent: command not found
I'm referring to the cli-demo:

Code: Select all

 
   REM Addition
    IF key EQ 49 THEN

        PRINT "Enter first number: ";
        INPUT f
        PRINT "Enter second number: ";
        INPUT g

        PRINT "\nResult is: ";
        PRINT f+g
        PRINT

NinerSevenTango
Posts: 186
Joined: Sun 17 Jun 2007, 18:25

#94 Post by NinerSevenTango »

Looks like part of my problem is no opengl installed.

I installed the pets for mesa-7.8.1-s131, because that looked like the latest ones (except for some that look like for a newer version of x-server).

So now I get the dreaded

Xlib: extension "GLX" missing on display ":0.0".
Error: couldn't get an RGB, Double-buffered visual


I made sure to change the Disable to:

Load "glx" #LOADGLX

in xorg.conf.

That's an awful lot of forum searching and fiddling around, and still no luck.

It would be a boon to mankind if someone who had gotten a recent build of Puppy working with all this stuff would release a remastered ISO. <Moaning snipped, I could go to a bloated distro if I didn't want Puppy so bad.>

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

#95 Post by PjotAwake »

Hi jpeps,

Can you tell me which version of BaCon you are using? Hope it is build 19. Furthermore, are you using the BASH version, or the binary version?

Note that if you use the BASH version of BaCon, you *must* use BASH 4.x or higher. In case of the binary, it should have been compiled within a BASH 4.x or higher.

If the Kornshell version was used, all Kornshell versions are woking fine.

The calculator (shell version) works fine for me:
peter@laptop:~/programming/bacon$ bash --version
GNU bash, version 4.0.33(1)-release (x86_64-pc-linux-gnu)
Copyright (C) 2009 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>

This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
peter@laptop:~/programming/bacon$
peter@laptop:~/programming/bacon$ ./bacon.bash calculator
Starting conversion... done.
Starting compilation... done.
Program 'calculator' ready.
peter@laptop:~/programming/bacon$ ./calculator

-= BACON Calculator =-

1) Perform addition
2) Perform substraction
3) Perform multiplication
4) Perform division
5) Quit

Enter your choice...
Enter first number: 20
Enter second number: 35

Result is: 55

1) Perform addition
2) Perform substraction
3) Perform multiplication
4) Perform division
5) Quit

Enter your choice...
Thanks for using this calculator!
Please let me know,

Peter

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

#96 Post by jpeps »

PjotAwake wrote:Hi jpeps,

Can you tell me which version of BaCon you are using? Hope it is build 19. Furthermore, are you using the BASH version, or the binary version?

Note that if you use the BASH version of BaCon, you *must* use BASH 4.x or higher. In case of the binary, it should have been compiled within a BASH 4.x or higher.

If the Kornshell version was used, all Kornshell versions are woking fine.

The calculator (shell version) works fine for me:
peter@laptop:~/programming/bacon$ bash --version
GNU bash, version 4.0.33(1)-release (x86_64-pc-linux-gnu)
Copyright (C) 2009 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>

This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
peter@laptop:~/programming/bacon$
peter@laptop:~/programming/bacon$ ./bacon.bash calculator
Starting conversion... done.
Starting compilation... done.
Program 'calculator' ready.
peter@laptop:~/programming/bacon$ ./calculator

-= BACON Calculator =-

1) Perform addition
2) Perform substraction
3) Perform multiplication
4) Perform division
5) Quit

Enter your choice...
Enter first number: 20
Enter second number: 35

Result is: 55

1) Perform addition
2) Perform substraction
3) Perform multiplication
4) Perform division
5) Quit

Enter your choice...
Thanks for using this calculator!
Please let me know,

Peter
Hi Peter,

I'm using version 0.110 from the bacon.tar.gz download at the front of the postings. Sounds like updated versions don't require "indent", and maybe the math func works differently. I compiled bash 4.1.0(1) with Lucid 2.3.5, so could give it a try.

Edit. Yes...I just tried bacon.bash, and calc works as is, and no need for indent.

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

#97 Post by jpeps »

gtkabout1.bac compiles and works nicely with bacon 0.110, but with bacon.bash:
~/Downloads/bacon/gtk-demos $ ./gtkabout1
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.

Note: error occurs when clicking for child window. Same after compiling new 'bacon' from bacon.bash "BaCon version 1.0 build 19"

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

#98 Post by PjotAwake »

Hi jpeps,

What is this program 'gtkabout1'? This one does not appear on the BaCon website.

Note that you were using 0.110 which is really old - it is a beta release of more than a year ago, and only after 1.0 build 1 the BaCon commands and functions were frozen. Programs which could be compiled with beta versions are likely to crash now, for example when they are using a function in a way which is not supported anymore.

Can you dump the code here so I can check it?

Thanks,
Peter

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

#99 Post by jpeps »

PjotAwake wrote:
What is this program 'gtkabout1'? This one does not appear on the BaCon website.
It's in bacon.tar.gz / gtk-demos. I'm getting similar errors with
other gtk demos, such as GTK-server demo from website...for both
versions of bacon (old and new). Non gtk demos seem to work fine.

Code: Select all

 $ ./gtk-server
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.
note: gtkserver-demo in bacon.tar.gz also gets the above error with both versions (old and new) of bacon

~ $

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

#100 Post by PjotAwake »

Jpeps,

It makes sense as the programs in that 'bacon.tar.gz' package are also more than a year old.

So forget about them!

Please use the programs shipped by Puppy Linux, or the current programs hosted on the BaCon website.

For fun I have adjusted the 'gtkabout1.bac' program so it compiles and runs with BaCon 1.0 build 19. Compare with the orignal one and you'll see the differences.

Here is the code:

Code: Select all

' ************************************************* 
' Program:	gtkabout1
' Purpose:	Demo of GTK about function
' Author:	Jan Bodnar
' Modded:	Vovchik (Puppy forum)
' Added:	added new png, text box, quit routine
' Date:		13 Nov 2009
'
' Modified for BaCon 1.0 build 19 by PvE - Nov. 2010
'
' ************************************************* 

TRAP LOCAL

GLOBAL NUL TYPE STRING

' ***********
' INIT VARS
' ***********
CONST GTK_WINDOW_TOPLEVEL = 0
CONST GTK_WIN_POS_CENTER = 1
CONST GDK_BUTTON_PRESS_MASK = 256 
' *********** 

' ***********
' LIB IMPORTS
' ***********
IMPORT "gtk_init(int*,void*)" FROM "libgtk-x11-2.0.so" TYPE void
IMPORT "gtk_window_new(int)" FROM "libgtk-x11-2.0.so" TYPE long
IMPORT "gtk_widget_show_all(long)" FROM "libgtk-x11-2.0.so" TYPE void
IMPORT "gtk_main" FROM "libgtk-x11-2.0.so" TYPE void
IMPORT "gtk_main_quit" FROM "libgtk-x11-2.0.so" TYPE void
IMPORT "g_signal_connect_data(long,char*,void*,long,long,int)" FROM "libgobject-2.0.so" TYPE void
IMPORT "g_object_unref(long)" FROM "libgobject-2.0.so.0" TYPE void
IMPORT "gdk_pixbuf_new_from_file(char*,void*)" FROM "libgdk_pixbuf_xlib-2.0.so" TYPE long
IMPORT "g_object_set(long,char*,...)" FROM "libgobject-2.0.so" TYPE void
IMPORT "gtk_show_about_dialog(long,char*,...)" FROM "libgtk-x11-2.0.so" TYPE void
IMPORT "gtk_check_version(int,int,int)" FROM "libgtk-x11-2.0.so" TYPE char*
' *********** added by vovchik
IMPORT "gtk_container_add(long,long)" FROM "libgtk-x11-2.0.so" TYPE void
IMPORT "gtk_label_new(char*)" FROM "libgtk-x11-2.0.so" TYPE long
IMPORT "gtk_table_new(int,int,int)" FROM "libgtk-x11-2.0.so" TYPE long
IMPORT "gtk_table_attach_defaults(long,long,int,int,int,int)" FROM "libgtk-x11-2.0.so" TYPE void
IMPORT "gtk_button_new_from_stock(char*)" FROM "libgtk-x11-2.0.so" TYPE long
IMPORT "gtk_exit(int)" FROM "libgtk-x11-2.0.so" TYPE void
' *********** end added by vovchik

' ***********
' SUBROUTINES
' *********** 

' ***********
' Callback for
' closing window
' *********** 

' ***********
SUB exit_prog
' ***********
    gtk_exit(0)
' ***********
ENDSUB
' ***********

' ***********
SUB show_about(long widget, long event, long dialog)
' ***********

    LOCAL pixbuf
    LOCAL v$

    IF gtk_check_version(2,12,0) EQ 0 THEN v$="program-name"
    ELSE v$="name"

    pixbuf = gdk_pixbuf_new_from_file("battery.png", NUL)
    gtk_show_about_dialog(dialog,v$,"Battery","version","0.9a","copyright","(c) Jan Bodnar\nmodded by vovchik","comments","Battery is a simple tool for battery checking.","website","http://www.basic-converter.org","logo",pixbuf,NUL)
    g_object_unref(pixbuf)

' ***********
END SUB
' ***********

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

' ***********
SUB BacMain()
' ***********

    LOCAL window, table, label, button

    gtk_init(0, 0)
    window = gtk_window_new(GTK_WINDOW_TOPLEVEL)
    g_object_set(window,"window-position",GTK_WIN_POS_CENTER,"title","Battery","default-width",220,"default-height",150,"events",GDK_BUTTON_PRESS_MASK,"border-width",15,NUL)

    ' *********** added by vochik	
    table = gtk_table_new(15, 15, 1)
    gtk_container_add(window, table)
    label = gtk_label_new("Click here for child window,\nplease! Pretty please!")
    gtk_table_attach_defaults(table, label, 1, 8, 3, 7)
    button = gtk_button_new_from_stock("gtk-cancel")
    gtk_table_attach_defaults(table, button, 10, 14, 12, 14)
    ' *********** end added by vovchik
    g_signal_connect_data(window,"button_press_event", show_about, window, 0, 0)
    g_signal_connect_data(window,"destroy", gtk_main_quit, 0, 0, 0)
    ' *********** added by vochik
    g_signal_connect_data(button, "clicked", exit_prog, 0, 0, 0)
    ' *********** end added by vovchik
    gtk_widget_show_all(window)
    gtk_main

' ***********
END SUB
' *********** 

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

BacMain

' ***********
' END MAIN
' ***********
Regards
Peter

Post Reply