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:

#441 Post by e_mattis »

Hey,

I went back in and made sure it was written exactly like the one on the website. It compiled and ran through to line 12 (FORMAT line). It gives a problem that '%d' is expected to be int, but is long int.

I have attached the gzip of demo (including screens) and the two screens showing the problem message.

BaCon is a little different than what i'm used to so i will have to pay closer attention to how I type things in - GLOBAL vs Global. Anyway, as far as I can tell, I have the file written correctly. Thanks again for the assist!

E
Attachments
capture13515.png
demo.bac as currently written
(6.67 KiB) Downloaded 368 times
capture12948.png
Problem given at compile
(3.13 KiB) Downloaded 344 times
EsDemo.tar.gz
Erics Demo.bac file and screens of the resulting errors
(44.54 KiB) Downloaded 279 times

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

#442 Post by L18L »

change line 12 to
PRINT c,b$,a,e FORMAT "%c %s %.2f %ld\n"

ld instead of just l

# ./demo
the big black dog125.6
a=125.6 b=the big black dog
z the big black dog 125.60 345
#


file:///usr/share/doc/BaCon/documentation.html has an example under PRINT :wink:

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

#443 Post by e_mattis »

Thanks L18L,

That seems to have done the trick. I am assuming the 'l' in front of the d indicates a long integer for d (which corrects the problem). The example I saw in both the webste and the documentation.html shows it as "...%d\n".

Anyway, with that worked out I can now proceed to the next section...wo0h0o!

I'm sure I'll be needing assistance again, so keep a close eye on the post.

Thanks !

E

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

#444 Post by e_mattis »

Well, that didn't take long....

So I'm at the proxy_setup1.bac example (link to HostGator did not find the file). I type in the code as per the web page. Everything seems to go normally... Converted Hug, Compiled PS1.bac, and Program 'PS1' ready. :)

I type in@ # ./PS1 - nothing. no window, no error message, no nothing. :cry:
Did a recompile like "# bacon -b PS!.bac". Same as before, so again I type in "# ./PS1"-nothing. I go to the file and permission it executable. Again enterd "# ./PS1" - nothng. Clicked the file itself, still nothing. :?

I know I'm missing something here again. :shock: I am thinking a window should appear. Anyway, here is a screen of the code as I typed it.


What did I miss? Help appreciated!

E


{UPDATE}

I read on and copied the PS2.bac from the website, compiled it, and ran it. Noticed for a split second there was a window that appeared then disappeared. Thought on it some more then added a FOR/NEXT statement after the DISPLAY on the PS1 file. It worked - window appeared and stayed active. Even closed when the "close window" x was pressed.

I take it that some other 'action' needs to be implemented after the DISPLAY statement in order for the window to remain. Like say the proverbial 'wait' LOL

Sorry for jumping the gun on this post...took a min for the old brain to fire up :oops:

Thanks!

E
Attachments
capture10294.png
AS-written for PS1.bac
(9.7 KiB) Downloaded 353 times

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

#445 Post by L18L »

BarryK wrote:...Alternatively, you could gzip your demo.bac and post it here.
Please do this alternative

or copy your PS1.bac here.

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

#446 Post by e_mattis »

@L18L

Here is the PS1.bac file as I have it written at present. It works with the invokation of a 'wait' after DISPLAY.

Thanks!

E
Attachments
PS1.tar.gz
Current (013113) copy of PS1.bac file
(273 Bytes) Downloaded 287 times

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

#447 Post by L18L »

e_mattis wrote:@L18L

Here is the PS1.bac file as I have it written at present. It works with the invokation of a 'wait' after DISPLAY.

Thanks!

E
Thank you.
It is not the wait but just the new line after DISPLAY that made it work.

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

#448 Post by e_mattis »

Moving along quit nicely now,thanks Barry, L18L, and everyone else! :D

Ran into a little snag, however. I need to put a menu in the window (Like 'file > open', etc.) I have been looking throughout the pages of the tutorials, documentations, etc and have not found out if it can be done or how to do it. :?

Also, how to display the window full-screen (just starting to search for that info but...) :shock:

Any help is appreciated!

E

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

#449 Post by sunburnt »

Hi e_mattis;
The window title bar control buttons are the only way I know to go full screen.
There might be a "properties request" for it, but they aren`t well documented.

There is no menu bar if you look at the HUG docs, however there`s a post at the BaCon site about importing the GTK+ menu bar.
I played with it a bit, what`s nice about importing is that it compiles fast.

Other than that, you can use a combo box for a single pull-down menu.
I hate the way the GTK made the combo box work, you must use a timer.

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

#450 Post by e_mattis »

Thanks sunburnt,

i'll look a little more and see about the GTK import. I think i'm going to like the idea about the combo boxes better though.

Maybe the best way to say what i am looking for is that I want it to open the full display width and height. fullscreen is the ideal, but full display would work. where would i find the dimension- which file?

thanks!

E

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

#451 Post by L18L »

e_mattis wrote:Thanks sunburnt,

i'll look a little more and see about the GTK import. I think i'm going to like the idea about the combo boxes better though.

Maybe the best way to say what i am looking for is that I want it to open the full display width and height. fullscreen is the ideal, but full display would work. where would i find the dimension- which file?

thanks!

E
I have found my screen size 1920x180 in /var/log/Xorg.0.log
my console wrote: # grep ' HDisplay:' /var/log/Xorg.0.log
[ 33.159] (II) CHROME(0): HDisplay: 1920
# grep ' VDisplay:' /var/log/Xorg.0.log
[ 33.159] (II) CHROME(0): VDisplay: 1080
#

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

#452 Post by sunburnt »

Property commands for width and height from a popup menu I wrote:

Code: Select all

PROPERTY(win_, "width-request", winW)
PROPERTY(win_, "height-request", winH)
Some of us like it use "win_, btn_, lst3_, file_" for object variables.
The underline shows that the variable is a handle for the object type.
It helps a lot to clearly see a variable`s purpose when looking at the code.

L18L shows a good way to get the screen resolution.
This is the command way to get it:

Code: Select all

RES=`xrandr | grep '*' | awk '{print $1}'
I find BaCon to be very useful, many cudos to Peter for it`s creation and maintaining.
Being as BaCon uses C, and HUG uses GTK+ it should work on most Linux distros.
So apps. you write are more portable compared to GtkDialog which only Puppy uses
GtkDialog does have more controls ( menu bar I think...) and more properties also.

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

#453 Post by e_mattis »

Thanks guys!

I seem to be having trouble declaring win_, winW, and winH. I've tried 'DECLARE win_, winW, winH' and 'GLOBAL winW, winH TYPE int' but keep getting errors after compile @ run. . .
GLib-GObject-critical**:g_object_set:assertion ....
with no declaration, it tell me the win_, winW, winH are not declared.

I'm probably jumping the gun and need to read more before trying this but I've just got excited about the possibilities...sorry :D

Just want you guys to know I appreciate your patience and assistance - it is good to have people who know to confer with. Thanks so much!

Thanks!

E

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

#454 Post by sunburnt »

I should show full code examples... I apologize.

Code: Select all

win_ = WINDOW("My App.", 300, 200)

OR:
OPEN File$ FOR READING AS file_
You don`t need to declare control object`s ID variables.!

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

#455 Post by e_mattis »

yea, lot different than what i'm used to. Gonna have to re-learn a lot.

@sunburnt
to clarify - when setting 'win_=WINDOW("my win", 300,200) - you set the dimensions of the window there, so the max winW would be 300, not the max width of the viewable screen. Am I correct in that assumption?

When I enter the 'RES = 'xrandr | grep '*' | awk '[print $1]' it gives me an error of "character constant too long for its type [enabled by default]". I am thinking this is due to asking for an int rather than a long int. correct?

thanks!

E

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

#456 Post by sunburnt »

Like this example the exact size is set in the control`s ( or widget`s ) statement.

Code: Select all

win_ = WINDOW("My App.", 300, 200) 
btnExit_ = BUTTON("Exit", 60, 25) : ATTACH(win_, btnExit_, 10, 10) : CALLBACK(btnExit_, EXIT)
This places the button on the window at 10 x 10 and it calls a SUB named EXIT.

I didn`t explain again, sorry. If you notice the command used grep, so it`s a Linux shell command.
Here`s the command called from BaCon, CHOP$ removes the shell`s LineFeed so Res$ has just text.:

Code: Select all

cmd$ = CONCAT$("xrandr | grep '*' | awk '{print $1}'")
Res$ = CHOP$(EXEC$(cmd$))
You can also read or write a file in one shell command too:

Code: Select all

File$ = EXEC$(CONCAT$("cat FileToRead"))

SYSTEM "echo Text >  FileToWrite"
SYSTEM CONCAT$("echo ", Text$, " > ", FileToWrite$)
The top-bottom example writes "Text" to the file FileToWrite.
The bottom one uses variables for the text and the file.
Notice the spaces in the " literal " parts to separate the command parts.

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

#457 Post by e_mattis »

Thaks sunburnt,

I'll play around with it a while and see what I figure out. Bad part is that it makes sense to me, but getting it to work when i write it....lol

thanks !

E

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

#458 Post by e_mattis »

Hey All,

I'm working with combo boxes in bacon/HUG. From what I can tell, this is the syntax to set up the box:

com_btn=COMBO("File",100,25)
ATTACH(mainwin,com_btn,1,1)
TEXT(com_btn,"Backup")
TEXT(com_btn,"Restore")
TEXT(com_btn,"Exit")

In order to make the program exit when 'exit' is chosen, i tried this:

CALLBACK(com_btn,"Exit",QUIT)

That did not work. :x So my question is, once a selection is chosen, how do you initiate an action for (or how do you associate an action with) that selection? :?

Also, I am wondering if there is a means of changing the text color on-screen? I tried the COLOR FG TO WHITE but it had no effect. The text as I have it atm is:

label_title=MARK("test line",80,20)
ATTACH(mainwin,label_title,20,20)

Also tried PROPERTY(label_title,"color","white") to no avail. :(

Observation: There isn't really an in-depth 'how-to' for Bacon that I can find. :cry:

Any help is very much appreciated!

Thanks!

E
.

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

#459 Post by L18L »

e_mattis wrote:... i tried this:

CALLBACK(com_btn,"Exit",QUIT)

That did not work. ...
With me it worked this way:
Compiler emits messages!

Cause:
too many arguments to function 'CALLBACK'
file:///usr/share/doc/BaCon/hugdoc.html wrote:CALLBACK

CALLBACK(widget, function)

Type: directive

Defines a self-defined <function> where HUG should jump to when an event for <widget> occurs.
Hope that helps :)

-------
edited

or this:

Code: Select all

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

SUB myaction
 SELECT GET(com_btn)
  CASE 0
   PRINT "File chosen"
  CASE 1
   PRINT "Backup chosen"
  CASE 2
   PRINT "Restore chosen"
  CASE 3
   QUIT
  DEFAULT
   PRINT "Value not found"
 END SELECT
END SUB

mainwin=WINDOW("combo example", 250, 100)
com_btn=COMBO("File", 100, 25)
ATTACH(mainwin, com_btn, 1, 1)
TEXT(com_btn, "Backup")
TEXT(com_btn, "Restore")
TEXT(com_btn, "Exit") 

CALLBACK(com_btn, myaction)

DISPLAY
---
edited:

this works without TIMEOUT
Last edited by L18L on Sat 23 Feb 2013, 18:46, edited 1 time in total.

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

#460 Post by sunburnt »

e_mattis; The Bacon ( GTK+ ) COMBO box doesn`t use CALLBACK, you must use the TIMEOUT.
Paste, save, and compile this:

Code: Select all

INCLUDE "/root/0_BaCon/BaCon/hug.bac",INIT,DISPLAY,WINDOW,COMBO,MARK,ATTACH,TIMEOUT,SET,GET,TEXT,GRAB$
INIT

SUB Set_Choice
	SET(cboTest_, GET(cboTest_))
	TEXT(lblTest_, GRAB$(cboTest_))
	PRINT GRAB$(cboTest_)
END SUB

win_ = WINDOW(" Combo Test", 100, 100)

lblTest_ = MARK("Test", 80, 25)
ATTACH(win_, lblTest_, 10, 10)

cboTest_ = COMBO("", 80, 25)
ATTACH(win_, cboTest_, 10, 50)

FOR i = 1 TO 5
	TEXT(cboTest_, CONCAT$("Item #", STR$(i)))
NEXT

SET(cboTest_, 1)

TIMEOUT(1000, Set_Choice)

DISPLAY
A _ "handle" on the end of the widget variables makes them easy to see.
.

Post Reply