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

#16 Post by vovchik »

Dear Puppians,

Peter has released his beta v. 2. Check out his site (bottom of my first post).

I have played around with Peter's hug library, which enables GTK GUIs to be created pretty painlessly. Attached is a little program that displays pngs and gifs, shows how to create buttons and to launch child windows, and how to run external progams and get the stdout results back for further processing. A bit of string handling is also in there.

The archive also includes a functioning binary and the hug lib. With a little work, this prog could also become a general pic viewer - although we already have two of Mark's excellent contributions (although they don't run on old puppy versions).

With kind regards,
vovchik
Attachments
bacon2.jpg
(51.07 KiB) Downloaded 3094 times
imgshow.tar.gz
(48.39 KiB) Downloaded 1361 times

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

#17 Post by vovchik »

Dear Puppians,

Just finished coding an icon generator in Bacon. It's here - with source:
http://www.murga-linux.com/puppy/viewtopic.php?t=49129

With kind regards,
vovchik

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

#18 Post by vovchik »

Dear Puppians,

Peter has now released his beta 3 of BaCon. You can get it here:

http://www.basic-converter.org/

With kind regards,
vovchik

edexter
Posts: 8
Joined: Wed 25 Nov 2009, 16:46

#19 Post by edexter »

I think you can con bcx basic into giving you gcc code and compiling for linux, you also have a mostly compatable interpeter availabe you would want the one from the yahoo group and you would need a dos emulator for it (unless there is a llinux version I am unaware of). It works with at least 7 c compilers including gcc, windows ce and the wii a. sorry if this is to off topic.I have some expierence with it as a package that may be transferable to the bash one also if someone is after more tools for it and has python with thier version of puppy linux(I haven't tried it yet, I think I have a bash for windows as well as linux so it sounds like it could be cross platform ). .

here is one of my tools for example, I can easily come up with source to html and maybe an ide with highlighting. between bcx basic and csound I have done alot of this type of thing.

http://dexrow.blogspot.com/2008/04/bcx- ... locks.html

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

#20 Post by vovchik »

Dear Puppians,

Peter has now released his beta 4 of BaCon, in preparation for the release of version 1 (stable). You can get it here:

http://www.basic-converter.org/

With kind regards,
vovchik

PS. Pikona compiles fine with the new version.

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

#21 Post by vovchik »

Dear Puppians,

Peter has released his stable version 1 rc. Get it here: http://www.basic-converter.org/.

He also modified/enhanced HUG (gtk API) and a few other things. My Pikona uses an older version of HUG. I will update it pretty soon. I am waiting for some others to post BaCon code here. It is a very nice, structured language that produces reasonably small executables - perfect for situations where things get messy and/or slow in bash - and unix progs can be called and the results captured into a var.With HUG, very decent GUIs can be written rather painlessly. Give it a try - you won't regret it.

With kind regards,
vovchik

mechanic
Posts: 29
Joined: Sun 12 Apr 2009, 20:20

Glade file converter

#22 Post by mechanic »

It's in no way perfect but maybe useful for someone trying out BaCON.

Comments, bug reports, improvements, etc. welcome. Especially improvements to the code.

Get it here: http://basic-converter.proboards.com/in ... &thread=21

Enjoy!
Doyle
regards,
mechanic

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

bacon glade stuff

#23 Post by vovchik »

Dear Doyle,

You mentioned on Peter's forum that you were working on a glade2Bacon converter. I would love to see the source and would find that program very useful. Imagine drawing a complex gui in glade, passing it through your prog and, presto, a wonderful GTK gui running in BaCon. Keep at it. I would be willing to lend a hand too.

With kind regards,
vovchik

PS. Sorry, I should have looked at the board and read you message carefully before posting. Wow. I can't wait to play with it. Thanks.

mechanic
Posts: 29
Joined: Sun 12 Apr 2009, 20:20

Re: bacon glade stuff

#24 Post by mechanic »

vovchik wrote:Dear Doyle,

You mentioned on Peter's forum that you were working on a glade2Bacon converter. I would love to see the source and would find that program very useful. Imagine drawing a complex gui in glade, passing it through your prog and, presto, a wonderful GTK gui running in BaCon. Keep at it. I would be willing to lend a hand too.
Thanks, it's nowhere near finished yet but it does a couple of simple glade gui examples that I have here. Of course it needs parsing of more controls and I would welcome anyone to help make it into a much more complete application. It sure would be nice to use the Glade designer for BaCON apps!

PS. Sorry, I should have looked at the board and read you message carefully before posting. Wow. I can't wait to play with it. Thanks.
Thanks go to your BaCON examples and the examples of others. I learned a lot from browsing the code.

Regards,
Doyle

PS: I'm working on the gui with the original FreeBasic code from here:

http://www.siebke.com/freebasic/glade2bas.zip
regards,
mechanic

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

Some glade thoughts

#25 Post by vovchik »

Dear mecahnic (Doyle),

I tidied up the callback prog a little (nothing substantive), just because I tend to work that way, and had another look at Peter's calc.bac program. What he does there is incorporate the *.glade source within the *.bac file via

Code: Select all

xml = glade_xml_new_from_buffer(Calc_Gui$, LEN(Calc_Gui$), 0, 0)
This means that there are no glade runtime dependencies, although the source is larger and a bit uglier! I think this would be nice for your glade callback prog, since the *.bac source would then contain all that would be required for compilation and only one binary without dependencies - apart from GTK - would be the result. Please have a look at the attachment. And the glade file could be read in like this (this is what I use):

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("myfile.glade")

In testing one of my glade files, SUBS were created for checkboxes, but no subs or signal processing for the buttons (I had to do that manually).

Incidentally, I like the size of the generated binaries - some 26k for simple guis.

With kind regards,
vovchik
Attachments
glade-stuff.tar.gz
(4.16 KiB) Downloaded 1178 times

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

Now glade xml is integrated into generated source

#26 Post by vovchik »

Dear Doyle,

I have done a little work. Please look at the attachment. I now read the glade and turn it into DATA statements and have those statements read by the generated program, so there is no external glade file needed to run the prog. Please have a look. After this, we should look at signal connects so that the buttons work.

With kind regards,
vovchik

PS. Still some work needed - getting rid of the second glade file read....
Attachments
mkglade-new.tar.gz
(21.63 KiB) Downloaded 1118 times

mechanic
Posts: 29
Joined: Sun 12 Apr 2009, 20:20

Re: Now glade xml is integrated into generated source

#27 Post by mechanic »

WOW! Very good work! Thanks!
vovchik wrote:Dear Doyle,

I have done a little work. Please look at the attachment. I now read the glade and turn it into DATA statements and have those statements read by the generated program, so there is no external glade file needed to run the prog. Please have a look. After this, we should look at signal connects so that the buttons work.
I'll take a look at the buttons and automatically adding a "gtk_main_quit" at the correct place in the code so the generated file will end correctly.

PS. Still some work needed - getting rid of the second glade file read....
I really like this way of building the new file and the way you format your code. I looked at some older *.glade files that I found just browsing around and the parsing code will have to be slightly modified in order to read these older glade files. I don't know if it's worth the effort right now.

Thank you for the ideas and the code!

Regards,
Doyle

PS: Maybe we should take this to the BaCON forum? (Or not, doesn't matter to me.)
regards,
mechanic

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

a bit of advice from Peter

#28 Post by vovchik »

Dear Doyle,

We seem to be getting somewhere and making progress, I think this little program has nice potential. Peter has been looking at the thread and just sent me a note, referring to his calc.bac program that also uses glade, with the following:
I see the comment on top (calc.bac) has an error, because the 'export-dynamic' flag, to enable callbacks from Glade to the BaCon program, should be used with the '-o' option - this comment is corrected now.
If you can get the buttons and quit stuff working, I think we are in business. There are lots of apps with ready-made guis that will be easy to port to BaCon and then customize. Think of all the python and c stuff, for instance. And, the binaries are small.

With thanks and kind regards,
vovchik

mechanic
Posts: 29
Joined: Sun 12 Apr 2009, 20:20

Re: a bit of advice from Peter

#29 Post by mechanic »

vovchik wrote:Dear Doyle,

We seem to be getting somewhere and making progress, I think this little program has nice potential. Peter has been looking at the thread and just sent me a note, referring to his calc.bac program that also uses glade, with the following:
I see the comment on top (calc.bac) has an error, because the 'export-dynamic' flag, to enable callbacks from Glade to the BaCon program, should be used with the '-o' option - this comment is corrected now.
Yes, I caught this too. It didn't help with the "glade_xml_signal_autoconnect" call however.

If you can get the buttons and quit stuff working, I think we are in business. There are lots of apps with ready-made guis that will be easy to port to BaCon and then customize. Think of all the python and c stuff, for instance. And, the binaries are small.
OK, I wondered why you said something about the button callback subs not being generated. It's because the glade file has no signals defined in it. I am catching the signal names and using that to generate the code. My test files just happened to have the signal code in the glade file.

Try a glade file which has the signals defined to see the callback subs being generated in the code.

I can do this without the signals defined but this would double the signal subs generated in the code. Sort of messy but one could probably catch this possibility and only generate one sub.

So what do you suggest? Try to make the callbacks without the signals being defined in the glade file or specify that the signals must be defined in the glade file if the user wants the callback subs generated for them.

I need a list of all controls that will need a callback sub generated. I have devhelp here and have tried to make such a list. Unfortunately, being new at using gtk, I may have missed some controls or added some that don't need a callback defined.

Thanks for your help. I appreciate it.
regards,
mechanic

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

signals and callbacks

#30 Post by vovchik »

Dear Doyle,

Please have a look at the attached archive. Peter put together a glade.bac file that is used as an include. It has all the necessary and useful imports and libs defined. I'll re-read your message and hope to post something sensible soon regarding signals.

With thanks and kind regards,
vovchik
Attachments
bvl-src.tar.gz
(19.07 KiB) Downloaded 1133 times

mechanic
Posts: 29
Joined: Sun 12 Apr 2009, 20:20

Re: signals and callbacks

#31 Post by mechanic »

vovchik wrote:Dear Doyle,

Please have a look at the attached archive. Peter put together a glade.bac file that is used as an include. It has all the necessary and useful imports and libs defined. I'll re-read your message and hope to post something sensible soon regarding signals.

With thanks and kind regards,
vovchik
Thanks but I have a copy of the glade.bac file here. I may need to add all of the IMPORTs in there but for now, it seems I have all needed.

Here is the latest source that I have. I am still working on automatically adding the close signal and connecting it correctly so that is not finished yet.

I am not adding the signals *IF* the user doesn't add them to the glade file in the Glade GUI designer. I don't want to second guess the user. They might not want the callbacks generated (can't see why but if they want them, they'll have to add them in the designer.)

Please share your thoughts on the code. What else is needed? What would be good to have added?
Attachments
mkglade.tar.gz
(3.62 KiB) Downloaded 978 times
regards,
mechanic

mechanic
Posts: 29
Joined: Sun 12 Apr 2009, 20:20

Latest glade converter for BaCON

#32 Post by mechanic »

Hi all, I completely rewrote the code making it simpler. Please test and let me know of any bugs. Seems to work on all of my test code here.
Attachments
mkglade-1.tar.gz
(2.85 KiB) Downloaded 986 times
regards,
mechanic

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

#33 Post by vovchik »

Dear Doyle,

GREAT work. I would do as you suggest - if no signal connect, just load the Glade file and add them. mkglade now picks up and makes the SUBs for my glade widgets. The only think that might be added as "standard" is a gtk_exit SUB by default.

I am now testing with various Glade files and will report back.

Thanks.

With kind regards,
vovchik

PS. I think
IMPORT "gtk_exit(int)" FROM "libgtk-x11-2.0.so" TYPE void
and the callback for closing a prog
' ---------------
SUB exit_prog()
' ---------------
gtk_exit(0)
END SUB

might be useful in nearly all cases.

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

nice compile

#34 Post by vovchik »

Dear Doyle,

Try compiling the attached. Works nicely.

With kind regards,
vovchik
Attachments
egdesigner.glade.tar.gz
(5.86 KiB) Downloaded 1011 times

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

parsing error

#35 Post by vovchik »

Dear Doyle,

The attached glade file gives a parsing error when compiling the binary. I think mkglade is missing something or getting confused. Have a look at the generated source. Bacon will point you to the line numbers.

With kind regards,
vovchik
Attachments
PupWebTV.glade.tar.gz
(941 Bytes) Downloaded 963 times

Post Reply