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
e_mattis
Posts: 114
Joined: Fri 21 Dec 2012, 02:24
Location: Williamston, SC
Contact:

#496 Post by e_mattis »

Thanks Mobeus,

Yea, I finally figured that part out :oops: my sloppy coding :roll: :lol:

I think I have it working now, however, I need the program to wait, halt, or stop until the MSGDIALOG decision is made (ie. wait until either the 'yes' or the 'no' button are pushed; or the window is closed indicating not to delete the record)

At present, it continues execution while the MSGDIALOG is present, continuing on to the 'END SUB'. Here is what I have atm (kmv is now being returned :D ):

Code: Select all

  killmsg$=CONCAT$(Are yo usure you want to delete ",kilme$," ?")
  kilme_dlg=MSGDIALOG(killmsg$,300,110,1,4)
  SHOW(kilme_dlg)
  CALLBACK(kilme_dlg,killme_btn)
  IF kmv = 1 THEN
      GOTO findrec
  END IF
  GOTO nokill
LABEL findrec
  PRINT "at finding record"
LABEL nokill
PRINT "ending"
END SUB
'ending' is being printed while the MSGDIALOG is being shown. I click the 'yes' button,GUI hides, then nothing happens. I re-click the button on the gui to go into the delete SUB and then the 'at finding record' prints followed by the 'ending' message while the new MSGDIALOG is being shown. :?

I'm familiar with the 'WAIT' command, but how and where do you set it up to pause the program until the MSGDIALOG buttons are pressed? :? :?:

I am thinking of trying this:

Code: Select all

  dmv = 3
  REPEAT
      SHOW(kilme_dlg)
      CALLBACK(kilme_dlg,killme_btn)
       dmv=WAIT(killme_btn, 30)
  UNTIL dmv < 3
OR

Code: Select all

  dmv = 3
  WHILE dmv >= 3
      SHOW(kilme_dlg)
      CALLBACK(kilme_dlg,killme_btn)
  WEND
It is late here, so I will try them and post what happens in the next few minutes or so. Then Ima going to bed!

Thanks!

E

.

[UPDATE]

Both failed :cry:

Using the WHILE/WEND method caused the MSGDIALOG window to pop up with nothing inside it and locked the system up. Strike one :(

Using the REPEAT/UNTIL with 'dmv=WAIT(kilme_dlg,30)' would not compile due to a segmentation fault. Strike Two :evil:

Using REPEAT/UNTIL with 'dmv=WAIT(killme_btn,30)' would not compile due to an integer from pointer error. Strike three- I'm out! :twisted:

Well, off to bed...I'll see what happens with it tomorrow. Meanwhile, any solutions , feel free to post them for me :D

Thanks all!


E

.

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

pausing to get MSGDIALOG input (solved?)

#497 Post by e_mattis »

Hey all,

Well, after a couple of days working at it, I finally got the result I was looking for. :D Here is how I got the program to 'pause' until the MSGDIALOG button was pressed:

Code: Select all

  killmsg$=CONCAT$("Are yo sure you want to delete record ",kilme$," ?")
  kill_dlg=MSGDIALOG(killmsg$,300,100,1,4)
  SHOW(kill_dlg)
  CALLBACK(kill_dlg,killit)
END SUB


SUB killit (NUMBER kill_dlg, int button)
  HIDE(kill_dlg)
  IF button = GTK_RESPONSE_YES THEN
      CALL kilrec
  END IF
END SUB


SUB kilrec
  PRINT "killing record"
END SUB
I want to thank all those who helped me understand how this works. All the responses and inputs were very helpful!

Thanks!

E

.

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

manufacturer db completed

#498 Post by e_mattis »

Hey guys,

Finally completed my first BaCon prog! :D Wo0h0o!

@L18L

Thought you might want to give it a 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. Hope you like it! Fair warning, the code is going to be repdative and at times jumpy - but like I said, my first in Bacon :)

Thanks!

E

.
Attachments
manuf_prog_bacon.tar.gz
small flat-file manufacturer contact list/db
(147.36 KiB) Downloaded 570 times

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

manufacturer db completed

#499 Post by e_mattis »

Hey guys,

Finally completed my first BaCon prog! :D Wo0h0o!

@L18L

Thought you might want to give it a 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. Hope you like it! Fair warning, the code is going to be repeatative and at times jumpy - but like I said, my first in Bacon :)

Thanks!

E

.
Attachments
manuf_prog_bacon.tar.gz
small flat-file manufacturers contact list/ database
(147.36 KiB) Downloaded 580 times

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

#500 Post by vovchik »

Dear all,

I have been doing a bit of label and svg coding recently and most of the examples are at http://basic-converter.proboards.com/in ... 314&page=3.

I was impressed with SFR's recent DYCP script and did a BaCon port/mod. Here is the source and a Lucid 32-bit binary.

With kind regards,
vovchik
Attachments
bmw-demo.tar.gz
(22.71 KiB) Downloaded 534 times
bmw1.png
(16.07 KiB) Downloaded 643 times

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.

Post Reply