none
Fremy extensions checkbox question RRS feed

  • Question

  • Do I have to raise an event to get this to work? If the check box is true (checked) why won't the textwindow.write display? I tried it with the controls.setchecked to true but still does not work.

    GraphicsWindow.Show()
    GraphicsWindow.BackgroundColor = GraphicsWindow.GetColorFromRGB(240,240,240)
    Controls.LoadTheme("Vista")

    CheckBox = Controls.AddCheckBox(" Show Text")
    Controls.Move(Checkbox, 140,128)
    'Controls.SetChecked(CheckBox , "True")
    If Checkbox = "True" then
      TextWindow.Write ("Hello" )
    endif

    Any help is greatly appreciated, thank,

    Steve

    Saturday, March 20, 2010 4:10 AM

Answers

  • GraphicsWindow

    .Show()

    GraphicsWindow

    .BackgroundColor = GraphicsWindow.GetColorFromRGB(240,240,240)

    Controls

    .LoadTheme("Vista")

    CheckBox = Controls.AddCheckBox(" Show Text")

    Controls

    .Move(Checkbox, 140,128)

    Controls

    .SetChecked(CheckBox , "True")

    checkbox2 = Controls.GetChecked(CheckBox)

    If

     

    Checkbox2 = "True" then

    TextWindow.Write ("Hello" )

    endif

    There you go. This will work just fine.

    • Proposed as answer by The Hacker2 Saturday, March 20, 2010 6:14 AM
    • Marked as answer by SFC-P33A Saturday, March 20, 2010 2:40 PM
    Saturday, March 20, 2010 6:14 AM

All replies

  • GraphicsWindow

    .Show()

    GraphicsWindow

    .BackgroundColor = GraphicsWindow.GetColorFromRGB(240,240,240)

    Controls

    .LoadTheme("Vista")

    CheckBox = Controls.AddCheckBox(" Show Text")

    Controls

    .Move(Checkbox, 140,128)

    Controls

    .SetChecked(CheckBox , "True")

    checkbox2 = Controls.GetChecked(CheckBox)

    If

     

    Checkbox2 = "True" then

    TextWindow.Write ("Hello" )

    endif

    There you go. This will work just fine.

    • Proposed as answer by The Hacker2 Saturday, March 20, 2010 6:14 AM
    • Marked as answer by SFC-P33A Saturday, March 20, 2010 2:40 PM
    Saturday, March 20, 2010 6:14 AM
  • Do I have to raise an event to get this to work? If the check box is true (checked) why won't the textwindow.write display? I tried it with the controls.setchecked to true but still does not work.

    GraphicsWindow.Show()
    GraphicsWindow.BackgroundColor = GraphicsWindow.GetColorFromRGB(240,240,240)
    Controls.LoadTheme("Vista")

    CheckBox = Controls.AddCheckBox(" Show Text")
    Controls.Move(Checkbox, 140,128)
    'Controls.SetChecked(CheckBox , "True")
    If Checkbox = "True" then
      TextWindow.Write ("Hello" )
    endif

    Any help is greatly appreciated, thank,

    Steve

    Steve,

    The reason that the above won't work, even though it looks logical enough, is due to the the contents of your 'CheckBox' variable.

    The CheckBox variable does not contain the status of the checkbox (ie. ticked or unticked), it contains (is a reference to) the CheckBox object itself.

    Once you have a reference to a checkbox object, you must use the commands that Fremy has provided to interact with it. So, you use Controls.Move to move it, Controls.SetChecked to set the status of it, and must then use Controls.GetChecked to read back the status of it.

    So, Method 1, change your IF statement in the code to either:

    If Controls.GetChecked( CheckBox ) = "True" Then ...

    Or, Method 2, use Hacker's suggestion of using another variable to read the status of the checkbox, then use that variable in the If:

    cboxChecked = Controls.GetChecked( CheckBox )

    If cboxChecked = "True" Then ...

     

    NOTE: The choice of which method to use depends mainly on efficiency. If this is the only time you are going to look at the CheckBox status, then use Method 1. If you are going to look at the CheckBox status a number of times, then use Method 2. The reason for this is that it is slower for SmallBasic to find the CheckBox object and read its status than it is to see what value is stored in a variable.

     

    You can quite happily ignore the below comment, it has nothing to do with your question!

    NOTE2: I don't wish to complicate things, but there is a shortcut to checking for True or False values, although it can be less easy to understand if you don't use it well...

    If Controls.GetChecked( CheckBox ) = "True" Then

    can be shortened to...

    If Controls.GetChecked( CheckBox ) Then

     

    And similarly,

    cboxChecked = Controls.GetChecked( CheckBox )

    If cboxChecked = "True" Then

    can be shortened to...

     

    cboxChecked = Controls.GetChecked( CheckBox )

    If cboxChecked Then


     

    Saturday, March 20, 2010 11:57 AM
  • Thank you for your help Hacker2
    Saturday, March 20, 2010 2:40 PM
  • Thank you for your help Hacker2
    Saturday, March 20, 2010 2:40 PM
  • Great info Davey, it really helps newbies in understanding programing, Thank you!
    Saturday, March 20, 2010 2:41 PM
  • Great info Davey, it really helps newbies in understanding programing, Thank you!
    Saturday, March 20, 2010 2:41 PM
  • I tried to download the fremy extension and it doesn't work. I unzipped created lib in the small basic folder and but those things in it restarted and it doesn't work. any Ideas?
    Sunday, April 3, 2011 10:12 PM
  • Try un-doing what you did, then follow these steps:

    1. Make sure you have the latest version of Small Basic (0.95)
    2. Close Small Basic, if it is open.
    3. REDOWNLOAD the lib folder
    4. If the lib folder is zipped, unzip it.
    5. Copy and Paste the unzipped lib folder into "C:\Program Files\Microsoft\Small Basic\"
    6. Open Small Basic, then begin typing "FC" (a bunch of new object should pop up, like FCCliboard, FCControls, FCDialogs, and many more.


    ~~AirWaves!!~~
    Monday, April 4, 2011 1:38 AM