November 1, 2011: BaCon 1.0 build 24 released

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

November 1, 2011: BaCon 1.0 build 24 released

#1 Post by GatorDog »

.
________________________________________________

:D November 1, 2011: BaCon 1.0 build 24 released :D

________________________________________________
.

User avatar
Lobster
Official Crustacean
Posts: 15522
Joined: Wed 04 May 2005, 06:06
Location: Paradox Realm
Contact:

#2 Post by Lobster »

Must be time to pretend I can program in Slacko Puppy 5.3

1. In Slacko add devx SFS - if you can not get from Slickpet
http://ftp.nluug.nl/ftp/pub/os/Linux/di ... puppy-5.3/
2. Reboot computer after adding SFS with menu/system/bootup
3. Check SFS is running - I usually type python at console and ctrl + D to get out
4. Sardine break*
5. Download 'BaCon Bash version (requires BASH 3.2 or higher)'
actually just a text file/script
6. Save the script into bac24 - I will use this to compile
7. More sardines*
8. Save the below code as hi.bac (this is a modified test bacon script)

Code: Select all

' BaCon / HUG  Hello World

INCLUDE "/usr/share/BaCon/hug_imports.bac"
INIT

   Mainwin = WINDOW( "hi from Crusty", 250, 100 )
   My_label = MARK( "Hello Sardines!", 150, 30 )
   ATTACH( Mainwin, My_label, 50, 20 )

   My_btn = BUTTON( "I'm done", 80, 25)
   ATTACH( Mainwin, My_btn, 85, 60 )

   CALLBACK( My_btn, QUIT)

   My_chk = CHECK( "Nada", 50, 25 )
   ATTACH( Mainwin, My_chk, 175, 60 )

DISPLAY


9. Add HUG (you need this see next post for details)

10. Run
./bac24 hi.bac
This runs the new Bacon bash script - compiling the file hi.bac

11. I iz coder . . . 8)

Thanks guys
*sardine breaks are optional
Last edited by Lobster on Fri 04 Nov 2011, 06:36, edited 1 time in total.
Puppy Raspup 8.2Final 8)
Puppy Links Page http://www.smokey01.com/bruceb/puppy.html :D

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

#3 Post by GatorDog »

Thanks Lobster for Slacko instructions. :)

_______________________________________________________________________________________

Along with the latest Bacon version you may want to make sure you have the current HUG files (GUI programing)
- "hug.bac" v .63
- "hug.so" shared object library (compiled hug.bac)
- hug_imports.bac

hug.bac and hug_imports.bac can go in /usr/share/BaCon/

and hug.so in /usr/lib/
_______________________________________________________________________________________

You can rename hug.so to libhug.so if you want, but you'll need to change the top line in hug_imports.bac to reflect
the name change.
Attachments
beach.jpg
Great place for a "Sardine break*.
(47.3 KiB) Downloaded 1588 times
HUG_v63.tar.gz
hug.bac (v63)
hub.so (v63)
hug_imports.bac
(78.08 KiB) Downloaded 473 times

User avatar
Lobster
Official Crustacean
Posts: 15522
Joined: Wed 04 May 2005, 06:06
Location: Paradox Realm
Contact:

#4 Post by Lobster »

Many thanks GatorDog, have amended my previous post
to include [ [ [ [ [ HUG ] ] ] ] ]
Puppy Raspup 8.2Final 8)
Puppy Links Page http://www.smokey01.com/bruceb/puppy.html :D

User avatar
Lobster
Official Crustacean
Posts: 15522
Joined: Wed 04 May 2005, 06:06
Location: Paradox Realm
Contact:

#5 Post by Lobster »

8) Well for my new found toy I thought I would add compression to compiled programs using UPX
Basically it makes the compiled code smaller . . .
http://en.wikipedia.org/wiki/UPX

However I only got as far as adding the menu option not executing it :oops:
See the enclosed file (it also contains the license for UPX in a compressed file)

Try UPX out on the ready compiled bgui2 (note the size before and after)

Code: Select all

./upx bgui2
In 'bgui2' you will notice under 'tools' the compress option (but no execute option)
In the bgui2.bac code my few inserts are labeled 'LOB 1, 'LOB 2 etc

If GatorDog or anyone with the required skill (not me today) wants to add that compression option - Great! Hope you do. 8)

I am going back to BASICS :roll:
Puppy Raspup 8.2Final 8)
Puppy Links Page http://www.smokey01.com/bruceb/puppy.html :D

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

upx - file compressor

#6 Post by GatorDog »

(note the size before and after)
:shock: ! WOW ! :shock:
anyone with the required skill (not me today) wants to add that compression option
I have several irons in the fire right now. Maybe L18L or vovchik will have an idea. :wink:

Thanks Lobster, for sharing that little jewel (upx),

GatorDog

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

#7 Post by big_bass »

Lobster
If GatorDog or anyone with the required skill (not me today) wants to add that compression option - Great! Hope you do. Cool
A big thanks
this is great news that the compiled BaCon bin can be compressed!
and the resulting bin is much smaller this will get more people writing apps in BaCon

updated more BaCon and Hug keywords and the upx compression option
http://murga-linux.com/puppy/viewtopic. ... &start=353

it is very easy to add this option to geany

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 8)

Joe

User avatar
PjotAwake
Posts: 34
Joined: Wed 03 Nov 2010, 20:58
Location: The Hague, The Netherlands
Contact:

#8 Post by PjotAwake »

Folks,

The BaCon binary also can be created using specific C compiler options. On my 32-bit system with GCC 4.5.2, the default way of compiling binary delivers a size of 407994 bytes.

However, if compiled as follows:
bacon.bash -o -O2 -o -s bacon
...the resulting size is 341760 bytes (gain of approx. 16%).

After this the binary can be compressed even more using UPX.

Regards
Peter

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

#9 Post by big_bass »

Thanks Peter @PjotAwake
P.S I am having a lot of fun with BaCon

1.)with no compiler options compile it
using bacon.bac in this example 387kb


2.)using the compile options PjotAwake posted above compile it
using bacon.bac in this example 283kb

Code: Select all

bacon -o -O2 -o -s bacon.bac 
*I already have bacon installed

3.)using upx compression on the already compiled bin 66kb


4.) with no compiler options used using the 387kb bin
then compress bacon with upx and the result is 59kb !
I dont know why but the numbers are the numbers :D

5.)

Code: Select all

upx  --ultra-brute  bacon
54kb takes much longer to compress

===========================================
using tcc compiler instead of gcc
==========================================

Code: Select all

bacon -c tcc bacon.bac
468kb
so the binary is larger :shock:

Code: Select all

upx --force-execve  bacon  
77kb
and to use upx you have to use the
--force-execve option or it wont compress the bin




please note that the size of the bacon bin is not a problem at all
it was only used to show the size reduction that can come from
using upx compression on all of your freshly compiled new BaCon apps


Joe

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

BaconGUI with "upx" support

#10 Post by GatorDog »

.
BaconGUI v1.0.24 with "upx" support.

"upx" needs to be available in PATH.

Convert the program first, then "upx" it.
(Runs upx on the program in the currently active tab.)

Uses "--best" compression. (I'll check that --ultra-brute if there's interest.)


GatorDog
.

FWIW - If you grab the dashed line on the dropdown menu, you'll get an
undocked copy that you can move off to the side. :)
.
Attachments
upx.png
upx under TOOLS menu
(20.71 KiB) Downloaded 1210 times
bacongui-upx.tar.gz
BaconGUI w/ upx support (uses upx --best compression)
(54.45 KiB) Downloaded 429 times

User avatar
Lobster
Official Crustacean
Posts: 15522
Joined: Wed 04 May 2005, 06:06
Location: Paradox Realm
Contact:

#11 Post by Lobster »

Good job GatorDog. Gonna try it shortly. Thanks for letting me know :)

Gonna try a 'from scratch' program . . . not sure what yet . . . :?
Puppy Raspup 8.2Final 8)
Puppy Links Page http://www.smokey01.com/bruceb/puppy.html :D

User avatar
Lobster
Official Crustacean
Posts: 15522
Joined: Wed 04 May 2005, 06:06
Location: Paradox Realm
Contact:

WAM BAM SHEBANG

#12 Post by Lobster »

:D
I was so pleased to receive Gatordogs PM
about the new IDE with UPX . . .
. . . that I wrote the enclosed from scratch in Geany :oops:
(the enclosed zip file does not include a compiled version)

Here is the code for the fish to laugh at :?

Code: Select all

#!/usr/bin/bacon -b
' Command line Buddhist YinYana Mala 
' Test Compiled on Puppy Linux 5.3 Slacko
' Nov 2011 Created by Lobster 
'''''''''''''''''''''''''''''

'''''''''''''''''''''''''''''''''''
' Set Initial State 
'''''''''''''''''''''''''''''''''''
 COLOR RESET
 CLEAR


SUB How_many
 '''''''''''''''''''''''''''''''''''
 ' How many repetitions
 '''''''''''''''''''''''''''''''''''

 PRINT
  COLOR FG TO WHITE
  COLOR BG TO BLUE
  CLEAR
 
 PRINT
 PRINT "  -= How many repetitions would you like? =-"
 PRINT
 PRINT " Type in a number and press ENTER"
 PRINT
 PRINT "  -= Press 0 and ENTER for Auto mode =-"
 
  COLOR FG TO RED
  INPUT repeats
  CLEAR

END SUB


SUB InitialMenu
 '''''''''''''''''''''''''''''''''''
 ' Select Style options  
 '''''''''''''''''''''''''''''''''''
 
 COLOR FG TO BLUE
 COLOR BG TO WHITE
 CLEAR

 COLOR FG TO WHITE
 COLOR BG TO BLUE
 PRINT "----------------------------------------" 
 PRINT "  YinYana Mantra Practices              " 
 PRINT "----------------------------------------" 

 COLOR FG TO BLUE
 COLOR BG TO WHITE
 PRINT
 PRINT "    Press 1 and ENTER for MANI's beginners"
 PRINT "    Press 2 and ENTER for GANESH mantra"
 PRINT "    Press 3 and ENTER for MEDICINE BUDDHA"
 PRINT "    Press 4 and ENTER for YINYANA mantra"
 PRINT "    Press 5 and ENTER for WRATHFUL Practice"
 PRINT "    Press 6 and ENTER for AMITABA Practice"

  COLOR FG TO RED
INPUT mantra_choice$

'''''''''''''''
' Make choice
'''''''''''''''

IF mantra_choice$ = "1" THEN 
  COLOR FG TO RED
  COLOR BG TO YELLOW
  CLEAR
  SYSTEM "mplayer omm.wav"
  mantra$ = "     OM MANI PEME HUM"
  CLEAR
ENDIF

IF mantra_choice$ = "2" THEN 
  COLOR FG TO WHITE
  COLOR BG TO GREEN
  CLEAR
  mantra$ = "     OM GANAPATAYA NAMAHA"
  SYSTEM "mplayer ganesh.mp3"
  CLEAR
ENDIF

IF mantra_choice$ = "3" THEN 
  COLOR FG TO WHITE
  COLOR BG TO BLUE
  CLEAR
  mantra$ = "     OM BEKANZA BENKANZA RA ZA TSA MUN GATE SOHA"
  CLEAR
ENDIF

IF mantra_choice$ = "4" THEN 
  COLOR BG TO WHITE
  COLOR FG TO CYAN
  CLEAR
  mantra$ = "    MAY TRE YA, OM TRE YA OM, YA OM MAY YA HUM"
  CLEAR
ENDIF

IF mantra_choice$ = "5" THEN 
  COLOR BG TO WHITE
  COLOR FG TO RED
  CLEAR
  mantra$ = "     OM AH HUM VAJRAKILI KILAYA HUM PEY"
  CLEAR
ENDIF

IF mantra_choice$ = "6" THEN 
  COLOR BG TO WHITE
  COLOR FG TO RED
  CLEAR
  mantra$ = "     AMITABA"
  SYSTEM "mplayer amtb8.wav"
  CLEAR
ENDIF

END SUB
 

SUB QueDisplay
 ''''''''''''''''''''''''''''''''
 ' Help Display 
 ''''''''''''''''''''''''''''''''
  COLOR FG TO WHITE
  COLOR BG TO BLUE
  CLEAR

 PRINT
 PRINT " ----------------------------------------" 
 PRINT "  YinYana Virtual Mala - What it is?     " 
 PRINT " ----------------------------------------" 
 PRINT
 PRINT "    For Vajrayana practitioners, common mantras"
 PRINT "    are repeated in 108 lots"
 PRINT "    It corresponds to the bead number"
 PRINT "    on a mala or Buddhist rosary"
 PRINT
 PRINT "    The chanting generates a mind calming effect" 
 PRINT
 PRINT "    You will be given a selection of mantras to repeat"
 PRINT "    and prompted for the number of repetitions"
 PRINT 
 COLOR FG TO BLUE
 COLOR BG TO WHITE
 PRINT "    Ctrl + c to Quit, ENTER to continue"
 
INPUT return_to_menu$

END SUB


SUB DisplayAffirmations
 ''''''''''''''''''''''''''''''''
 ' Display Affirmations in terminal 
 ''''''''''''''''''''''''''''''''
 
x=0
CURSOR <OFF>

 REPEAT
     x=x+1
     PRINT "   ",x," ",mantra$
     IF repeats = 0 THEN SLEEP 5000
     ELSE INPUT c$
 UNTIL x = repeats

END SUB


'''''''''''''''''
' Run Program
'''''''''''''''''
 CALL QueDisplay
 CALL How_many
 CALL InitialMenu
 CALL DisplayAffirmations
 CALL InitialMenu
 
''''' END Program
Right at the top you will see

Code: Select all

#!/usr/bin/bacon -b
This means you do not have to compile the program to run it
using something called a 'Shebang' (news to me as I have led a sheltered programming life)

You just run the program from the command line like so

Code: Select all

./chant1.bac
--------

The program is command line only
I am running Slacko, so used the SYSTEM command to run mplayer

Code: Select all

SYSTEM "mplayer omm.wav"
One thing that got me - Python does this too
You must have a blank line at the end of your program :oops:

- the error messages were very good :)

Been a while since I programmed in BASIC.
This page was helpful
http://www.basic-converter.org/documentation.html

In particular the ability to use

Code: Select all

SUB <name>
END SUB
and then

Code: Select all

CALL SUB
means structured procedural programs are possible
(gosh - almost sound like I know what I am talking about) :shock:
Puppy Raspup 8.2Final 8)
Puppy Links Page http://www.smokey01.com/bruceb/puppy.html :D

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

#13 Post by GatorDog »

Hey Lobster,

Looks like a weiner Image :D

______________________________________________________________________________________________________________________
You must have a blank line at the end of your program
What bacon version are you running?
______________________________________________________________________________________________________________________

You could use mhWaveEdit to convert audio files to nnn.au format.
I've been reducing sample rate to about 14000 and converting to mono.
Smaller than wav files.

Mplayer and aplay can play .au format.
Seems like aplay starts a little quicker.
And "aplay -q file.au" will suppress message output to the terminal.

Good going,
GatorDog

(and what's up with this geany thing :twisted: )

User avatar
Lobster
Official Crustacean
Posts: 15522
Joined: Wed 04 May 2005, 06:06
Location: Paradox Realm
Contact:

#14 Post by Lobster »

GatorDog wrote:Hey Lobster,

Looks like a weiner
We do not have this brand of hot dog sausage in the UK
. . . however I am aware of the idiom and sentiment.
Many thanks :)
You must have a blank line at the end of your program
What bacon version are you running?
November 1, 2011: BaCon 1.0 build 24

I think this may be a feature/bug/result of using the shebang method - compiling the program it probably does not matter . . .
However with Shebang you have to interpret a 'clear line'

Thanks for the audio tips 8)
(and what's up with this geany thing :twisted: )
Ah yes - familiarity (I turn on the Basic coding highlight - we could do with one for BaCon) and known reliability and the ability to zoom into code with the mouse wheel.

Thanks for the encouragement.
Programming does not come easy to me
but I like to try . . .
Puppy Raspup 8.2Final 8)
Puppy Links Page http://www.smokey01.com/bruceb/puppy.html :D

Post Reply