Quick Tips

  This new section is designed to give you super-quick insights as to how to improve the way you use RB. Unlike the Tips section, these tips are super-short, and don't come with lots of screenshots and a tutorial.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26

1
 Close the properties window when you're simply editing code. It'll make RB much more responsive—epsecially on older machines. Same thing for the colors palette.

2

 Write your code, and then add the variables section at the top. If you make the variables first, you'll wind up adding more, so you'll need to switch back up anyway. Adding them to a routine after writing it is just a useful time saver

3

 If you find that you'll be using a piece of code quite often, just make it a method. This won't speed up your program any, but it will make it a lot easier for you to read, write, and modify.

4

 Being object oriented is a good idea—after all, that's the type of language RB is. But keep in mind that this is only a good idea to a certain extent. For example, if you're going to be using a lot of toolbar buttons, go ahead and make a new canvas subclass. However, if you're only going to be using one, just put all the code directly into the canvas that will be the button. This will keep your from having dozens of classes in your project—something that can become confusing VERY quickly.

5

 RB crashes. In fact, it crashes a lot. So, when you're testing your program, be sure to save very often. A good idea is to teach yourself that the key combination to run a program is Cmd-S-R, not just Cmd-R.

6

 When you're making a multiple column listbox, be sure to refresh the window and check the column placements (see picture) by clicking the windowshade button twice. This gives you a better idea of how the columns will be placed–a much better system than the previous guess-and-check setup.

7
 When you're using the clipboad, it takes four lines to get text from it: dim c as clipboard, c=new clipboard, s=c.text, and c.close. However, you can compress all these into one measly line! Just make it s=(new clipboard).text. It works!

8

  Feel free to set breakpoints when you're writing code. They let you stop the execution of code at any point, and check what values every single variable holds–info that can often tell you what the problem is.

9

 Far to few people know that you can press Command-Shift-Period to go back to the debugger no matter what RB is doing. So, if you get stuck in an infinite loop, you can always escape without force-quitting. Now you know.

10

 Use exceptions! If you're getting lots of NilObjectExceptions, you can always add "Exception NilObjectException" to the bottom of your code, and RB will execute the code following it–instead of quitting your program.

11

 Get your program working first. Optimize later. This simple strategy is something a lot of people don't use, and it makes writing your program much, much easier.

12
   In the window editor, you probably know that when you're dragging a control, it snaps to relevant spots. However, if you have a window with a ton of controls, dragging becomes incredibly slow. So, always keep in the back of your mind that you can hold down the Command key as you drag to temporarily disable this snapping behavior. You'll be shocked at just how incredibly quick and smooth dragging is.

13

  When working with a canvas control, flickering is your greatest enemy. It's easy enough to avoid though. Instead of drawing directly to the canvas, first draw to a picture object, and then draw that picture to the canvas. Goodbye, flickering.

14

  Personally, I think that RB's code editor is an overly graphical piece of junk. However, it does offer a very convenient use of contextual menus. Just control click the code editor, and voila! A complete hierarchial popupmenu of every event in the window/module/class.

15

  When you're writing a program, you'll often need to put in a quote. Usually, you'd just write chr(34), but there's a better way. Just type """. Yes, it looks wierd, but it works great.
16

  It's widely accepted that using the Goto command in langauges like C is bad style. There are much more logical ways to do branching. However, RB also has an undocumented goto command, and it can be handy in a pinch. This code only makes the computer beep twice.

beep
Goto NextLine
beep
NextLine:
beep

17
   Remember, pressing Option-Tab when a window is selected in the project window opens up the code editor for it—without you having to open the actual window. Pressing Option-Tab when nothing in a window is selected makes the code editor open without anything expanded (often a useful tool).

18

  When making a control array, always make the first item in the array, give it a descriptive name, and an index of zero. Then, copy and paste for new items in the array. Don't option-drag, as this will create controls that aren't in the array.

19

  If you have an variable of type object, and you know that it's a control, you still can't access the properties of that variable that are specific to the control. This is because the variable is an object, and not a control. However, you can make it a control (for this example, it's a PushButton) using typecasting. If the variable is obj, then this changes its caption: PushButton(obj).caption="Hello!"

20

  If you have a multiple column listbox, and you're adding rows, you probably endlessly type listbox.listcount-1. However, a listbox's LastIndex property always returns the last item's actual index. I never knew about this, and I suspect that I'm not the only one...

21

  When you make an application, always remember to add an Application class to it. Be sure to put code in the NewDocument, and OpenDocument sections, or your application won't meet Apple's requirements (the required AppleScript suite). Also, don't forget to give your app a creator code before compiling.

22
  If you want your program to open a type of file when it's double clicked, be sure to check the "document icon" box in the File Types dialog for that particular file type.

23

  In the reference, if you know what you're looking for, immediately click the Alpha button. You might even want to give it a keyboard shortcut using a macro utility (Cmd-Opt-A perhaps?)

24

  Whenever you're writing a program, and are doing a lot of editing, remember that RB has an infinite undo buffer. You can undo as many steps as you want, and the redo them again if you feel that its neccesary.

25

  If you plan on distributing a built application, give it a large amount of RAM in the "Build Application…" dialog. Then, launch the compiled program, quit it, decrease the prefered memory size, run it again, and so on. Do this until you get a crash. That's how much RAM the app needs.

26

  If RB seems to be giving you the wrong answers to math problems (ie, 50000*20000=-5894), then try adding ".0" to all the numbers involved. 50000.0*20000.0 will give you the right answer.