ARTICLE #4 — STRINGS: THE XL POWER EDITION (Part 1)
Now we’re at the article that most inspires me but also gives me the most dread. Believe it or not, I am excited to work with strings. Making characters move up and down, left and right, changing the text to its inverse counterpart and then back again, even making them fall off the top of the screen only to bounce right back up. That’s real entertainment.
Yeah, I know I need to get out more. BASIC is an old language for sure, but it’s still important. It’s a language that takes your brain and makes it engage. It opens pathways that haven’t been used in a really long time, and it creates new futures that you haven’t even dreamt of yet.
As you discover new programs you will be able to show that family member or that neighborhood learner, that you just created a rocket out of letters and then shot them from the bottom of your screen all the way to the top right corner. You amaze your family, but honestly, you amaze yourself just as much.
Let’s start our journey to learn about the differences that string functions in OSS BASIC XL offer us. Atari BASIC is still foundational, and now we are going to build on that foundation. So what do we know? We know that strings are simply a bunch of characters in a group. These can be numbers, letters, or whatever, so pretty much anything inside quotation marks. To illustrate this, I’ll show
you examples of things we can do with show you OSS BASIC XL.
Years ago I enjoyed books like The Waite Group’s Turbo C Bible. Not because it was so BIG, but because they had examples for almost everything. They gave me small programs that helped me learn by doing. Small programs I could start with that would then fuel my imagination to generate code and help me make programs that I was proud of.
That is what I am hoping to do for you as we’ll provide you with small code that works. And that you can take and place into your own programs. As mentioned before, a string is really just characters stuck between quotes. In the example below, we name a variable and toss a dollar sign on the end so BASIC knows it’s text. We do this so that gives our BASIC language application a clue on how to treat the text inside that variable, and this essentially tells BASIC that it’s to be treated as text not numbers.
STRING1.BXL
05 GRAPHICS 0
10 NAME$="ATARI XL"
20 PRINT NAME$
In the example above we define the word NAME$, and then place the string “ATARI XL” inside it. Makes sense so far? To picture what’s happening, imagine you and I walking through Ikea and picking up a single shelf so we have a place to put things. (See picture) As you see it’s one long shelf, with 8 compartments. Now that our shelf is built, we are able to put our prize possessions on them so each shelf gets one item. A book, a figurine, a picture and 5 more items.
This is exactly like what we just did, we defined NAME$ for “ATARI XL” each of those letters will fill up a spot. It’s the same as our Ikea shelf, just virtual or rather in the NAME$ variable. Atari BASIC and OSS BASIC XL are very similar. However they do have some differences as well, mainly in performance, memory handling, and the additional features BASIC XL brings to the table, additional string functions, FAST mode, and structured programming tools. One of those features is the automatic DIMension command that we alluded to in the Ikea example. When using Atari BASIC we need to let it know that we will be using up 8 characters for a string. This is done by using the DIM statement. And yet OSS BASIC XL allows us to not worry about this and automatically sets up our string to use up to 40 characters. See the code below. (Coming Soon)
NOTE: THIS PAGE IS UNDER CONSTRUCTION. THANKS FOR YOUR PATIENCE.
- REPRINT
- PORTLAND ATARI CLUB
- SEPTEMBER 1985
- AUTHOR: MIKE FULTON
- SUBHEADINGS & GRAPHICS ADDED BY ATARI BASICS