Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Sun 21 Dec 2014, 14:42
All times are UTC - 4
 Forum index » Off-Topic Area » Programming
BaCon Bits
Post_new_topic   Reply_to_topic View_previous_topic :: View_next_topic
Page 3 of 12 Posts_count   Goto page: Previous 1, 2, 3, 4, 5, ..., 10, 11, 12 Next
Author Message
GatorDog


Joined: 12 Sep 2006
Posts: 136

PostPosted: Mon 08 Aug 2011, 03:45    Post_subject: Hello Bacon (World)
Sub_title: Using a COMBO widget
 

A project to demo some of the BaCon HUG widgets.
This program demos the COMBO widget ie. drop down box.

This is the naming convention that I've started using.
It should prevent collisions with items used in the compiler.

    ALL_UPPER_CASE ( All uppercase for SUB's and FUNCTIONs )
    Unnnn_nnnn_ ( Uppercase first letter, end with "_" for widget handles )
    Unnnn_nnnn ( Variable names )
    Unnnn_nnnn$ ( String variables )

NEW -
The GLOBAL statement.
Although not strictly necessary, declaring variables becomes
more useful the bigger a program gets. The "TYPE NUMBER" declares
these variables to be numbers. We can have as many GLOBAL statements
as we want.

COMBO
The COMBO widget is initialized like this:
Widget_handle_ = COMBO( "first item", size-x, size-y )

Items are added to the COMBO widget with the TEXT method:
TEXT( Widget_handle_, "2nd item" )
TEXT( Widget_handle_, "3rd item" )
TEXT( Widget_handle_, "4th item" )

Then the COMBO is added to the widow in the same way the buttons
were in the previous example.
ATTACH(Mainwin_, Widget_handle_, x-coord, y-coord )

rod
Code:
' BaCon / HUG  Hello BaCon (World)
' Add a Combo widget (drop down)

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

GLOBAL Mainwin_, Menu_label_, Drink_label_, Drink_combo_, My_close_ TYPE int

' ******************
' SUBS & FUNCTIONS
' ******************

' ------------------
SUB MAKE_GUI
' ------------------
   Mainwin_ = WINDOW( "Hello BaCon", 400, 400 )

   Menu_label_ = MARK( "Please choose items from Menu", 200, 28 )
   ATTACH( Mainwin_, Menu_label_, 100, 0 )

   Drink_label_ = MARK("Select Drink", 100, 28)
   ATTACH( Mainwin_, Drink_label_, 10, 25)

   '--- Add a COMBO widget with 4 items
   Drink_combo_ = COMBO("Coffee", 100, 28 )
   TEXT( Drink_combo_, "Tea")
   TEXT( Drink_combo_, "Milk")
   TEXT( Drink_combo_, "O,J.")
   ATTACH( Mainwin_, Drink_combo_, 10, 50 )


   '--- BUTTONS ---
   Close_btn_ = STOCK("gtk-close", 100, 28)
   ATTACH(Mainwin_, Close_btn_, 290, 365)

   '--- CALLBACKS ---
   CALLBACK(Close_btn_, QUIT)
END SUB

' ******************
' END SUBS & FUNCTIONS
' ******************


' ******************
' MAIN PROGRAM
' ******************

MAKE_GUI

DISPLAY
hello_bacon.png
 Description   
 Filesize   9.68 KB
 Viewed   1253 Time(s)

hello_bacon.png

hello_bacon_combo.tar.gz
Description  source file
gz

 Download 
Filename  hello_bacon_combo.tar.gz 
Filesize  641 Bytes 
Downloaded  378 Time(s) 
Back to top
View user's profile Send_private_message 
sunburnt


Joined: 08 Jun 2005
Posts: 5043
Location: Arizona, U.S.A.

PostPosted: Mon 08 Aug 2011, 14:39    Post_subject:  

Hey GatorDog; Thanks for the help at the BaCon forum, mucho appreciato!

Thoughts; I dislike the underscore "_", after years of Visual Basic I like the period.

And the Visual Basic convention for control naming, "winMain" or "btnOk".
The lower case first part ids the control type, the next part ids it`s purpose.
This is very sensible and easy to understand.

I liked your idea of using the underscore at the end of handles, it`s like a little handle.
So the handle for the button control "btnOk" would be "btnOk_".

Qs ( of course ).
Can a variable list be used for the combo items? Example:
Code:
   TEXT( Drink_combo_, "$cboMonths_list")

So there would be only one TEXT statement for the combo box.
I`d hope there`s a method of doing this some way.

Keep the tutorials coming GatorDog, I think Barry`s behind you.
Back to top
View user's profile Send_private_message 
GatorDog


Joined: 12 Sep 2006
Posts: 136

PostPosted: Mon 08 Aug 2011, 15:11    Post_subject:  

Quote:
Can a variable list be used for the combo items? Example:
Code:
TEXT( Drink_combo_, "$cboMonths_list")

So there would be only one TEXT statement for the combo box.
I`d hope there`s a method of doing this some way.


In pFontSelect (earlier post) I populated the list of fonts with a FOR/NEXT loop.
So if the list of items are already in Some_array$[] of length Number_of_items, then
you can add these items to the list or combo with something like this:
(assuming you have OPTION BASE 1 set up, you can start count with 1)
Code:
FOR Count = 1 to Number_of_items
   TEXT( Drink_combo_, Some_array$[Count] )
NEXT

If you don't have an array$[] yet, but have the items in a string, say seperated by ":",
ex Drink$ = "Coffee:Tea:Milk:Water:O.J."
Then use the SPLIT command to create an array, then populate the list/combo.
Code:
SPLIT Drink$ BY ":" TO Drink_array$ SIZE Drink_Count
FOR Count = 1 to Drink_count
   TEXT( Drink_combo_, Drink_array$[Count] )
NEXT
Back to top
View user's profile Send_private_message 
GatorDog


Joined: 12 Sep 2006
Posts: 136

PostPosted: Mon 08 Aug 2011, 15:19    Post_subject: Hello Bacon (World)
Sub_title: FRAME & RADIO Buttons
 

NEW -

FRAME widget
The FRAME widget lets you visually group items together.
Here we'll use it to group the radio buttons. First
give the FRAME a Handle_ and size. Optionally give the
frame a title with the TEXT command. Then attach it to
our main window.



RADIO buttons widget
The RADIO buttons are usually used when you need the
user to select one of several options. The group name
assigns the radio button to a specific group of buttons.
See [html=http://www.basic-converter.org/hugdoc.html]HUG[/html] doc for further information about group name.
Handle_1_ = RADIO( "First item", x-size, y-size, group_name )
Handle_2_ = RADIO( "Second item", x-size, y-size, group_name )
Handle_3_ = RADIO( "Third item", x-size, y-size, group_name )


SET method
Use the SET method to "set" the default to the third radio button.
SET( Handle_3_, TRUE )

TRUE and FALSE are reserved keywords.
Basically FALSE is defined as "0" zero, and TRUE anything other than
zero, but you'll probably find that TRUE is "1".

Here is the code to add the FRAME and RADIO buttons. The download has
the complete program so far.

rod

Code:

   '--- Add a FRAME for slice size
   Slice_frame_ = FRAME( 265, 50 )
   TEXT( Slice_frame_, " Slice My Bacon: " )
   ATTACH( Mainwin_, Slice_frame_, 120, 32 )

   '--- Add RADIO buttons for slice size selection
   Slice_size_1_ = RADIO( "Thin"  , 70, 28, Slice_size_1_ )
   Slice_size_2_ = RADIO( "Medium", 70, 28, Slice_size_1_ )
   Slice_size_3_ = RADIO( "Thick" , 70, 28, Slice_size_1_ )
   ATTACH( Mainwin_, Slice_size_1_, 130, 50 )
   ATTACH( Mainwin_, Slice_size_2_, 220, 50 )
   ATTACH( Mainwin_, Slice_size_3_, 310, 50 )
   SET( Slice_size_3_, TRUE )

hello_bacon.png
 Description   
 Filesize   11.66 KB
 Viewed   942 Time(s)

hello_bacon.png

hello_bacon-frame.tar.gz
Description  source
gz

 Download 
Filename  hello_bacon-frame.tar.gz 
Filesize  788 Bytes 
Downloaded  374 Time(s) 
Back to top
View user's profile Send_private_message 
sunburnt


Joined: 08 Jun 2005
Posts: 5043
Location: Arizona, U.S.A.

PostPosted: Mon 08 Aug 2011, 16:31    Post_subject:  

Thanks GatorDog; Would you prefer that I ask Qs in another thread or maybe at the BaCon forum?

Q; You ATTACH the radio buttons to MainWin, not the frame.
So I assume the frame is just a visual widget and not a widget container?
Back to top
View user's profile Send_private_message 
GatorDog


Joined: 12 Sep 2006
Posts: 136

PostPosted: Mon 08 Aug 2011, 16:56    Post_subject:  

Quote:
Q; You ATTACH the radio buttons to MainWin, not the frame.
So I assume the frame is just a visual widget and not a widget container?


I just tried a quick test. It does not seem to be a container. But if push comes to
shove, it might be best to get it straight from Peter Smile

rod
Back to top
View user's profile Send_private_message 
sunburnt


Joined: 08 Jun 2005
Posts: 5043
Location: Arizona, U.S.A.

PostPosted: Mon 08 Aug 2011, 19:46    Post_subject:  

I tested it using the frame`s handle and it doesn`t show the widget.
Changing the X, Y position I placed the radio button half over the frame edge.
That settles it, the frame is not a widget container, it`s just a visual widget.
Back to top
View user's profile Send_private_message 
sunburnt


Joined: 08 Jun 2005
Posts: 5043
Location: Arizona, U.S.A.

PostPosted: Mon 08 Aug 2011, 22:34    Post_subject:  

I`m working with a combo and I wondered, how to get the item selected?
Need to do this both by making a combo selection and also by a button.

Need to modify my HUG library so the combo will use an array.
Back to top
View user's profile Send_private_message 
GatorDog


Joined: 12 Sep 2006
Posts: 136

PostPosted: Tue 09 Aug 2011, 02:18    Post_subject:  

Quote:
I`m working with a combo and I wondered, how to get the item selected?
Need to do this both by making a combo selection and also by a button.

If you mean you want to get the currently selected COMBO item, do that with GRAB$.
Code:
Picked_item$ = GRAB$( Combo_widget_ )


If you mean that you want to set the default value, use the SET method
SET( Combo_widget_ , 3) . To set it with a button, do a callback to a
function/sub that then does a SET. Wink

From HUG doc:
Quote:
SET(widget, value)
"Depending on the widget, sets a value into the widget. The current behavior is shown in the table below."
Combo - Select entry in combo



rod
Back to top
View user's profile Send_private_message 
sunburnt


Joined: 08 Jun 2005
Posts: 5043
Location: Arizona, U.S.A.

PostPosted: Tue 09 Aug 2011, 07:09    Post_subject:  

So then I assume the combo will use the callback event?
It`s the only way I can think of to know when a selection is made.
The button callback event can use the GRAB method of course.

I think I`m going to make a complete set of widget test files.
Then it`ll be easy to try out all the different HUG possibilities.
Back to top
View user's profile Send_private_message 
GatorDog


Joined: 12 Sep 2006
Posts: 136

PostPosted: Tue 09 Aug 2011, 18:15    Post_subject: Hello Bacon (World)
Sub_title: CHECK box, LIST, SPINner
 

For both of you who are following along, I hope you're
trying out these examples. Make changes, move things around,
add to, etc.

A "CONST" (constant) is a variable that is not going to change value
during the course of the program run. I want a carriage return
ie. NewLine in the text so that the text for the CHECKbox
isn't stretched out. We'll use the CONCAT$ command to
concatinate (string together) three string$. "NL$" is
a reserved word for the "New Line" character. CONST doesn't
really buy us much in a program of this size. But in larger
programs it'll help us keep track of variable names we're using
and save memory space. (This is my opinion/thought on CONST).
Since the CONST declares a variable of fixed length, it is static.
The program sets it up and leaves it alone. A variable length
variable can be dynamic, changing length, memory location and
how much memory it occupies. That means the program has to spend
some amount of resources keeping track of it, moving it around,
making sure there is memory available. etc. So I suggest using
CONST where appropriate. For GLOBAL variables, in addition to
helping you keep track of the variables you're using, it gives
the compiler a "heads up" on the variables to come.
(Or I may just be full of it Wink ) At any rate, we'll use this
CONST in our program. Look at the screen shot to see the effects of NL$.
Code:
CONST Egg_checkbox$ = CONCAT$("Check if you", NL$, " want eggs")

Introducing three more widgets AND going to add a tad bit of logic in to boot.

We'll add a section for ordering Eggs, putting a FRAME around it.
Nothing new here:
Code:
   '--- Add FRAME for eggs
   Eggs_frame_ = FRAME(380, 130)
   TEXT(Eggs_frame_, " How about those Eggs ")
   ATTACH(Mainwin_, Eggs_frame_, 10, 85)


The first widget is the CHECKbox.
Code:
   '--- CHECK box for eggs
   Eggs_or_not_ = CHECK(Egg_checkbox$, 100, 45)
   ATTACH(Mainwin_, Eggs_or_not_, 20, 130)

Next up is a LIST widget. Items are added to the LIST widget
in the same way we added items to the COMBO widget; with
the TEXT method. I deliberately added more items to the
list than will fit in the LIST window. This to show that
the list window will automatically add a scrool bar. If
an item in the list is too wide to fit the window, a
horizontal scrool bar will be added. Note the DISABLE
method is used, the list is "grayed out" and not accessable.
(We'll do the same for the egg count).
Code:
   '--- Add a LIST widget for cooking eggs
   Eggs_list_ = LIST(120, 100)
   TEXT(Eggs_list_, "Sunny Side Up")
   TEXT(Eggs_list_, "Over Easy")
   TEXT(Eggs_list_, "Scrambled")
   TEXT(Eggs_list_, "Poached")
   TEXT(Eggs_list_, "Runny")
   TEXT(Eggs_list_, "Hard Boiled")
   ATTACH(Mainwin_, Eggs_list_, 150, 105)
   DISABLE(Eggs_list_)

The SPIN widget is just an up/down counter. It's set up
like this:
Handle_ = SPIN( xsize, ysize, start_count, end_count, step)
Throw in a label so the user knows what the count is for.
This SPINner allows the user to pick from 1 to 4 eggs.
Code:
   '--- Label/MARK for egg count
   Tmp$ = CONCAT$("How Many", NL$, "    Eggs")
   How_many_label_ = MARK(Tmp$, 75, 40)
   ATTACH(Mainwin_, How_many_label_, 300, 120)

   '--- Add SPINner widget for how many eggs
   How_many_eggs_ = SPIN(40, 26, 1, 4, 1)
   ATTACH(Mainwin_, How_many_eggs_, 320, 160)
   DISABLE(How_many_eggs_)
   SET(How_many_eggs_, 2)

Now we'll add in some logic. If the CHECK box is blank, then
the user doesn't get to make selections about the eggs.
ie. DISABLE'd. If the box is checked, we need to ENABLE the
egg selection widgets. We'll do the actual enable-ing with a
call to a SUBroutine; get to that in a moment.

There are two parts to the logic here. First, watch the
CHECK box for a change. Second, do something if the CHECK box
status changes. We'll set up a CALLBACK function to watch for
an "event" (in this case anything) to happen to the CHECK box.
We gave the CHECK box the widget handle "Eggs_or_not_". And
we'll write a subroutine named "ENABLE_EGGS" to execute when
an event occurs to "Eggs_or_not_".
Code:
CALLBACK(Eggs_or_not_, ENABLE_EGGS)

About the IF/THEN construct. In simplest form-
Code:
IF this_is_true THEN
   do_this
END IF
The "this_is_true" just needs to evaluate to a non zero
result. In our case, GET(.....) gets the value of the CHECK box
widget. "0" if not checked, "1" if checked. So if our CHECK box
is checked, GET(Eggs_or_not_) evaluates to "1" ie TRUE, and the
following commands are executed. Otherwise it must be FALSE, so
execute the commands after the "ELSE" statement. For more in-depth
info on IF/THEN, Google-it.
Code:
' ------------------
SUB ENABLE_EGGS
' ------------------
   IF GET(Eggs_or_not_) THEN
      ENABLE(Eggs_list_)
      ENABLE(How_many_eggs_)
   ELSE
      DISABLE(Eggs_list_)
      DISABLE(How_many_eggs_)
   END IF
END SUB

Check out the whole program to see how the widgets are used, and the
CALLBACK and SUB routine are setup.

rod

(how did I get the text at the top bigger and thicker ?)
hello_bacon.png
 Description   
 Filesize   26.94 KB
 Viewed   899 Time(s)

hello_bacon.png

hello_bacon.tar.gz
Description  hello_bacon source
gz

 Download 
Filename  hello_bacon.tar.gz 
Filesize  1.24 KB 
Downloaded  379 Time(s) 
Back to top
View user's profile Send_private_message 
sunburnt


Joined: 08 Jun 2005
Posts: 5043
Location: Arizona, U.S.A.

PostPosted: Tue 09 Aug 2011, 23:10    Post_subject:  

Rob; Next make the combo auto put the selection into a entry.
And add a button that puts the combo`s current selection into a label.

So combo action is demoed, and changing a label`s text is also.

Combo boxes are a real sore point of gtkDialog. Little functionality.
Back to top
View user's profile Send_private_message 
GatorDog


Joined: 12 Sep 2006
Posts: 136

PostPosted: Wed 10 Aug 2011, 03:03    Post_subject: Combo Challenge  

Quote:
Next make the combo auto put the selection into a entry.
And add a button that puts the combo`s current selection into a label.
Okie Dokie Wink
rod
Code:
'Da combo challenge
INCLUDE "/usr/share/BaCon/hug_imports.bac"
INIT

' ------------------
FUNCTION SEND_TEXT_TO_ENTRY
' ------------------
   TEXT(My_entry_, GRAB$(My_combo_))
   RETURN TRUE
END FUNCTION

' ------------------
SUB COMBO2LABEL
' ------------------
   TEXT(My_label_, GRAB$(My_combo_))
END SUB

' ------------------
SUB CLEAR_LABEL
' ------------------
   TEXT(My_label_, "")
END SUB

' ------------------
SUB MAKE_GUI
' ------------------
   Mainwin_ = WINDOW( "Combo Challenge", 200, 200 )
   PROPERTY(Mainwin_, "icon-name", "gtk-execute")

   '--- COMBO widget with 3 items
   My_combo_ = COMBO("November", 100, 28 )
   TEXT( My_combo_, "Whiskey")
   TEXT( My_combo_, "India")
   ATTACH( Mainwin_, My_combo_, 50, 10 )

   My_entry_ = ENTRY("", 100, 30)
   ATTACH(Mainwin_, My_entry_, 50, 40)

   My_frame_ = FRAME(100, 40)
   TEXT(My_frame_, " Label in here")
   FONT(My_frame_, " 9")
   ATTACH(Mainwin_, My_frame_, 50, 75)

   My_label_ = MARK("", 100, 30)
   ATTACH(Mainwin_, My_label_, 50, 80)

   My_btn_ = BUTTON("Combo2Label", 100, 30)
   ATTACH(Mainwin_, My_btn_, 50, 120)

   My_other_btn_ = BUTTON("Clear-Label", 100, 30)
   ATTACH(Mainwin_, My_other_btn_, 50, 160)

   CALLBACK(My_btn_, COMBO2LABEL)
   CALLBACK(My_other_btn_, CLEAR_LABEL)
   TIMEOUT(500, SEND_TEXT_TO_ENTRY)

END SUB

' ****************
'  MAIN PROGRAM
' ****************

MAKE_GUI

DISPLAY
combo_challenge.jpg
 Description   
 Filesize   8.73 KB
 Viewed   973 Time(s)

combo_challenge.jpg

Back to top
View user's profile Send_private_message 
sunburnt


Joined: 08 Jun 2005
Posts: 5043
Location: Arizona, U.S.A.

PostPosted: Wed 10 Aug 2011, 09:46    Post_subject:  

Very nice GatorDog, it took a minute for me to see the TIMEOUT.

I was puzzled by what the action was that made the combo work.
Back to top
View user's profile Send_private_message 
GatorDog


Joined: 12 Sep 2006
Posts: 136

PostPosted: Thu 11 Aug 2011, 14:11    Post_subject:  

We'll add another widget to Hello BaCon and then look
into processing the information gathered.

Concept- If we want to count out 5 apples, we don't call the
first apple zero. However, computers like to start counting at zero.
(We don't). Bacon has an option that specifies to start counts with
1 instead of zero. "OPTION BASE 1". Put that near the top of the
program. See the BaCon doc for further information.

The ENTRY widget allows the user to type in some piece
of information. Their name for example. This is how we'll
set up an info label and an ENTRY widget.
Code:
   '--- Customer info
   Customer_label_ = MARK("We'll call you when order is ready!", 380, 30)
   PROPERTY(Customer_label_, "xalign", 0.5)
   ATTACH(Mainwin_, Customer_label_, 10, 220)

   Customer_name_ = ENTRY(Customer_directions$, 380, 30)
   ATTACH(Mainwin_, Customer_name_, 10, 246)

To initiate the process I've added a "Place-Order" button next to
the "Cancel" button. We need a CALLBACK to trigger a FUNCTION
when the "Place-Order" button is clicked.
Code:
   Place_order_ = BUTTON("Place-Order", 100, 28)
   ATTACH(Mainwin_, Place_order_, 170, 365)

   CALLBACK(Place_order_, PLACE_ORDER)

Now to write a function named FUNCTION PLACE_ORDER.
We'll only do minimal amount of error checking.
GRAB$(widget_) gets the text, if any, that is in the ENTRY widget.
The double set of double quotes stands for a "null" string (ie. nothing).
If ENTRY is blank, we'll just wait until the customer
is ready to let us know their name Wink The CHOP$ command removes any
leading or trailing spaces or tabs.
Code:
' ------------------
FUNCTION PLACE_ORDER
' ------------------
   Customer_name$ = GRAB$(Customer_name_)
   Customer_name$ = CHOP$(Customer_name$)
   IF Customer_name$ = "" THEN
      RETURN FALSE
   END IF
END FUNCTION

Next we'll check to see if there are spaces in the name. Maybe they
entered their first and last names. To do this, we use the SPLIT
command. We use the space character as the seperator (if there is one).
ex. SPLIT String_to_split$ BY character_to_split_on TO an_array_name$ SIZE how_many_names.
After SPLIT seperates the string into individual smaller chunks (array), it sets
the "how_many_names" variable to the number of smaller chunks. If the customer
entered their first and last name, how_many_names will be set to 2. If there is only
one name, SPLIT is happy setting how_many to one. By the way, if we hadn't used
the "OPTION BASE 1" mentioned earlier, we'd be working with 0 and 1. One meaning
that there are actually two items. (That can get confusing quick.) Any way,
using SPLIT we can make sure we have a single name and that's all the error
checking we'll do on that item.
Code:
' ------------------
FUNCTION PLACE_ORDER
' ------------------
   Customer_name$ = GRAB$(Customer_name_)
   IF Customer_name$ = "" THEN
      RETURN FALSE
   END IF

   SPLIT Customer_name$ BY " " TO Array$ SIZE How_many_names
   Customer_name$ = Array$[ How_many_names ]
END FUNCTION

Refer to the following function code for the rest of this discussion.
Grab the drink order with Drink$ = GRAB$(Drink_combo_) .

The radio buttons for slice thickness take a little more work. We have
to check each one to see which is selected. It will be TRUE if it is selected,
otherwise FALSE. This is a simple IF/THEN test so we can use the shortened IF/THEN syntax.

Now check if they're ordering eggs, and if so grab that information.
The call to our SHOW_ORDER function opens a message box so that the customer
can confirm the order is correct.
Code:
' ------------------
FUNCTION PLACE_ORDER
' ------------------
   Customer_name$ = GRAB$(Customer_name_)
   IF Customer_name$ = "" THEN
      RETURN FALSE
   END IF

   SPLIT Customer_name$ BY " " TO Array$ SIZE How_many_names
   Customer_name$ = Array$[ How_many_names ]

   Drink$ = GRAB$(Drink_combo_)

   IF GET(Slice_size_1_) THEN Slice_thickness$ = "Thin"
   IF GET(Slice_size_2_) THEN Slice_thickness$ = "Medium"
   IF GET(Slice_size_3_) THEN Slice_thickness$ = "Thick"

   Eggs_cooked$ = ""
   How_many_eggs$ = ""
   IF GET(Eggs_or_not_) THEN
      Eggs_cooked$ = GRAB$(Eggs_list_)
      How_many_eggs$ = STR$( GET(How_many_eggs_))
   END IF
   
   SHOW_ORDER : 'Show Msgdialog, Confirm order
   RETURN TRUE
END FUNCTION

This is the code added to set up a MSGDIALOG. Refer to the complete
source code for location and details.
Code:
   '--- This initializes the MSGDIALOG, but doesn't display it yet
   Order_window_ = MSGDIALOG("Confirm Order", 300, 220, 4, 5)

   '--- This "shows" the MSGDIALOG when the "Place-Order" button is clicked
   CALLBACK(Place_order_, PLACE_ORDER)

   '--- This "hides" the MSGDIALOG when the "dialog" button is clicked
   CALLBACK(Order_window_, ORDER_CLOSE)

These are the subroutines that open and close the msgdialog widget.
Code:
' ------------------
SUB SHOW_ORDER
' ------------------
   Tmp$ = CONCAT$("Hello ", Customer_name$, NL$, NL$)
   Tmp$ = CONCAT$(Tmp$, "Please click OK if order is correct", NL$, NL$)
   Tmp$ = CONCAT$(Tmp$, "Drink - ", Drink$, NL$)
   Tmp$ = CONCAT$(Tmp$, "Bacon - ", Slice_thickness$, NL$)
   IF GET(Eggs_or_not_) THEN
      Tmp$ = CONCAT$(Tmp$, How_many_eggs$, " Egg(s), ", Eggs_cooked$, NL$)
   ELSE
      Tmp$ = CONCAT$(Tmp$, "No Eggs", NL$)
   END IF

   TEXT(Order_window_, Tmp$)
   SHOW(Order_window_)
END SUB

' ------------------
SUB ORDER_CLOSE(NUMBER Dialog_, int Button_)
' ------------------
   HIDE(Dialog_)
END SUB


This Hello BaCon program should give you a good running start to create GUI's
using BaCon and HUG.

I added a few other goodies in the source to discover, but you should be able
to figure them out Razz

Happy Crankin'
rod
hello_bacon.tar.gz
Description  source
gz

 Download 
Filename  hello_bacon.tar.gz 
Filesize  2.11 KB 
Downloaded  318 Time(s) 
hello_bacon.jpg
 Description   
 Filesize   25.93 KB
 Viewed   976 Time(s)

hello_bacon.jpg

Back to top
View user's profile Send_private_message 
Display_posts:   Sort by:   
Page 3 of 12 Posts_count   Goto page: Previous 1, 2, 3, 4, 5, ..., 10, 11, 12 Next
Post_new_topic   Reply_to_topic View_previous_topic :: View_next_topic
 Forum index » Off-Topic Area » Programming
Jump to:  

Rules_post_cannot
Rules_reply_cannot
Rules_edit_cannot
Rules_delete_cannot
Rules_vote_cannot
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.1788s ][ Queries: 12 (0.0375s) ][ GZIP on ]