Share via


Find - Small Basic's Search Feature and its Importance to New Coders

Being bitten by the programming bug can be a dizzying experience. You are coming to grips with the ability to bend the most complex and powerful machines ever built to your will. You begin to notice that computers are everywhere. You start seeing new places for computers. You start having ideas that no one ever had before. You are discovering that you are in fact learning a super power.

You are also coming to grips with the insanity of the cryptic hieroglyphics that is program code. There are only fifteen words that you understand, and they only sort of do what you think they should. All the rest is this hodge-podge of abbreviations and acronyms sprinkled liberally with dots and parenthesis; looking like some deranged cross between an English poetry assignment and the worst solution to an Algebra problem of all time.

You could get your feet wet by using one of the block based programming environments -- Scratch, Hopscotch, and AppInventor to name a few. But the blocks don't help much when it comes to understanding how the parts of a program work together. Plus, the blocks feel confining; like you are being limited in some way.

Small Basic to the rescue. Its colorful editor and big friendly run button go a long way making those early steps as frustration free as possible.

But there is still all that code to deal with. Did I name the variable num, or number? What was the name of the GraphicsWindow command? Was it Timer or Clock that let you get the current hour? All of the examples are great, when you can follow them. This one has 1500 lines of code, and this variable here seems to be important to the animation, but right here in line 397 it isn't doing anything. What's up with that?

This is where Search sweeps in to save the day. Being able to search is one of those special abilities. Vital to newbies in that it lets you learn from example. That variable you were looking at is used in 67 different places. Knowing where it is and what it does at each of those locations is vital to following what is going on in an example. Even for veterans, having a search feature integrated into a compiles editor is vitally important. I couldn't count the number of times I worked my way out of a logic puzzle by searching back and forth though the code I was struggling with. Even back in the olden days, I never used the editor built into the BASIC interpreters. It was always worth the effort of loading up an outside editor with its search features (Borland's Sidekick was my favorite).

Actually, Small Basic has two very powerful search features: The obvious search function from the right-click context menu, and the more subtle auto-highlight feature built into the editor.

The first is the straight forward search. When you want to find something, right click in the editor and choose "Find". A little dialog pops up to let you type in what you are looking for. Even handier, if you have anything currently selected, that text is automatically filled into the edit box. The search is not case sensitive, so you do not have to worry about matching what you are looking for exactly.

When you hit enter or "find" Small Basic searches forward in your document until the first match for your text. The editor is repositioned to the matching text, the text is selected, and the cursor is positioned after the selection. If the first hit isn't what you're looking for, you are not required to launch the search again. Simply hit the F3 key and the search will pick up at the cursor and continue until the next match. Reached the end of the file? No worry, the search automatically picks up at the start of the document. And the auto select is really nice when you are doing replacements. Simply copy the new information to the clipboard (Cntrl-C) and quickly alternate between F3 and paste (Cntrl-V).

When you are trying to remember the name of a command, where you incremented that counter, or find all the places where you set that flag, the search function is your little buddy, saving you an eternity of time in one and two minute increments.

The more subtle auto-highlight can be even more powerful in its own way. This one is straight forward to use. Simply select some text in your code. When you do, every occurrence of that text is automatically highlighted in yellow no matter where it might be in your code.

This option is really amazing when you are gazing at an example, or trying to get a feel for someone else's code. You can quickly flip through hundreds of lines of code taking note of how often a command or a subroutine is used, tracking the location of variables, or trying to un-puzzle a particularly puzzling piece of code.

If you have the nack, programming can be the most involving and entertaining past time ever invented. The trick is getting over the initial learning hump. Nothing makes that easier than analyzing other people's code. And nothing makes that analysis easier than knowing how to make good use of the search tools.


See Also