Liberty BASIC Help Online

Image radiobutton.GIF
RADIOBUTTON #handle.ext, "label", setHandler, resetHandler, x, y, wide, high
This command adds a radiobutton control to the window referenced by #handle.  Radiobuttons have two states, set and reset.  They are useful for getting input of on/off  type information.
All radiobuttons on a given window are linked together, so that if one is set by clicking on it, all the others will be reset (cleared). The exception to this rule occurs when radiobuttons are placed within the confines of groupboxes.  In this case, only radiobuttons contained within the same groupbox act as a radio-set.  Clicking (setting) a radiobutton within one groupbox has no effect on radiobuttons that are placed within other groupboxes.  See the demo below.
This specifies handle for this control.  The #handle part must be the same as the #handle of the window that contains the radiobutton, and the ".ext" part names the radiobutton uniquely in the window.
This specifies the visible text of the radiobutton
This is the branch label or subroutine executed by the program when the user sets the radiobutton by clicking on it.  See also:  Controls and Events
This is the branch label or subroutine executed when the user resets the radiobutton by clicking on it. (this doesn't actually do anything because radiobuttons can't be reset by clicking on them).
This is the x position of the radiobutton relative to the upper left corner of the window it belongs to.
This is the y position of the radiobutton relative to the upper left corner of the window it belongs to.
This is the width of the radiobutton control
This is the height of the radiobutton control
Radiobuttons understand these commands:
print #handle.ext, "set"
This sets the radiobutton.
print #handle.ext, "reset"
This resets the radiobutton.
print #handle.ext, "value? result$"
The result$ variable will be set to the status of the radiobutton (either "set" or "reset").
print #handle.ext, "setfocus"
This causes the radiobutton to receive the input focus.  This means that any keypresses will be directed to the radiobutton.
print #handle,ext, "locate x y width height"
This repositions the radiobutton in its window.  This is effective when the radiobutton is placed inside window of type "window". The button will not update its size and location until a REFRESH command is sent to the window.  See the included RESIZE.BAS example program.
print #handle.ext, "font facename pointSize"
This sets the font to the specified face and point size.  If an exact match cannot be found, then Liberty BASIC will try to find a  close match, with size taking precedence over face. For more on specifying fonts read How to Specify Fonts
print #handle.ext, "font times_new_roman 10"
print #handle.ext, "enable"
This causes the control to be enabled.
print #handle.ext, "disable"
This causes the control to be inactive and grayed-out.
print #handle.ext, "show"
This causes the control to be visible.
print #handle.ext, "hide"
This causes the control to be hidden or invisible.
There are two demo programs below.
'demonstrates radiobuttons with branch label event handlers
WindowWidth = 520
WindowHeight = 220
groupbox #cfg, "Confirm File Operations:", 240, 20, 200, 140
radiobutton #cfg.Aalways, "Always", [alwaysConfirm], [nil], _
    260, 45, 130, 20
radiobutton #cfg.AwhenReplacing, "When Replacing", _
    [whenReplacingConfirm], [nil], 260, 70, 130, 20
radiobutton #cfg.Anever, "Never", [neverConfirm], [nil],_
     260, 95, 130, 20
groupbox #cfg, "Confirm Close Operations:", 20, 20, 200, 140
radiobutton #cfg.always, "Always", [alwaysClose], [nil],_
    40, 45, 130, 20
radiobutton #cfg.whenReplacing, "When Replacing", _
    [whenReplacingClose], [nil], 40, 70, 130, 20
radiobutton #cfg.never, "Never", [neverClose], [nil], _
    40, 95, 130, 20
button #cfg, " &OK ", [cfgOk], UL, 450, 30
open "Action Confirmation - Setup" for dialog as #cfg
print #cfg, "trapclose [cfgOk]"
print #cfg.Anever, "set"
print #cfg.never, "set"
    status$ = "Always Confirm"
    status$ = "When Replacing Confirm"
    status$ = "Never Confirm"
    cstatus$ = "Always Close"
    cstatus$ = "When Replacing Close"
    cstatus$ = "Never Close"
    msg$ = status$ + chr$(13) + cstatus$ + chr$(13)
    msg$ = msg$ + "Save this configuration?"
    confirm msg$ ; answer$
    'perform some sort of save for config here
    close #cfg
'demonstrates radiobuttons with subroutine event handler
global status$
radiobutton #win.yes, "Yes", doRadio, dummy,10,45,130,20
radiobutton, "No", doRadio,dummy,10,70,130,20
open "Make a Choice" for window as #win
print #win, "trapclose Quit"
print #win.yes, "set"
sub doRadio handle$
    notice "You selected ";handle$
    if handle$ = "#win.yes" then status$="yes"
    if handle$ = "" then status$="no"
    end sub
sub Quit handle$
    close #handle$
    end sub
Note: see also CHECKBOX
For information on creating controls with different background colors, see Colors and the Graphical User Interface.

Copyright (C) 2003 Shoptalk Systems
Liberty BASIC -