BaCon - Bash-based Basic-to-C converter/compiler
Hey guys,
@ L18L
yea, isn't it funny how such a small mistake can make you look like such a big dummy ! I went back and sure enough- no line after the end. I put one there and got a good run through. Thanks m8!
@ vovchik
I see what you mean. Tried the hug_imports just for 'grins & giggles' to see what would happen. what a mess! LOL Thanks for the fore-warning!
@ everyone
Now I have more questions....
I need to incorporate a text-area on my window. Also, I will have a listbox to list the 'records' within a file (i.e. lines of data contained within).
I've looked through the docs I have, but do not see any indication of a text area command. I'm sure it is probably something i am overlooking - like multiline or something - so I ask, is there a means of producing multi-lined entry?
As far as the second issue, I have the listbox set up. Question is what would be the best method of inserting data obtained from the read-in of a file? Can I simply create an array and print it to the listbox?
You guys are the best! I have gained a lot of insight from you and appreciate it more than I can express.
Thanks!
E
.
@ L18L
yea, isn't it funny how such a small mistake can make you look like such a big dummy ! I went back and sure enough- no line after the end. I put one there and got a good run through. Thanks m8!
@ vovchik
I see what you mean. Tried the hug_imports just for 'grins & giggles' to see what would happen. what a mess! LOL Thanks for the fore-warning!
@ everyone
Now I have more questions....
I need to incorporate a text-area on my window. Also, I will have a listbox to list the 'records' within a file (i.e. lines of data contained within).
I've looked through the docs I have, but do not see any indication of a text area command. I'm sure it is probably something i am overlooking - like multiline or something - so I ask, is there a means of producing multi-lined entry?
As far as the second issue, I have the listbox set up. Question is what would be the best method of inserting data obtained from the read-in of a file? Can I simply create an array and print it to the listbox?
You guys are the best! I have gained a lot of insight from you and appreciate it more than I can express.
Thanks!
E
.
If you`re using OPEN to read the file then it`s already in an array, correct?
If your using Txt$ = EXEC$(CONCAT$("cat ", $PathFile)) as I suggested then:
Now the file`s contents is in the array $File$[]
The MARK is Bacon`s "Label", it only shows text and can do multiple lines.
If your using Txt$ = EXEC$(CONCAT$("cat ", $PathFile)) as I suggested then:
Code: Select all
SPLIT Txt$ BY NL$ TO File$ Size fileSz
The MARK is Bacon`s "Label", it only shows text and can do multiple lines.
Thanks sunburnt,
Yea, the info is already in an array, just not sure how to print it in the list box. assuming the 'MARK' attribute will do that?
Also, the multi lined area is not the listbox. It will actually be a 'notes' area - for entering your personal notations. As an ENTRY box, i would assume there would be some sort of word-wrap or multi-line setting to use in order to accomplish this. Haven't found the code yet though.
Thanks!
E
[update] 022813 23:32 est
Looks like i figured out the print to listbox (finally ):
TEXT(listbox,variable)
Still working on how to make a multi-line ENTRY box, so any help will be appreciated
.
Yea, the info is already in an array, just not sure how to print it in the list box. assuming the 'MARK' attribute will do that?
Also, the multi lined area is not the listbox. It will actually be a 'notes' area - for entering your personal notations. As an ENTRY box, i would assume there would be some sort of word-wrap or multi-line setting to use in order to accomplish this. Haven't found the code yet though.
Thanks!
E
[update] 022813 23:32 est
Looks like i figured out the print to listbox (finally ):
TEXT(listbox,variable)
Still working on how to make a multi-line ENTRY box, so any help will be appreciated
.
Dear e_mattis,
This may or may not be what you are after, but HUG's EDIT box allows for multiple lines:
With kind regards,
vovchik
PS. For reading in text files, which I do often, I use my own hand-rolled CAT command:
And, as sunburnt has said, if you use NL$ as your SPLIT delimiter, every separate line will be an array element. If you don't want to use arrays, you can always use my little GETWORD$ function:
This may or may not be what you are after, but HUG's EDIT box allows for multiple lines:
Code: Select all
EDIT(xsize, ysize)
Type: directive
Defines a multiline text widget with a width of <xsize> and a height of <ysize>.
Returns the ID of the created text widget.
vovchik
PS. For reading in text files, which I do often, I use my own hand-rolled CAT command:
Code: Select all
' --------------------
FUNCTION CAT(STRING FILENAME$)
' --------------------
LOCAL fileline$, txt$ TYPE STRING
IF FILEEXISTS(FILENAME$) THEN
OPEN FILENAME$ FOR READING AS catfile
WHILE NOT(ENDFILE(catfile)) DO
READLN fileline$ FROM catfile
txt$ = CONCAT$(txt$, fileline$, NL$)
WEND
CLOSE FILE catfile
END IF
RETURN CHOP$(txt$)
END FUNCTION
x$ = CAT("/etc/profile")
PRINT x$
Code: Select all
' --------------
FUNCTION GETWORD$(STRING mystring$, NUMBER word_number, STRING delimiter$)
' --------------
LOCAL i, mypos, n TYPE NUMBER
LOCAL string_temp$ TYPE STRING
i = 0
mypos = 0
n = 1
string_temp$ = ""
mystring$ = CONCAT$(mystring$, delimiter$)
REPEAT
mypos = INSTR(mystring$, delimiter$, n)
INCR i
IF i = word_number THEN
string_temp$ = MID$(mystring$, n, (mypos - n))
END IF
n = mypos + 1
UNTIL mypos IS FALSE
RETURN string_temp$
END FUNCTION
x$ = CAT("/etc/profile")
' grab first line
y$ = GETWORD$(x$, 1, NL$)
PRINT y$
Peg Solitaire - BaCon version
Hi guys,
This is a little game I programmed in Bacon durng the summer but revised it today to take into account the stricter type casting in newer BaCon versions. The excercise was interesting, at least to me, for a number of reasons:
The graphics are all internal to the source - they are generated internally and not loaded from disk.
The program shows how to change mouse cursors and how to create a unique taskbar icon.
My implementation, after some long and hard thought, avoids any real movement of objects. They are simply hidden or shown, and I keep track of thier status.
The rsvg lib is put to good use, and gtk and gkd imports are used because native HUG did not have them.
The program demostrates how to REGISTER new widgets in HUG.
I compiled the binary in lucid (using Bacon beta 1.30 and hug 0.83) and then UPX'd it, so it is not large (23k).
The compile line was:
Have fun....
With kind regards,
vovchik
PS. The game is winnable, but it ain't easy. Press the Help button for instructions on how to play. The archive contains a compiled binary and the source.
This is a little game I programmed in Bacon durng the summer but revised it today to take into account the stricter type casting in newer BaCon versions. The excercise was interesting, at least to me, for a number of reasons:
The graphics are all internal to the source - they are generated internally and not loaded from disk.
The program shows how to change mouse cursors and how to create a unique taskbar icon.
My implementation, after some long and hard thought, avoids any real movement of objects. They are simply hidden or shown, and I keep track of thier status.
The rsvg lib is put to good use, and gtk and gkd imports are used because native HUG did not have them.
The program demostrates how to REGISTER new widgets in HUG.
I compiled the binary in lucid (using Bacon beta 1.30 and hug 0.83) and then UPX'd it, so it is not large (23k).
The compile line was:
Code: Select all
bacon -o -s -o -Os -o -fdata-sections -o -ffunction-sections -o -Wl,--gc-sections psol-1
With kind regards,
vovchik
PS. The game is winnable, but it ain't easy. Press the Help button for instructions on how to play. The archive contains a compiled binary and the source.
- Attachments
-
- psol1.png
- (20.92 KiB) Downloaded 795 times
-
- psol1.tar.gz
- (27.72 KiB) Downloaded 383 times
@ Vovchik
That was exactly what I have been searching for! Never thought it would be listed as 'edit'. Thanks so much!
Also like the 'getword function'. may make it easier to accomplish what I will need. I will give it a shot!
Nice game, too! Haven't gotten to play it much yet, no wins but it may just replace my old "time-killer" solitaire card game at this rate!
You, my friend, are awsome!
@everyone
I really appreciate all your inputs. It is important to me that I learn how to make a 'program' for Puppy as I intend for this OS to be my goto in the future. Thank you so much!
Thanks!
E
PS: So you guys will get an idea, here is a screen of what I'm working on.
That was exactly what I have been searching for! Never thought it would be listed as 'edit'. Thanks so much!
Also like the 'getword function'. may make it easier to accomplish what I will need. I will give it a shot!
Nice game, too! Haven't gotten to play it much yet, no wins but it may just replace my old "time-killer" solitaire card game at this rate!
You, my friend, are awsome!
@everyone
I really appreciate all your inputs. It is important to me that I learn how to make a 'program' for Puppy as I intend for this OS to be my goto in the future. Thank you so much!
Thanks!
E
PS: So you guys will get an idea, here is a screen of what I'm working on.
- Attachments
-
- man_db.png
- GUI for manufacturer database
- (18.83 KiB) Downloaded 768 times
- L18L
- Posts: 3479
- Joined: Sat 19 Jun 2010, 18:56
- Location: www.eussenheim.de/
The commands are:
This transfers text from widget to widget by widget`s index ( List or Combo ):
Transfer text from widget to widget by widget`s text ( Button, Mark, List, Combo, etc.):
It sounded like you were looking for a Label widget, sorry...
Looking at your GUI, it looks like it could be for both display and entry.
To enter or edit an item use a ENTRY, to display text only use a MARK.
Code: Select all
TEXT for entering or changing text in a widget.
GRAB$ for getting text from a widget.
Code: Select all
TEXT(widget, GET(index))
Code: Select all
TEXT(widget, GRAB$(widget))
Looking at your GUI, it looks like it could be for both display and entry.
To enter or edit an item use a ENTRY, to display text only use a MARK.
@L18L
Yea, sorry bud, haven't gotten to putting in the internationalization yet. Gotta get my coding right first for the basis, then I can get 'fancy'
@sunburnt
Thanks m8, that should help make my coding a little prettier when I feel comfortable that I understand it properly. And you are correct, it will be used to both enter and view information. Figure editing can be done by changing displayed info and then saving.
Thanks you guys - all the help has made it possible for me to actually write stuff! I know I will need your inputs as I trudge through on this journey. It is great to know I can count on some assistance along the way!
Thanks!
E
.
Yea, sorry bud, haven't gotten to putting in the internationalization yet. Gotta get my coding right first for the basis, then I can get 'fancy'
@sunburnt
Thanks m8, that should help make my coding a little prettier when I feel comfortable that I understand it properly. And you are correct, it will be used to both enter and view information. Figure editing can be done by changing displayed info and then saving.
Thanks you guys - all the help has made it possible for me to actually write stuff! I know I will need your inputs as I trudge through on this journey. It is great to know I can count on some assistance along the way!
Thanks!
E
.
Hey guys,
Well, i'm back again I have run into a situation I can't resolve with my limited knowledge.
I have an ENTRY box t input a web address. When the entry is reviewed, if desired, I have a button to launch the web browser to the address listed in the ENTRY box.
Here is how I have it set up at the present. it opens the browser but instead of the web page I get the 'FILE:///' index:
would it work better to just use the GRAB$ in the SYSTEM cmd? If the http:// is not included in webaddy, would this disrupt the flow?
Thanks!
E
.
Well, i'm back again I have run into a situation I can't resolve with my limited knowledge.
I have an ENTRY box t input a web address. When the entry is reviewed, if desired, I have a button to launch the web browser to the address listed in the ENTRY box.
Here is how I have it set up at the present. it opens the browser but instead of the web page I get the 'FILE:///' index:
Code: Select all
webz$=GRAB$(webaddy)
IF LEFT$(webz$,7) = "http://" THEN doit
webz$=CONCAT$("http://",webz$)
END IF
LABEL doit
SYSTEM "exec defaultbrowser webz$ &"
would it work better to just use the GRAB$ in the SYSTEM cmd? If the http:// is not included in webaddy, would this disrupt the flow?
Thanks!
E
.
Dear e_mattis,
Just a little mod to your code:
I am assuming you want to make sure that you include the "http://" before you pass the URL to the browser, so you want a properly formatted URL. The tests for validity above are, of course, not good or exhaustive. You could "ping" the site to ensure that it exists first - or use BaCon's networking function - to see that it is responding before launching your browser.
With kind regards,
vovchik
Just a little mod to your code:
Code: Select all
SUB LAUNCH_BROWSER(STRING my_url$)
SYSTEM CONCAT$("exec defaultbrowser ", my_url$, " &")
END SUB
webz$=GRAB$(webaddy)
IF LEFT$(webz$, 7) = "http://" AND LEN(CHOP$(webz)) > 7 THEN
LAUNCH_BROWSER(webz$)
ELIF LEN(CHOP$(webz$)) > 1 THEN
webz$ = CONCAT$("http://", webz$)
LAUNCH_BROWSER(webz$)
ELSE
PRINT "Bad URL. Try again."
END IF
With kind regards,
vovchik
ok, so i've been working on this like the past 5 hours....
I have created the SUB to remove the unwanted record. The flow I am following is this:
clear gui workarea
find the record selected in list
confirm removal of record
find record in database file
remove record from database file and list
tidy up
I am at the 'confirm removal of record' task. Here is the code I have thus far for this section:
I have the 'killme_btn' FUNCTION outside the above SUB.
My problem is two-fold; 1. KMV shows '0' as soon as the selection is made in the listbox and does not change after the MSGDIALOG FUCTION (value kmv not being returned?) and 2. - this is most likely why there is a problem #1 - I cannot figure out the process of using buttons with MSGDIALOG (ie how they react/respond or how to manipulate the result of the button being pushed).
I have also tried CALLBACKX(kilme_dlg,killme_btn,dmv) which gave compile errors because dmv is not assigned yet (?) - even when I set it to 0 (dmv=0) beforehand.
In the Winbloze basic i'm familiar with, the code would be :
this would send kmv to the PRINT line as '0' if OK_BTN was pushed or as '1' if the window were closed without the button being pushed.
I would prefer that the yes/no buttons be used in the dialog and want to set it up so that only the 'yes' button would go through to find the selected file in the database.
I have consulted these references for help:
http://www.basic-converter.org/documentation.html
http://www.basic-converter.org/hugdoc.html
http://basic-converter.proboards.com
I still cannot seem to put it all together Can someone, anyone, please explain how I might get this to work and how to use the MSGDIALOG buttons? All help is greatly appreciated!
Thanks!
E
.
I have created the SUB to remove the unwanted record. The flow I am following is this:
clear gui workarea
find the record selected in list
confirm removal of record
find record in database file
remove record from database file and list
tidy up
I am at the 'confirm removal of record' task. Here is the code I have thus far for this section:
Code: Select all
killmsg$=CONCAT$("You are about to delete ",kilme$," !")
kilme_dlg= MSGDIALOG(killmsg$,350,110,1,1)
SHOW(kilme_dlg)
CALLBACK(kilme_dlg,killme_btn)
PRINT kmv
Code: Select all
FUNCTION killme_btn( NUMBER value)
HIDE (kilme_dlg)
IF value = GTK_RESPONSE_OK THEN
kmv = 0
ELIF value = GTK_REPONSE_DELETE_EVENT THEN
kmv=1
END IF
RETURN kmv
END FUNCTION
I have also tried CALLBACKX(kilme_dlg,killme_btn,dmv) which gave compile errors because dmv is not assigned yet (?) - even when I set it to 0 (dmv=0) beforehand.
In the Winbloze basic i'm familiar with, the code would be :
Code: Select all
CONFIRM"Delete this file?";a$
LOWERCASE$(a$)
IF a$ = "y" OR a$ = 'yes" THEN dmv=0:GOTO next
dmv=1
[next]
I would prefer that the yes/no buttons be used in the dialog and want to set it up so that only the 'yes' button would go through to find the selected file in the database.
I have consulted these references for help:
http://www.basic-converter.org/documentation.html
http://www.basic-converter.org/hugdoc.html
http://basic-converter.proboards.com
I still cannot seem to put it all together Can someone, anyone, please explain how I might get this to work and how to use the MSGDIALOG buttons? All help is greatly appreciated!
Thanks!
E
.
Last edited by e_mattis on Mon 04 Mar 2013, 04:23, edited 1 time in total.
E
Could this be the problem? From http://www.basic-converter.org/hugdoc.html#MSGDIALOG
Regards,
Mobeus
Could this be the problem? From http://www.basic-converter.org/hugdoc.html#MSGDIALOG
Your function def isThe dialog can be connected to a callback function which should have two arguments, the first for the dialog and the second for the button.
SUB HandleError(NUMBER dialog, int button)
Code: Select all
FUNCTION killme_btn( NUMBER value)
Mobeus
/root for the home team
Thanks Mobeus,
Yea, I finally figured that part out my sloppy coding
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 ):
'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:
OR
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
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
Using REPEAT/UNTIL with 'dmv=WAIT(killme_btn,30)' would not compile due to an integer from pointer error. Strike three- I'm out!
Well, off to bed...I'll see what happens with it tomorrow. Meanwhile, any solutions , feel free to post them for me
Thanks all!
E
.
Yea, I finally figured that part out my sloppy coding
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 ):
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
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
Code: Select all
dmv = 3
WHILE dmv >= 3
SHOW(kilme_dlg)
CALLBACK(kilme_dlg,killme_btn)
WEND
Thanks!
E
.
[UPDATE]
Both failed
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
Using REPEAT/UNTIL with 'dmv=WAIT(killme_btn,30)' would not compile due to an integer from pointer error. Strike three- I'm out!
Well, off to bed...I'll see what happens with it tomorrow. Meanwhile, any solutions , feel free to post them for me
Thanks all!
E
.
pausing to get MSGDIALOG input (solved?)
Hey all,
Well, after a couple of days working at it, I finally got the result I was looking for. Here is how I got the program to 'pause' until the MSGDIALOG button was pressed:
I want to thank all those who helped me understand how this works. All the responses and inputs were very helpful!
Thanks!
E
.
Well, after a couple of days working at it, I finally got the result I was looking for. 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
Thanks!
E
.
manufacturer db completed
Hey guys,
Finally completed my first BaCon prog! Wo0h0o!
@L18L
Thought you might want to give it a look over with the international finished on it (I hope ). 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
.
Finally completed my first BaCon prog! Wo0h0o!
@L18L
Thought you might want to give it a look over with the international finished on it (I hope ). 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 576 times
manufacturer db completed
Hey guys,
Finally completed my first BaCon prog! Wo0h0o!
@L18L
Thought you might want to give it a look over with the international finished on it (I hope ). 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
.
Finally completed my first BaCon prog! Wo0h0o!
@L18L
Thought you might want to give it a look over with the international finished on it (I hope ). 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 596 times
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
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 539 times
-
- bmw1.png
- (16.07 KiB) Downloaded 643 times