Tweak your GOOEY!

by Welopez

Shake, shake shake! Shake, shake, shake, Tweak your Gooey! Well, maybe the words don't go together, and you'll have to make your own music, but you'll discover that tweaking your gooey is not really a problem.

Now that you've moved up from other versions of basic, the biggest difference you will notice is the ability to create a Graphic User Interface, like the most popular programs written for Windows. At first, the code to display a window and add controls will seem quite strange to you, but don't let that stop you.

When you open some of the demo programs, often the first line you will see is NOMAINWIN. This means "Don't open the main window (or console)", where all programming results and responses are displayed as text. The best way to begin creating a gooey is to run fformJ10.bas from your JB sample applications. All you need to do is click on an item (called controls) on the left side of your screen (called the toolbox) to add controls to your GUI. Controls can be dragged all over your gooey, stretched vertically and horizontally, until the look of your gooey pleases you. In most cases, you can right-click on a control to adjust properties, such as caption (title), font, and other properties.

Once the appearance of your gooey satisfies you, save the template as "filename.frj." This allows you to return to the template, open it and make adjustments if you discover you want to add, delete, or change controls while designing your program.

Once you get familiar with the code used to setup your gooey and place controls, you may find it more convenient to "tweak" your gooey by simply making small changes directly to the basic program. Tweaking may be simply moving a control or resizing it by a pixel or two, just to make the gooey look more professional. Once in awhile, it will be necessary to resize a control merely because the caption or text displayed doesn't suit you. You may even want to change the extension of your control to give it a little more meaning.

Below is a demo code written for a generic gooey with several controls on it, and the parameters defining those controls. Generous REMs are included to give you an idea what the parameters are used for, and you can try changing the width, height, and location of controls just for practice.

      'Tweaking a Gooey.
      'Written by Welo, 121404

          NOMAINWIN
          WindowWidth = 550
          WindowHeight = 410
          UpperLeftX=int((DisplayWidth-WindowWidth)/2) 'Puts the Window in the center.
          UpperLeftY=int((DisplayHeight-WindowHeight)/2)

      'Set up controls for the Window. Control parameters are:
      'Type control, #window.ext, "caption", [branchto], locate, right, down, width, height.

          BUTTON #main.btn1, "CLOSE ME", [quit], UL, 20, 40, 180, 48
          BUTTON #main.btn2, "QUIT", [quit], LR, 80, 50, 75, 30
          BUTTON #main.btn3, "What's This?", [whatsThis], UR, 90, 40, 170, 48
          RADIOBUTTON #main.btn4, "I don't do anything. Try me!", _
          [null], [zilch], 20, 300, 320, 48
          TEXTBOX #main.txt2, 100, 175, 340, 80
      'Location from window corner can be Upper Left, Lower Left, Upper Right, Lower Right.
      'The RADIOBUTTON does not require a corner reference.

          OPEN "Tweaking Your Graphic User Interface" for window as #main 'Title bar.
          PRINT #main, "trapclose [quit]" 'Always include the trap to exit your window
          PRINT #main, "font ms_sans_serif 18"
          PRINT #main.txt2, "!font comic_sans_ms 36"
          PRINT #main.txt2, " I am a Gooey!"

      WAIT
      [whatsThis] 'Branch label from BUTTON #main.btn3
          NOTICE "You are wasting the day!"+CHR$(13)+"Get back to doing"+_
          CHR$(13)+"something useful!" 'CHR$(13) adds line breaks.

      [zilch] 'Does nothing except WAIT because radio buttons cannot be reset by clicking.
      [null] 'Another dummy merely to satisfy a branch label requirement. Program waits.
      WAIT
      [quit]
          CLOSE #main
          END

The Right, Down, Width, and Height parameters will probably be the tweaks you apply most often. Branch labels can easily be modified and sometimes you will want to change the text displayed to make it more meaningful to your user.

Don't be afraid to practice tweaking! No changes will be made to your program until you save it. For practice, you can save programs as program1.bas, program2.bas, etc. It is not necessary to save a program before you can run it just to see what effect your changes have made.

When in doubt, you can always go to the HELP files to learn more about the specifics of each control, and more I have not mentioned in this small demo. Programming with JB is FUN, as it is supposed to be. It will be a lot more fun if you become familiar with all those blue, orange and green numbers used to setup controls in your BAS code. Enjoy!