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

#331 Post by GatorDog »

I guess I'm having an extended senior moment. I tried this, but of course it
didn't fly.

Code: Select all

label_title = MARK("<span color=\"red\">Color me red</span>",  50, 30)
ATTACH(mainwin, label_title, 30, 5)
Just printed the literal <span color=\"red\">Color me red</span> :?:

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

OT

#332 Post by L18L »

Off Topic but this flies :D

Code: Select all

# yad --text="<span color=\"red\">Color me red</span>"
More on colors in yad see http://www.murga-linux.com/puppy/viewto ... 2&start=16 :oops:
Attachments
color_me_red.png
(3.61 KiB) Downloaded 1144 times

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

#333 Post by sunburnt »

Is there a way to change blank line spacing in HUG`s List and Combo Boxes?

A medium length list becomes really long, there must be a way to set it...

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

#334 Post by GatorDog »

sunburnt,
There may be a way to do it with "Import the GTK functions". (above my paygrade).
For a LIST widget, you can use FONT(List_, " 10") to set the font size.
However the line spacing still has same space to text proportions, but you
can get more (or less) lines in the same size LIST widget.

FONT works for a COMBO widget also, but not as you'd probably expect :wink:

gDog

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

#335 Post by GatorDog »

forum server hiccup / posted twice.

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

#336 Post by sunburnt »

Thanks GatorDog, I haven`t tried your suggestion yet, dumped the combo for a list.
It`s interesting how the combo boxes in both HUG and gtkDialog kinda suck.
But they are both GTK, it`s also interesting how much different they are.

I hate pull down menus and combos, but are very useful for seldom needed things.

### Q... Is there a DirDialog to match the FileDialog? I didn`t see one.
................ The FileDialog won`t return just a path, of course.

I`ll probably just end up using EXEC$ with Xdialog`s dselect as usual. So sad...

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

#337 Post by GatorDog »

### Q... Is there a DirDialog to match the FileDialog? I didn`t see one.
................ The FileDialog won`t return just a path, of course.
Well, actually it will :D

Code: Select all

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

CONST Mainwin_width = 200
CONST Mainwin_height = 200
CONST Mainwin_border = 5
CONST Btn_height = 25
CONST Btn_width = 125

GLOBAL Foldername$ TYPE STRING

' =====================================================
' 			SETUP FILEDIALOG FOR FOLDER/DIRECTORY
' =====================================================
' ------------------
SUB OPEN_FILEDIALOG
' ------------------
	SHOW(Get_folder_)
END SUB

' ------------------
SUB GET_FOLDERNAME(int Foldername_handle_, int Button_)
' ------------------
	'On exit, Foldername$ = the folder/directory
	HIDE(Foldername_handle_)
	IF Button_ = GTK_RESPONSE_ACCEPT THEN
		Foldername$ = GRAB$(Foldername_handle_)
	ELSE
		Foldername$ = ""
	END IF

' For demo
PRINT Foldername$
' -------

END SUB
' ------------------

' ------------------
SUB MAKE_GUI
' ------------------
	Mainwin_ = WINDOW("Get Folder Demo", Mainwin_width, Mainwin_height)

	Get_folder_ = FILEDIALOG("Select Folder/Directory", "gtk-ok", 300, 300, 2)

	Browse_btn_ = BUTTON("Browse", Btn_width, Btn_height)
	ATTACH(Mainwin_, Browse_btn_, 5, 5)
	CALLBACK(Browse_btn_, OPEN_FILEDIALOG)
	CALLBACK(Get_folder_, GET_FOLDERNAME)
END SUB
' =====================================================
' 						END SETUP FILEDIALOG
' =====================================================

' ******************
LABEL MAIN
' ******************

MAKE_GUI

DISPLAY
rod
Attachments
folder.png
(30.98 KiB) Downloaded 679 times

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

#338 Post by sunburnt »

Ahhh yes... I seem to recall looking at the Message Dialog`s options.
I should have guessed, or better yet used your reference guide...

Now to see if "configure --prepath ......." creates the final dir. ( I think so...).

Many thanks GatorDog, this is coming close to being functional. Terry

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

#339 Post by GatorDog »

Now to see if "configure --prepath ......." creates the final dir. ( I think so...).
Don't know what you're trying to do, but Bacon has MAKEDIR :wink:

rod

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

#340 Post by sunburnt »

Yep... Just need to see if I need to use it !

Another code Q...

Code: Select all

btnDnldP_ = BUTTON("Download Path",120,25)
ATTACH(tab0_,btnDnldP_,5,tabH-120)
CALLBACKX(btnDnldP_,showDLG,0)

SUB showDLG(int btnN)
	SHOW(DLG_)
PRINT btnN
PRINT btnDnldP_
END SUB
### "PRINT btnN" doesn`t show "0", it shows the same as "PRINT btnDnldP" !!!
The BaCon docs seem pretty clear on how to use CALLBACKX ...

# I`m trying to reuse the same FileDialog with different buttons.
....... Each button gets it`s own EntryBox filled from the FileDialog.
....... Should only need to declare/create one FileDialog, right?
# It`d be nice to be able to control the FileDialog type and WinTitle.

# Additional Q... Way to get a return from a Bacon exec file? Like a function?

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

#341 Post by GatorDog »

sunburnt wrote:Another code Q...
The BaCon docs seem pretty clear on how to use CALLBACKX ...

Code: Select all

CALLBACKX(widget, function, value)

Type: directive

Defines a self-defined <function> where HUG should jump to when an event for <widget> occurs, 
and pass <value> to that function. The arguments in the callback function should catch this value.

Example:

INCLUDE "hug.bac"

SUB demo(NUMBER widget, NUMBER value)
    PRINT value
END SUB
Modify your sub definition-
SUB showDLG(NUMBER Handle_, int btnN)
# I`m trying to reuse the same FileDialog with different buttons.
....... Each button gets it`s own EntryBox filled from the FileDialog.
....... Should only need to declare/create one FileDialog, right?
Probably one, for each type used.
# It`d be nice to be able to control the FileDialog type and WinTitle.

Code: Select all

TEXT(widget, "text")
Depending on the widget, sets the text. The current behavior is shown in the table below.
WINDOW Sets the text in the title bar
# Additional Q... Way to get a return from a Bacon exec file? Like a function?

Code: Select all

EXEC$(command$ [, stdin$])

Type: function

Executes an operating system command and returns the result to the BaCon program. 
The exit status of the executed command itself is stored in the reserved variable RETVAL. 
Optionally a second argument may be used to feed to STDIN. See SYSTEM to plainly execute a 
system command. Example:

result$ = EXEC$("ls -l")
result$ = EXEC$("bc", CONCAT$("123*456", NL$, "quit"))
Or, if you mean for a Bacon program to return a value on STDIN, simply have it PRINT the
value before it exits.

rod

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

#342 Post by sunburnt »

Thanks again GatorDog; I`m getting the feel of Bacon, it`s different than QBasic.

Here`s something I was talking about, and you helped me write it.
FFdialog ... ( FileFolder dialog )
It`s an exec. of the FileDialog, it works in Bacon-HUG and in the Bash shell !
Returns the /path/[file], and it also sets the proper WinTitle.

# Just one problem: In the shell it works fine, but...
In Bacon, it leaves a control character at the end of it`s return, probably a LF.
I suppose I`ll have to filter it out in the Bacon program that calls it ( dang! ).

Compile it and make an app. to run it with a label to show the return.
To exec. it:

Code: Select all

FFdialog [ 0 - 3 ]
Take your time... No big rush that you mess with this... Terry
Attachments
FFdialog.bac.gz
(477 Bytes) Downloaded 413 times

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

#343 Post by vovchik »

Dear sunburnt,

Try this out:

Code: Select all

IF INSTR(ARGUMENT$, " ") = 0 THEN
	Style = 0
ELSE
	Style = VAL(CHOP$(RIGHT$(ARGUMENT$, 1)))
END IF
CHOP$ removes exteraneous garbage....and it works.

With kind regards,
vovchik

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

#344 Post by sunburnt »

vovchik; Yes, I`d just hoped that the LF could be removed in FFdialog.
Further checks proved it can`t be, so it must occur when passed to the caller.
Fixed in the Bacon calling program, not in FFdialog.

Code: Select all

FF$ = CHOP$(EXEC$(Title$, "2"))
Strange how the Bash shell doesn`t get the LF but Bacon does...

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

#345 Post by GatorDog »

...Yes, I`d just hoped that the LF could be removed in FFdialog.
Ah yes, sahib, your wish is my command :twisted:
PRINT
...
Prints a numeric value, text, variable or result from expression.
A semicolon at the end of the line prevents printing a newline.
Lookin' good
Gatordog

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

#346 Post by sunburnt »

That`s it... You`re the bomb GatorDog! :idea:

I was thinking of using the : and start a do-nothing command to kill the LF.

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

#347 Post by sunburnt »

Hey guys, I got a working exec. with the File and Message dialogs, and help.
The file/folder dialog is all 4 types and auto sets the winTitle for each type.
The message dialog needs all options: Type, Buttons, Width, Height, Message.
It returns both the end of the GTK response variable name, and it`s negative number.

I think add a font dialog ( maybe like my Visual Basic one ), and color?
There`s a few other dialogs, but they`re not nearly as important as these 4.

Any suggestions are welcome, it`s just the first draft... :?:

# I`d like to give credit to GatorDog, vovchik, and pjot if they want it...


TEST: "hug.bac" makes a exec. file 76 KB larger than "hug_imports.bac" does.
Not much, but my stdDlgs exec. compiles to only 56 KB with "hug_imports.bac".

More damn Qs...
# Can HUG use common icons ( not Stock ) for most dlgs.? PROPERTY ?
# What`s the deal with: INTL$ ? It auto. builds foreign language files?

I`ve noticed the Bacon and HUG docs. are misleading and even wrong.
Maybe I understand it differently, but I`m sure they could be better written.

# stdDlgs.bac is posted below.
Attachments
stdDlgs.bac.gz
For Help, after compiling, in rxvt type: stdDlgs
(1.25 KiB) Downloaded 506 times
Last edited by sunburnt on Sun 25 Sep 2011, 05:03, edited 4 times in total.

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

#348 Post by GatorDog »

sunburnt,
Unless I did something wrong (possible), stdDlgs.bac wan't in package.
The stdDlgs binary was, but got a seg fault when I tried to run it.

rod

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

#349 Post by sunburnt »

Sorry about that, rushing to get to something else.

Need to finish up my Deb. downloader and package builder app.

# Amazing, now the File Folder dialog isn`t returning anything! I`ll fix it...

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

#350 Post by sunburnt »

Fixed... Useless code messing it up.

# Another Q: (NUMBER dialog_, int button_)
Why is dialog_ a NUMBER, and button_ an int ?
They`re both widget handles... What`s a NUMBER exactly?

Post Reply