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
L18L
Posts: 3479
Joined: Sat 19 Jun 2010, 18:56
Location: www.eussenheim.de/

Re: manufacturer db completed

#501 Post by L18L »

e_mattis wrote:...look over with the international finished on it (I hope :roll: ). So here's the whole thing, the prog, the code, and the '.pot' file....
Good news first:
Internationalization is working
(translation of NY, NC, ... does not make sense )

Bad news:
prog and code do not match:

Code: Select all

# bacon manuf.bac
Converting 'manuf.bac'... done.
Compiling 'manuf.bac'... Compiler emits messages!

Problem:
	 file 'manuf.bac' line 9: GLOBAL valu$,manunam$,contpsn$,street$,city$,state$,zip$ TYPE STR
Cause:
	 expected '=', ',', ';', 'asm' or '__attribute__' before 'valu$'

# 
REM INCLUDE "/usr/share/BaCon/hug.bac"
INCLUDE "/usr/share/BaCon/hug_imports.bac"
is converting faster

User avatar
e_mattis
Posts: 114
Joined: Fri 21 Dec 2012, 02:24
Location: Williamston, SC
Contact:

#502 Post by e_mattis »

Hey L18L

Thanks for the review.
Bad news:
prog and code do not match:
hmm, not sure why 'valu$' is there. I don't remember using it anywhere. May be a typo that can be removed? Compiles and runs on my system either way.

Thanks!

E

.

User avatar
L18L
Posts: 3479
Joined: Sat 19 Jun 2010, 18:56
Location: www.eussenheim.de/

manuf

#503 Post by L18L »

e_mattis wrote:... Compiles and runs on my system either way....
So your system is not racy 5.5.1 :lol:

If have changed to slacko and there it compiles and runs. :D

Translations tend to need more length than english.
Idea for the buttons:
frame named Entry
and default gtk stock buttons for add remove edit save (and quit)
Attachments
manuf.png
(27.65 KiB) Downloaded 709 times

User avatar
Mobeus
Posts: 94
Joined: Thu 26 Aug 2010, 15:49

#504 Post by Mobeus »

Hi E,

I'm a little surprised that it builds on slacko. Using the latest bacon beta and hug.bac here I get the same compile error as L18L, and it should.
There is no TYPE STR in bacon, it's TYPE STRING. :)
After changing those it builds fine.

Regards,
Mobeus
/root for the home team

User avatar
e_mattis
Posts: 114
Joined: Fri 21 Dec 2012, 02:24
Location: Williamston, SC
Contact:

#505 Post by e_mattis »

Hey guys,

no, it's not Racy, it's Precise :)

As you can tell, i'm not accustomed to making "international" programs...didn't think about the wording and the different lengths, my bad :(

I guess i'm telling my age as the saying goes...the 'TYPE STR' comes from a basic long ago :shock: Rather surprised it compiled using just that. Thanks for the heads-up!

I have noticed one 'bug' issue - and i'm sure it's in my coding somehow. When you add multi-records (more than two or three) and then try to remove one, it either crashes or removes the entire database :cry: Am working on that now, but can not seem to remember/figure out how to remove a certain record and re-assign the remaining ones. ( i.e remove record #3 of a 5 record list). Hopefully I will have it figured out soon (thinking of doing it in another 'while,wend' statement), but, meanwhile, any input would be appreciated :D

Thanks again for the inputs !

E

.

User avatar
L18L
Posts: 3479
Joined: Sat 19 Jun 2010, 18:56
Location: www.eussenheim.de/

#506 Post by L18L »

Mobeus wrote:Hi E,

I'm a little surprised that it builds on slacko. Using the latest bacon beta and hug.bac here I get the same compile error as L18L, and it should.
There is no TYPE STR in bacon, it's TYPE STRING. :)
After changing those it builds fine.

Regards,
Mobeus
good catch!
looking in my source I see now:
I had removed TYPE STR because all those variables had a trailing $[/b].

Sorry, nobody is perfect :wink:

PaulR
Posts: 249
Joined: Wed 04 May 2005, 18:45
Location: UK

#507 Post by PaulR »

Can anyone suggest a fix for this please? I'm executing a shell command to search for a named file starting from "/".

If I execute the following line in a terminal it works as expected:

find / -name icon.xpm -and -not -path /proc

but if filename$="icon.xpm" and I do the following in a BaCon program, the find command still looks in /proc (and returns no such file/directory errors)

command$ = "find / -name " & filename$ & " -and -not -path /proc"
result$=EXEC$(command$)

I've also tried putting /proc in quotes (both by escaping double quotes and using CHR$) and using "proc" and even "/proc/*" both with and without quotes.

I've looked into -prune as an alternative but I'm struggling to understand it at present!

Cheers

Paul

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

#508 Post by vovchik »

Dear Paul,

This code, which is yours, compiles fine and runs OK, i.e. no errors:

Code: Select all

filename$ = "icon.xpm"
command$ = "find / -name " & filename$ & " -and -not -path /proc"
result$=EXEC$(command$) 
PRINT result$
I don't have any problems with it.

With kind regards,
vovchik

PaulR
Posts: 249
Joined: Wed 04 May 2005, 18:45
Location: UK

#509 Post by PaulR »

vovchik

If I run the code many times with different filenames I start to get errors like this:

find: `/proc/24007': No such file or directory
find: `/proc/24008': No such file or directory
find: `/proc/24009': No such file or directory

Just in case you haven't noticed, the program/problem is explained in these two threads..

http://murga-linux.com/puppy/viewtopic.php?t=85526
http://murga-linux.com/puppy/viewtopic.php?t=85563

Basically I'm extracting menu entries from .jwmrc and writing them out to a file in Fluxbox format. The new file is created properly (including the icon filenames) but these errors are annoying!

Many thanks,

Paul

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

#510 Post by sunburnt »

If I`m not mistaken, isn`t CONCAT$ required to combine literal and variable strings in Bacon?
Like this:

Code: Select all

filename$ = "icon.xpm" 
command$ = CONCAT$("find / -type f -name ", filename$)
result$=EXEC$(command$) 
PRINT result$
# PaulR; If you reduce the "find" to /usr or whatever you`re looking for, it be quicker.

Also, I think you`ll find that shell scripts are much better at doing strings.
And you end up needed the shell to interface with the O.S. and file systems anyway.
.
Last edited by sunburnt on Wed 10 Apr 2013, 19:36, edited 1 time in total.

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

#511 Post by vovchik »

Dear Terry,

Since build 1.29 beta and also build 2.0, you can use "&" to concatenate strings. :) That was somebody's request and Peter obliged...

With kind regards,
vovchik

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

#512 Post by sunburnt »

New things all the time...!

It is a bit better and easier to use.

Thanks vovchik.

PaulR
Posts: 249
Joined: Wed 04 May 2005, 18:45
Location: UK

#513 Post by PaulR »

sunburnt wrote: # PaulR; If you reduce the "find" to /usr or whatever you`re looking for, it be quicker.

Also, I think you`ll find that shell scripts are much better at doing strings.
And you end up needed the shell to interface with the O.S. and file systems anyway.
.
Hehe, I realize both of those but the files I'm seeking could be anywhere. As it's probably a program that would only be run once speed isn't a major issue - if it was I'd probably be doing it straight in C (although that would take much longer to code as I'm well out of practice).

At some point I'm going to learn shell scripting but for now I'm still learning Linux and BaCon!

Thinking about it, I suspect there's another way to solve this problem anyway...

Cheers

Paul

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

#514 Post by sunburnt »

PaulR; Shell scripting is Linux for the most part.

I coded Visual Basic for years ( very much like Bacon ).
When I tried scripting it was daunting at first ( pipe chaining commands ).

But then I realized an entire paragraph of code is needed in Basic to do what 1 line does in Bash.!
And again, you are using shell code in Bacon`s EXEC$ and SYSTEM commands.

I`m writing a pre-processor for Bacon, and it`s a pain in Bacon.
All it does is rewrite the Bacon code so it`s ready to run "bacon" on.
So a shell script will do this very well. I`d prefer it be Bacon code, but...

PaulR
Posts: 249
Joined: Wed 04 May 2005, 18:45
Location: UK

#515 Post by PaulR »

I know, I'm happy enough with the command line I just can't deal with all the arcane stuff and new syntax for scripting atm (having recently learned a good chunk of php and Java/Processing for no particular reason!).

The idea I had earlier is a non-starter so I've checked all the default icon locations in .jwmrc and they are all under /usr so I'll limit the search as you suggested - it's faster and eliminates the searching or /proc at a stroke.

The problem I have with icons not displaying seems to be Fluxbox related - all the problem ones are .png - obviously Fluxbox only likes .xpm. Maybe I can convert these on the fly somehow....

Thanks again

Paul

EDIT: Seems that the png problem is because this version of fluxbox is compiled without suitable support for png's.

seaside
Posts: 934
Joined: Thu 12 Apr 2007, 00:19

#516 Post by seaside »

PaulR wrote:I Maybe I can convert these on the fly somehow....

.
Paul,

Here you go-

Code: Select all

 pngtopnm FILENAME.png >FILENAME.pnm
ppmtoxpm FILENAME.pnm >FILENAME.xpm 
Two steps - first convert .png file to .pnm file then .pnm to .xpm.
I think those commands are standard in Puppies.

Cheers,
s

EDIT: actually I think you could just pipe it straight through-

Code: Select all

 pngtopnm FILENAME.png | ppmtoxpm  >FILENAME.xpm

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

#517 Post by sunburnt »

Or... Use vovchik`s picscale.

It converts most pic. types to any of the other types.

PaulR
Posts: 249
Joined: Wed 04 May 2005, 18:45
Location: UK

#518 Post by PaulR »

I'm going to try compiling Fluxbox with png support - first problem, it requires imlib2 which doesn't appear to be on my system so far as I can see. So, a few questions... :D

- where should I obtain this library? It doesn't appear in package manager...
EDIT: I found the library and the source but neither archive contains the imlib2-config file that ./configure is calling for as far as I can see. Actually I'm not sure if I need the pre-compiled library or the source package :?


Everything else when running ./configure looks ok so once the imglib2 issue is fixed, if I go ahead and make/install will itoverwrite my existing Fluxbox or is it possible to install another version side by side?

Please excuse my Linux noobiness!

Cheers

Paul

User avatar
miriam
Posts: 373
Joined: Wed 06 Dec 2006, 23:46
Location: Queensland, Australia
Contact:

#519 Post by miriam »

Hi PaulR, I just stumbled on this page. You've probably solved your imlib2 problem by now, but just in case you haven't, the Linux From Scratch project has a page that links to the downloadable and gives more info on dependencies and so on.
http://www.linuxfromscratch.org/blfs/vi ... mlib2.html

Just one thing. The page's instructions on compiling don't really need to be so complex for Puppy. Just open a terminal in the folder of decompressed imlib2 contents.
./configure
make
make install


And it should be all done.

Cheers.
[color=blue]A life! Cool! Where can I download one of those from?[/color]

PaulR
Posts: 249
Joined: Wed 04 May 2005, 18:45
Location: UK

#520 Post by PaulR »

Cheers Miriam, I'm sorted but no doubt others will find that info very useful :)

Paul

Post Reply