BaCon Bits

For discussions about programming, programming questions/advice, and projects that don't really have anything to do with Puppy.
Message
Author
User avatar
sunburnt
Posts: 5090
Joined: Wed 08 Jun 2005, 23:11
Location: Arizona, U.S.A.

#61 Post by sunburnt »

Yeah... I`ve used the CONCAT$ before, I just didn`t think of using it here.
And boy is that a pain in the arse! I`m remembering how crude Basic is...

I`ve said here many times, it takes 10 lines of Visual Basic for 1 of Bash.
Bash script`s intimidating as you start learning it, but it`s very powerful.!
But BaCon will compile! Too bad there isn`t a real converter for script to C.

P.S. Hey GatorDog, should I post a pic. of my app. here for all to see?

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

#62 Post by GatorDog »

P.S. Hey GatorDog, should I post a pic. of my app. here for all to see?
Sure. Go ahead and throw in the source code too. We all can learn :)

rod

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

#63 Post by sunburnt »

A BaCon-HUG GUI front end for pDebThing, a Debian package downloader.
I wrote another GUI in gtkDialog, they both use the same Bash script backend.
I could have written more of the backend code in BaCon Basic,
. but it just calls shell commands anyway, so I didn`t write much of it in BaCon.

This is a good example of the type of GUI`s I talk about, with no backend code.
This way the backend and frontend ( GUI ) code is separate and replaceable.
Here there is one set of backend code and two sets of frontend code I wrote.
More GUIs could be written in Perl or Python, and the backend C or whatever.

Both GUIs look the same as they both use GTK widgets.

# The first pic. is the main tab panel of the Debian downloader.
The left ListBox shows the groups of packages.
Click a group and it`s list of packages shows in the right ListBox.
The right ListBox shows the packages in the selected group.
Click a package and it`s description info. shows on the second tab panel.

# The second pic. is the second tab panel that shows the description info.
Attachments
000_DebDnld_BaCon.png
Upper one is package selection , lower one is package info.
(63.47 KiB) Downloaded 1200 times
Last edited by sunburnt on Tue 13 Sep 2011, 21:54, edited 3 times in total.

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

#64 Post by GatorDog »

sunburnt

Looking neat and clean :D

rod

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

#65 Post by sunburnt »

GatorDog; Trying to get the GUI to show all the info.
Here`s one part for the first listbox, the second`s the same.
The var. TMP$ is set above and the files exist. What`s wrong?

Code: Select all

TMP$ = "/tmp/deb-dnld"

	OPEN CONCAT$(TMP$,"/main.list") FOR READING AS inFile
	WHILE NOT(ENDFILE(inFile)) DO
		READLN TXT$ FROM inFile
		IF CHOP$(TXT$) = "" THEN CONTINUE
		TEXT(lstGRPS_,TXT$)
	WEND
	CLOSE FILE inFile
And this is the info. box, is this code right for filling an edit box?

Code: Select all

	OPEN CONCAT$(TMP$,"/pkg.info") FOR READING AS inFile
	WHILE NOT(ENDFILE(inFile)) DO
		READLN TXT$ FROM inFile
		INFO$ = CONCAT$(INFO$,TXT$,NL$)
	WEND
	CLOSE FILE inFile
	TEXT(edINFO_,INFO$)
Last edited by sunburnt on Tue 13 Sep 2011, 05:25, edited 1 time in total.

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

#66 Post by GatorDog »

Terry,
I think your file I/O code itself is OK.

I'm guessing that for the top code snippet that you're getting a blank List?
I'll bet you a Little Debbies Chocolate Snack Cookie that "main.list" has
a final newline (NL$) character. NL$ is the default seperator when reading
in a text file. So, the final NL$ is seperating the text before it from the "nothing" (ie. null)
after it. So the final thing the TEXT(lstGRPS_,TXT$) is a null character.
Guess what that does. It clears the list box.

If you want to skip blank lines, you can put this in the WHILE loop
IF CHOP$(TXT$) = "" THEN CONTINUE
That will just skip processing that line and go read in the next line.
If you want the blank line, then substitute in a space for that list line.
IF CHOP$(TXT$) = "" THEN TMP$ = " "

An edit widget is cleared the same way, TEXT(Edit_widget_, "").
But your code there is adding a NL$ to each line so I don't think that's a problem there.

rod

ed. Snack Cookie vs. Snake Cookie :oops:

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

#67 Post by sunburnt »

Hey GatorDog; Look above at the corrected first listBox, I`m sure that`s right...
The listboxes are still empty...

I see that the CHOP line is removing blank lines.
And you`re right... All 3 lists have a trailing blank line or more.
All 3 files are there for this testing, and are there sometimes during operation.

I assume the info. editBox handles null lines, other wise it couldn`t show them.

### Q: Would this work also: IF TXT$ <> "" THEN TEXT(lstGRPS_,TXT$)
It gives a compile error: Cause: expected expression before token ","
Last edited by sunburnt on Tue 13 Sep 2011, 08:32, edited 1 time in total.

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

#68 Post by GatorDog »

sunburnt,
I don't spot anything yet that looks out of place, but I may be looking through
the wrong section of my tri-focals :lol:

If you'd like to, either upload your code and the sample files your working with
or PM them, and I'll take a look.

rod

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

#69 Post by sunburnt »

Hey GatorDog; Well your code was needed as always, of course.
But in the final code error it was just my stupid code holding it up.

Posted the pics. of the working GUI displaying Debian packages and info.
I had to widen the GUI to get rid of the hoz. scroll bar, I`ve seen this before.
What`s weird is that the text isn`t anywhere near the edge of the listBox.

# Same Q: This should work also: IF TXT$ <> "" THEN TEXT(lstGRPS_,TXT$)
It gives a compile error: Cause: expected expression before token ","

When I get help with mtPaint, I`ll come back and clean up the pics.
The code`s very long, but when it`s fully functional I`ll post the BaCon file.

# Note: I think I`ll try editBoxes instead of the 2 listBoxes.
..... The listBoxes waste space between the lines, not very efficient.

Thanks again buddy... Terry

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

#70 Post by GatorDog »

# Same Q: This should work also: IF TXT$ <> "" THEN TEXT(lstGRPS_,TXT$)
It gives a compile error: Cause: expected expression before token ","
In this case "less than nothing" probably doesn't make sense; so just the "greater than" should accomplish the task.
When I get help with mtPaint, I`ll come back and clean up the pics.
If you're just wanting to get two views of a GUI into one picture..
- Run two instances of the GUI, place them side-by-side, overlap etc.
- Pup menu/Graphic/mtPaint snapshot.
- Select area and crop.
- Optionally Scale
- Save

Example below

Note- the forum makes some limits on image dimensions. Beyond those
limits the image isn't displayed, but becomes a download. The dimensions
are probably documented somewhere, but there's always the trial & error method :roll:
# Note: I think I`ll try editBoxes instead of the 2 listBoxes.
... The listBoxes waste space between the lines, not very efficient.
Well, the tradeoff here is that Bacon cannot grab a single (1) line from an EDIT widget.
So you probably need the listbox for the select window, but the info window could be an edit widget.

rod
Attachments
snap_blt.png
ex.. combine pics using snapshot
(62.61 KiB) Downloaded 960 times

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

#71 Post by sunburnt »

Gui starts and quits, didn`t change anything big, added a Combo.
I stared at it for several hours, so post it and sleep.

# A compiled Bacon gui`s fairly portable I think... Should work on most Linuxes?

So if you get a few minutes to stare at it GatorDog...
Attachments
deb-dnld_post.bac.gz
Can`t seem to get the FileDialog to work either.
(1.55 KiB) Downloaded 362 times

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

#72 Post by GatorDog »

sunburnt,

1. Try setting a Var$ to the CONCAT$( path/filename.... and then use
OPEN VAR$ .
I think that is causing the crash.

2. You have two CLOSE FILE's in a row, but I think main problem is #1.

3. I put in a filedialog to getcha' a filename. I used a button to call it but
you'll probably want to call it from the program.

-----
I put all of the "OPEN FILE AS..." inside of a SUB since I don't have those
files on my system. It's just a cheap trick way of commenting them out 8)
A compiled Bacon gui`s fairly portable I think... Should work on most Linuxes?
That should be correct. Though I've received little to no feedback on how the GUI's I've made "look" for other people. :cry:

rod
Attachments
deb-dnld_with_filedialog.tar.gz
(1.97 KiB) Downloaded 334 times

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

#73 Post by big_bass »

A compiled Bacon gui`s fairly portable I think... Should work on most Linuxes?
only thing to beware of is the glibc version

the GUI just needs to match the glibc of the distro
this is not a problem you just have to recompile for the target machine

I discovered this by trying a recently compiled
app that was compiled using a more recent glibc

a quick recompile of the app against the older glibc did the trick


@GatorDog That should be correct. Though I've received little to no feedback on how the GUI's I've made "look" for other people

I have plans to test a lot of the code you posted
so much code so little time keep posting when I have more free
time I will go though the examples maybe just knowing other
people are interested will help

Joe

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

#74 Post by GatorDog »

A compiled Bacon gui`s fairly portable I think... Should work on most Linuxes?
If the program is compiled with INCLUDE "hug.bac", my understanding is that
everything is compiled in that it needs to run. I've tested a couple of bacon
programs on another system and that seemed to be the case; however it
may not be that way across the board. If someone knows, please chime in.

Whereas compiling with INCLUDE "hug_imports.bac", it is dependent on a
shared object file ( .so), in this case hug.so .

The tradeoff being that the former is more portable and the latter gives a
significantly smaller executable file.

To be safe, when posting I've started attaching both the source program and
a standalone compiled version of it. That way anyone should be able to
check it out even if they're not running the Puppy devx package.

===================================
Tnx Joe, constructive feedback welcome :D
rod

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

#75 Post by big_bass »

Hey GatorDog

Im trying to get your first example compile to test it

this tell me I have to recompile no big deal

Code: Select all

# ./pFontSelect
./pFontSelect: /lib/libc.so.6: version `GLIBC_2.7' not found (required by ./pFontSelect)
# 

this tell me in the sources I am missing files to recompile with no problem I'll go to the bacon web site and look for that file

Code: Select all

# bacon pFontSelect.bac
Converting 'pFontSelect.bac'... 34   
ERROR: missing file '/usr/share/BaCon/hug_imports.bac' for INCLUDE at line 34 in file 'pFontSelect.bac'!
#


fix it
download http://www.basic-converter.org/hug_imports.bac
mkdir -p /usr/share/BaCon
copy the hug_imports.bac into the folder


compile it

Code: Select all

# bacon pFontSelect.bac
Converting 'pFontSelect.bac'... done.   .bac'... 94   
Compiling 'pFontSelect.bac'... done.
Program 'pFontSelect' ready.
# 
try to run the compiled app

Code: Select all

./pFontSelect            
Could not open library ./hug.so: cannot open shared object file: No such file or directory
# 

ok looks like I have to compile a *.so now Im stuck whats the code for that
I'll read more about this

Code: Select all

# bacon -f hug.bac       
Converting 'hug.bac'... done.   
Compiling 'hug.bac'... done.
Program 'hug.so' ready.
# 

ok lets try now

Code: Select all

# bacon pFontSelect.bac
Converting 'pFontSelect.bac'... done.   .bac'... 94   
Compiling 'pFontSelect.bac'... done.
Program 'pFontSelect' ready.
# ./pFontSelect 

Code: Select all

(<unknown>:27668): Gtk-WARNING **: Failed to set text from markup due to error parsing markup: 'medium' is not a valid value for the 'weight' attribute on <span> tag, line 1; valid values are for example 'light', 'ultrabold' or a number

(<unknown>:27668): Gtk-WARNING **: Failed to set text from markup due to error parsing markup: 'medium' is not a valid value for the 'weight' attribute on <span> tag, line 1; valid values are for example 'light', 'ultrabold' or a number

ok the GUI came up some markup I need to sort out 

looking good getting close 



P.S we posted at the same time
Joe
Attachments
pfont.png
(36.78 KiB) Downloaded 714 times

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

#76 Post by sunburnt »

GatorDog; Thanks for the code staring, I appreciate it greatly.

If there`s something of your`s in particular you want looked at, say so...

# Cross-Linux compatability...
So a Bacon file with: INCLUDE "hug_imports.bac" needs the hug.so library file.

# But if the target Linux distro. has a hug.so compiled and installed on it,
...... then the the smaller Bacon binary file will work on it?

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

#77 Post by GatorDog »

sunburnt
# But if the target Linux distro. has a hug.so compiled and installed on it,
...... then the the smaller Bacon binary file will work on it?
That's how I understand it.
This got me to thinking. The hug_imports.bac file has a (CONST) variable
that sets the path to hug.so. I don't know if Puppy(s) are consistant about the
location of Bacon files or not. So maybe that would leave the location of
Bacon support files on other systems something that would need to be
considered.
Food for thought. If in doubt, compile a standalone version.
--------------
Joe,
I updated the first post with the latest source and standalone for pFontselect.
I'm not seeing that last set of errors/ gtk-warnings that you posted.
I probably used Bacon 1.0.23 originally on pFontselect, but I've been using
BaconGUI 1.0.24 beta hug.bac .62 beta. A few posts back there should be
a tar package with those versions if you'd like to try them.

rod

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

#78 Post by sunburnt »

# Wouldn`t it be much better if hug.so were in /lib or /usr/lib ? ( in the Lib. path )
This seems all too obvious, but maybe there`s a method to the madness...

# GatorDog; ( I`ll continue calling you that as there`s been complaints in the past
when using real names, as most folks only know our forum handles. )

# I`m going to need "spots" of help with this, PMs might be better than
messing up your BaCon thread here... Unless it may be helpful to others?

# Error at "empty line"...
Line 2: lstGRPS_
Cause: 'lstGRPS_' undeclared here (not in a function)

Code: Select all

DECLARE lstGRPS_, lstPKGS_, edINFO_, cboMIR_ AS int

LOCAL dat[8]
DATA "/main.list", lstGRPS_, "/pkgs.list", lstPKGS_, "/pkg.info", edINFO_, "/mirrors.list", cboMIR_

FOR i =  0 TO 7 STEP 2
	READ dat[i]
	READ dat[i+1]
PRINT CONCAT$(TMP$,dat[i])
PRINT CONCAT$(TMP$,dat[i+1])
NEXT
### Got the error, so I added the DECLARE line and same error!
I think you can see what I`m doing here, files to read to fill the widgets.

# Also, is there a way to read a file in one command ( not looping )?
The editBox is filled in one command, so read it`s file in one command also?
V.B. would do this and I used it almost exclusively to reduce H.D. wear.

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

#79 Post by big_bass »

Hey rod @GatorDog


great news !

now tested on an older glibc re-compiled and gtk compatible
on another gtk version

there is a gtk fix you need to add I looked over your code with the error report

Code: Select all

(<unknown>:27668): Gtk-WARNING **: Failed to set text from markup due to error parsing markup: 'medium' is not a valid value for the 'weight' attribute on <span> tag, line 1; valid values are for example 'light', 'ultrabold' or a number
so I replaced the medium with light and bingo !

Code: Select all

tmp$ = "<span weight=\"light\" size=\"33000\" color=\"#000000\">p</span>"
	tmp$ = CONCAT$(tmp$, "<span weight=\"light\" size=\"33000\" color=\"#202020\">F</span>")
	tmp$ = CONCAT$(tmp$, "<span weight=\"light\" size=\"33000\" color=\"#303040\">o</span>")
	tmp$ = CONCAT$(tmp$, "<span weight=\"light\" size=\"33000\" color=\"#373760\">n</span>")
	tmp$ = CONCAT$(tmp$, "<span weight=\"light\" size=\"33000\" color=\"#474780\">t</span>")
	tmp$ = CONCAT$(tmp$, "<span weight=\"light\" size=\"33000\" color=\"#505090\">S</span>")
	tmp$ = CONCAT$(tmp$, "<span weight=\"light\" size=\"33000\" color=\"#555595\">e</span>")
	tmp$ = CONCAT$(tmp$, "<span weight=\"light\" size=\"33000\" color=\"#5757A5\">l</span>")
	tmp$ = CONCAT$(tmp$, "<span weight=\"light\" size=\"33000\" color=\"#5757B5\">e</span>")
	tmp$ = CONCAT$(tmp$, "<span weight=\"light\" size=\"33000\" color=\"#6060C0\">c</span>")
	tmp$ = CONCAT$(tmp$, "<span weight=\"light\" size=\"33000\" color=\"#7070E5\">t</span>")
now it is more portable for gtk :D

as you can see no errors with gtk the terminal is clean

one small suggestion to your great app
could you default to the quick brown fox to be in the display by default

a big thanks
Joe

I added the sources and edits compiled for puppy 4.12 compatible
I bumped the minor version number to avoid confusion

this is fun

Joe
Attachments
gtk-fix-1.0.4.png
(88.91 KiB) Downloaded 794 times
Last edited by big_bass on Thu 29 Sep 2011, 06:07, edited 2 times in total.

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

#80 Post by GatorDog »

sunburnt wrote:# Wouldn`t it be much better if hug.so were in /lib or /usr/lib ? ( in the Lib. path )
I started using Bacon when I switched to PUP 525. There were some issues
with the Bacon files in the 525 devx. By trial, error and some help I upgraded Bacon
packages. It's possible that I, myself may have moved my hug.so to the /usr/share/BaCon
directory. I just looked, and there is an old hug.so in /usr/lib. I probably left it alone while
trying to get things to work; then never went back and replaced the old version in /usr/lib.
I'll probably do that, now that I have a little more knowledge. I'll need to edit my hug_imports.bac
to point there. It would still be nice to know if the default location for hug_imports.bac is the same
on Puppy & non-Puppy systems. Are you running Bacon on ubuntu?
# GatorDog; ( I`ll continue calling you that as there`s been complaints in the past
when using real names, as most folks only know our forum handles. )
I'm good either way :)
# I`m going to need "spots" of help with this, PMs might be better than
messing up your BaCon thread here... Unless it may be helpful to others?
Good point. Maybe some things might fit better in vovchik's original thread?
# Error at "empty line"...
Line 2: lstGRPS_
Cause: 'lstGRPS_' undeclared here (not in a function)

Code: Select all

DECLARE lstGRPS_, lstPKGS_, edINFO_, cboMIR_ AS int

LOCAL dat[8]
DATA "/main.list", lstGRPS_, "/pkgs.list", lstPKGS_, "/pkg.info", edINFO_, "/mirrors.list", cboMIR_

FOR i =  0 TO 7 STEP 2
	READ dat[i]
	READ dat[i+1]
PRINT CONCAT$(TMP$,dat[i])
PRINT CONCAT$(TMP$,dat[i+1])
NEXT
### Got the error, so I added the DECLARE line and same error!
I think you can see what I`m doing here, files to read to fill the widgets.
In a nutshell - DATA stores "values" not variables. (The widget names are variables.)
READ <x[$]>

Type: statement

Reads a value from a DATA block into variable <x>.
So, DATA "some string data" is cool. 8)
Also DATA 123 8)
BUT, DATA program_variable_name , Not so much :cry:
(voice of experience here)

Another problem with your code- the LOCAL dat[8] I believe defaults to a numeric variable.
You're trying to make READ and CONCAT$ use it as a string variable. Numbers can
easily be converted to string with STR$(... . However that doesn't help here.

I think this will get you what you're after-

Code: Select all

' ------------------
SUB WIDGET_STUFFER(int Widget_handle_, STRING Basename$)
' ------------------
	LOCAL Dirname$, File$, Txt$ TYPE STRING
	Dirname$ = "/tmp/"
	File$ = CONCAT$(Dirname$, Basename$)

	OPEN File$ FOR READING AS Infile
	WHILE NOT(ENDFILE(Infile))
		READLN Txt$ FROM Infile
		IF Txt$ = "" THEN Txt$ = CONCAT$(" ", NL$)
		TEXT(Widget_handle_, Txt$)
	WEND
	CLOSE FILE Infile
END SUB

' ==============================================

WIDGET_STUFFER(lstGRPS_, "main.list")
WIDGET_STUFFER(lstPKGS_, "pkgs.list")
WIDGET_STUFFER( cboMIR_, "main.list")
WIDGET_STUFFER( edINFO_, "mirrors.list")
Haven't tried it, but at least it looks pretty, don't you think? :P
# Also, is there a way to read a file in one command ( not looping )?
Not that I'm aware of.

rod er... I mean Gatordog

Post Reply