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
User avatar
GatorDog
Posts: 138
Joined: Tue 12 Sep 2006, 16:43

#341 Post by GatorDog »

sunburnt wrote:Another code Q...
The BaCon docs seem pretty clear on how to use CALLBACKX ...

Code: Select all

CALLBACKX(widget, function, value)

Type: directive

Defines a self-defined <function> where HUG should jump to when an event for <widget> occurs, 
and pass <value> to that function. The arguments in the callback function should catch this value.

Example:

INCLUDE "hug.bac"

SUB demo(NUMBER widget, NUMBER value)
    PRINT value
END SUB
Modify your sub definition-
SUB showDLG(NUMBER Handle_, int btnN)
# I`m trying to reuse the same FileDialog with different buttons.
....... Each button gets it`s own EntryBox filled from the FileDialog.
....... Should only need to declare/create one FileDialog, right?
Probably one, for each type used.
# It`d be nice to be able to control the FileDialog type and WinTitle.

Code: Select all

TEXT(widget, "text")
Depending on the widget, sets the text. The current behavior is shown in the table below.
WINDOW Sets the text in the title bar
# Additional Q... Way to get a return from a Bacon exec file? Like a function?

Code: Select all

EXEC$(command$ [, stdin$])

Type: function

Executes an operating system command and returns the result to the BaCon program. 
The exit status of the executed command itself is stored in the reserved variable RETVAL. 
Optionally a second argument may be used to feed to STDIN. See SYSTEM to plainly execute a 
system command. Example:

result$ = EXEC$("ls -l")
result$ = EXEC$("bc", CONCAT$("123*456", NL$, "quit"))
Or, if you mean for a Bacon program to return a value on STDIN, simply have it PRINT the
value before it exits.

rod

User avatar
sunburnt
Posts: 5090
Joined: Wed 08 Jun 2005, 23:11
Location: Arizona, U.S.A.

#342 Post by sunburnt »

Thanks again GatorDog; I`m getting the feel of Bacon, it`s different than QBasic.

Here`s something I was talking about, and you helped me write it.
FFdialog ... ( FileFolder dialog )
It`s an exec. of the FileDialog, it works in Bacon-HUG and in the Bash shell !
Returns the /path/[file], and it also sets the proper WinTitle.

# Just one problem: In the shell it works fine, but...
In Bacon, it leaves a control character at the end of it`s return, probably a LF.
I suppose I`ll have to filter it out in the Bacon program that calls it ( dang! ).

Compile it and make an app. to run it with a label to show the return.
To exec. it:

Code: Select all

FFdialog [ 0 - 3 ]
Take your time... No big rush that you mess with this... Terry
Attachments
FFdialog.bac.gz
(477 Bytes) Downloaded 413 times

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

#343 Post by vovchik »

Dear sunburnt,

Try this out:

Code: Select all

IF INSTR(ARGUMENT$, " ") = 0 THEN
	Style = 0
ELSE
	Style = VAL(CHOP$(RIGHT$(ARGUMENT$, 1)))
END IF
CHOP$ removes exteraneous garbage....and it works.

With kind regards,
vovchik

User avatar
sunburnt
Posts: 5090
Joined: Wed 08 Jun 2005, 23:11
Location: Arizona, U.S.A.

#344 Post by sunburnt »

vovchik; Yes, I`d just hoped that the LF could be removed in FFdialog.
Further checks proved it can`t be, so it must occur when passed to the caller.
Fixed in the Bacon calling program, not in FFdialog.

Code: Select all

FF$ = CHOP$(EXEC$(Title$, "2"))
Strange how the Bash shell doesn`t get the LF but Bacon does...

User avatar
GatorDog
Posts: 138
Joined: Tue 12 Sep 2006, 16:43

#345 Post by GatorDog »

...Yes, I`d just hoped that the LF could be removed in FFdialog.
Ah yes, sahib, your wish is my command :twisted:
PRINT
...
Prints a numeric value, text, variable or result from expression.
A semicolon at the end of the line prevents printing a newline.
Lookin' good
Gatordog

User avatar
sunburnt
Posts: 5090
Joined: Wed 08 Jun 2005, 23:11
Location: Arizona, U.S.A.

#346 Post by sunburnt »

That`s it... You`re the bomb GatorDog! :idea:

I was thinking of using the : and start a do-nothing command to kill the LF.

User avatar
sunburnt
Posts: 5090
Joined: Wed 08 Jun 2005, 23:11
Location: Arizona, U.S.A.

#347 Post by sunburnt »

Hey guys, I got a working exec. with the File and Message dialogs, and help.
The file/folder dialog is all 4 types and auto sets the winTitle for each type.
The message dialog needs all options: Type, Buttons, Width, Height, Message.
It returns both the end of the GTK response variable name, and it`s negative number.

I think add a font dialog ( maybe like my Visual Basic one ), and color?
There`s a few other dialogs, but they`re not nearly as important as these 4.

Any suggestions are welcome, it`s just the first draft... :?:

# I`d like to give credit to GatorDog, vovchik, and pjot if they want it...


TEST: "hug.bac" makes a exec. file 76 KB larger than "hug_imports.bac" does.
Not much, but my stdDlgs exec. compiles to only 56 KB with "hug_imports.bac".

More damn Qs...
# Can HUG use common icons ( not Stock ) for most dlgs.? PROPERTY ?
# What`s the deal with: INTL$ ? It auto. builds foreign language files?

I`ve noticed the Bacon and HUG docs. are misleading and even wrong.
Maybe I understand it differently, but I`m sure they could be better written.

# stdDlgs.bac is posted below.
Attachments
stdDlgs.bac.gz
For Help, after compiling, in rxvt type: stdDlgs
(1.25 KiB) Downloaded 506 times
Last edited by sunburnt on Sun 25 Sep 2011, 05:03, edited 4 times in total.

User avatar
GatorDog
Posts: 138
Joined: Tue 12 Sep 2006, 16:43

#348 Post by GatorDog »

sunburnt,
Unless I did something wrong (possible), stdDlgs.bac wan't in package.
The stdDlgs binary was, but got a seg fault when I tried to run it.

rod

User avatar
sunburnt
Posts: 5090
Joined: Wed 08 Jun 2005, 23:11
Location: Arizona, U.S.A.

#349 Post by sunburnt »

Sorry about that, rushing to get to something else.

Need to finish up my Deb. downloader and package builder app.

# Amazing, now the File Folder dialog isn`t returning anything! I`ll fix it...

User avatar
sunburnt
Posts: 5090
Joined: Wed 08 Jun 2005, 23:11
Location: Arizona, U.S.A.

#350 Post by sunburnt »

Fixed... Useless code messing it up.

# Another Q: (NUMBER dialog_, int button_)
Why is dialog_ a NUMBER, and button_ an int ?
They`re both widget handles... What`s a NUMBER exactly?

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

#351 Post by vovchik »

Dear sunburnt,

NUMBER is a long int (c type) and int is a c type plain int.... Hope that helps.

Here is an explanation:

http://www.lix.polytechnique.fr/~libert ... types.html

With kind regards,
vovchik

User avatar
sunburnt
Posts: 5090
Joined: Wed 08 Jun 2005, 23:11
Location: Arizona, U.S.A.

#352 Post by sunburnt »

Many thanks vovchik; I kinda figured it might be a longer integer type.
But I was also thinking it might be a special variable type for passing handles.

### A handle is only an integer, correct? ... So the NUMBER is over-kill?


My girl friend tells me that vovchik is a Russian name or expression.
And what town in the Ukraine do you live in?
Just curiosity questions, I`m always interested in where folks are from.
Last edited by sunburnt on Sun 25 Sep 2011, 05:48, edited 1 time in total.

User avatar
sunburnt
Posts: 5090
Joined: Wed 08 Jun 2005, 23:11
Location: Arizona, U.S.A.

#353 Post by sunburnt »

Got up today and it started doing GatorDog`s Segmentation fault error.
Turned out to be the ARGUMENT parsing loop.
It really doesn`t like it if the array isn`t filled all the way...

Anyway... It`s working normally again. Sure hope it stays that way.

# I`ve re-posted the re-fixed stdDlgs above.

# I`ll post my Qs again further down. - T.
Last edited by sunburnt on Sun 25 Sep 2011, 05:52, edited 1 time in total.

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

#354 Post by big_bass »

updated so you can compile most apps from inside the geany GUI
updated Nov-5-2011 for HUG highlighting and upx compression
this is a "hack" going for geany syntax highlighting with BaCon!

geany fix with rxvt_hold
http://www.puppy2.org/slaxer/geany_bacon-2-1_SLXR.tgz

upx compression
http://www.puppy2.org/slaxer/upx-3.07-i ... 1_SLXR.tgz

note in geany I had to recycle the build button
so after you compile the app you click on build
which build now uses upx to compress your already compiled bin


then open geany with any *.bac and select
Document -->Set Filetype-->Programming Languages-->FreeBasic source file


just install the package
and upx
and you get the BaCon commands highlighted !

I cant use gtksourceview with my gtk version so this is how to get
another GUI going


*since FreeBasic was compiled in the GUI as an option that was used
later when all the commands are added and tested Bacon would be used and compiled into geany the right way

if we keep at we could get an official bacon filetype someday it can be done



----------------------------------------------------------------------------
as a side note

*you can also call the rxvt_hold script for other apps too
like this

Code: Select all

 rxvt_hold ls -1   

you could change the "ls -1" for any command you want to run
it works for keeping rxvt or urxvt open after the command is executed
Attachments
geany-compile-bacon.png
(66.05 KiB) Downloaded 1234 times
Last edited by big_bass on Sun 06 Nov 2011, 20:09, edited 21 times in total.

User avatar
sunburnt
Posts: 5090
Joined: Wed 08 Jun 2005, 23:11
Location: Arizona, U.S.A.

#355 Post by sunburnt »

big_bass; I had to set the Programming Language to: FreeBasic

Click: Document > Set Filetype > Programming Languages > FreeBasic source file

I was surprised I didn`t have to add ".bac;" to the file: filetype_extensions.conf

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

#356 Post by big_bass »

Hey sunburnt
thanks for confirming that
I had that in my first post viewtopic.php?t=48901&sort=author&start=73
but thought it wasnt needed with the new changes I made

I'll update the above post
I was surprised I didn`t have to add ".bac;" to the file: filetype_extensions.conf
thats for when you click on any source program with the *.bac
it opens automatically with geany

*its nice to know that parts of geany are scriptable without having to
hack it and recompile it to test if it works or not


thanks
Joe

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

#357 Post by vovchik »

Dear Joe,

Although bacongui works on my system, I prefer your method with geany and the modded filetypes.freebasic. I guess I am just used to geany, and the syntax highlighting works perfectly.

Thanks.

With kind regards,
vovchik

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

#358 Post by big_bass »

Hey vovchik

thanks for the comments
I updated the post above to fix it so it now compiles
files that have INCLUDES :D

I also added a little terminal so the user can see the
progress while it compiles in geany

there is a script called rxvt_hold
that goes in /usr/sbin the ( app depends on it)

*you can also call that script for other apps too
as a side note like this

Code: Select all

 rxvt_hold ls -1   
you could change the "ls -1" for any command you want to run
it works for keeping rxvt or urxvt open after the command is executed

Joe

User avatar
sunburnt
Posts: 5090
Joined: Wed 08 Jun 2005, 23:11
Location: Arizona, U.S.A.

#359 Post by sunburnt »

big_bass; Now you need to add HUG highlighting and it`ll be complete!

I still think API libraries should be made of all this stuff, there`s lots of it !
I wrote shell libraries for dealing with files, file systems, lists, gtkDialog, etc.

But written in Bacon and compiled they can become far more useful.
Especially to Bacon as it`s so limited by the standard Basic language.

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

#360 Post by big_bass »

sunburnt
Now you need to add HUG high lighting and it`ll be complete
great idea
thanks
its now added in the above post

*Hey guys if you find a missing command let me know
It will be added


Joe

Post Reply