BaCon - Bash-based Basic-to-C converter/compiler
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
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 281 times
- L18L
- Posts: 3479
- Joined: Sat 19 Jun 2010, 18:56
- Location: www.eussenheim.de/
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
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
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.
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. 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
Thanks!
E
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.
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. 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
Thanks!
E
- Attachments
-
- capture10294.png
- AS-written for PS1.bac
- (9.7 KiB) Downloaded 353 times
- L18L
- Posts: 3479
- Joined: Sat 19 Jun 2010, 18:56
- Location: www.eussenheim.de/
@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
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 289 times
- L18L
- Posts: 3479
- Joined: Sat 19 Jun 2010, 18:56
- Location: www.eussenheim.de/
Moving along quit nicely now,thanks Barry, L18L, and everyone else!
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...)
Any help is appreciated!
E
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...)
Any help is appreciated!
E
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.
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.
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'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
- L18L
- Posts: 3479
- Joined: Sat 19 Jun 2010, 18:56
- Location: www.eussenheim.de/
I have found my screen size 1920x180 in /var/log/Xorg.0.loge_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
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
#
Property commands for width and height from a popup menu I wrote:
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:
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.
Code: Select all
PROPERTY(win_, "width-request", winW)
PROPERTY(win_, "height-request", winH)
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}'
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.
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
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
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
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
I should show full code examples... I apologize.
You don`t need to declare control object`s ID variables.!
Code: Select all
win_ = WINDOW("My App.", 300, 200)
OR:
OPEN File$ FOR READING AS file_
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
@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
Like this example the exact size is set in the control`s ( or widget`s ) statement.
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.:
You can also read or write a file in one shell command too:
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.
Code: Select all
win_ = WINDOW("My App.", 300, 200)
btnExit_ = BUTTON("Exit", 60, 25) : ATTACH(win_, btnExit_, 10, 10) : CALLBACK(btnExit_, 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$))
Code: Select all
File$ = EXEC$(CONCAT$("cat FileToRead"))
SYSTEM "echo Text > FileToWrite"
SYSTEM CONCAT$("echo ", Text$, " > ", FileToWrite$)
The bottom one uses variables for the text and the file.
Notice the spaces in the " literal " parts to separate the command parts.
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. 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.
Any help is very much appreciated!
Thanks!
E
.
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. 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.
Any help is very much appreciated!
Thanks!
E
.
- L18L
- Posts: 3479
- Joined: Sat 19 Jun 2010, 18:56
- Location: www.eussenheim.de/
With me it worked this way:e_mattis wrote:... i tried this:
CALLBACK(com_btn,"Exit",QUIT)
That did not work. ...
Compiler emits messages!
Cause:
too many arguments to function 'CALLBACK'
Hope that helpsfile:///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.
-------
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.
e_mattis; The Bacon ( GTK+ ) COMBO box doesn`t use CALLBACK, you must use the TIMEOUT.
Paste, save, and compile this:
A _ "handle" on the end of the widget variables makes them easy to see.
.
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
.