wywtk.com homepage What You Want To Know  Index to my pages about BBC BASIC

Saving your work in BASIC- and a little program

(Page's URL: bas1.htm)

In a moment, we need to have a rather tedious conversation about how you can save your programs (code).

But that's going to be so boring, I thought we should do a clever but simple program first.

Start the IDE, and then enter the following...

x=5
REPEAT
  PRINT x
  x=x-1
UNTIL x<1

When you run it, you get...

1
2
3
4
5

You should be able to understand most of the program... except...

Maybe you're not sure about the meaning of the meaning of "UNTIL x<1". That means "go back to the "REPEAT" again and again, UNTIL the value in the variable "x" is less than (<) 1.

I would be surprised if you can make sense of "x=x-1". (Unless perhaps you've already done some programming?)

I'll explain "x=x-1" in a moment, but I want you to think about this. Not just sit there waiting for me to give you the answer.

"x=x-1" is a little bit like the "x=5" which appears earlier.

x is a variable. We've met them before. They are places to store things.

In the first tutorial, we used "INPUT MyName$" to put something in the variable "MyName$"

In the new program, I hope you won't be surprised to learn that "x=5" puts 5 in the variable called x.

The safest way to read something like that is "x becomes 5".

Moving on: Your algebra teacher would have found "x=x-1" very confusing, wouldn't he/ she?? If x is 25 then x-1 is 24, and 25 doesn't equal 24, does it?!

In many programming languages, "x=x-1" is read as follows. We say it means "x becomes whatever x was previously, minus one. E.g. if x had 25 in it when we came to this line, then what's in x will change when the program does this line. After the line was been done, x would hold 24

Not that we've discussed that, look at the code again. Are you quite clear as to why it does what it does?

Play time over

Time to learn about saving your code

You wouldn't want to write out all of your program each time you wanted the computer to execute those instructions, would you.

There is, of course a way to save your program.

I am new to the SDLIDE BBC BASIC. I feel like I must be missing things, but at the moment I can't see all the features I would like in the provisions for saving your code.

As you read this section about saving, please don't conclude that I am an ignorant idiot! I DON'T know a lot about SDLIDE's save process... but I DO know a lot about the rest of the fun you can have with BBC BASIC!

But I've found something that works! Clunky... but it works.

BE CAREFUL. Saving things on your computer's hard drive gets you close to things which can Mess The Computer Up.

That said...

In the IDE's window, the one you used to enter the program, click on "File" in the toolbar, and in the menu that drops down, click "Save".

So far, so good!

The problem isn't so much HOW to save, but how to save it WHERE you want it!

A hard drive is organized in folders.

What follows isn't The Way It Has To Be. It is just my best shot at a way to work that risks other things as little as possible.

When you invoke save, you get something that looks a little bit like an ordinary Windows save.

It might help you to watch the "Folder" (path) specified in text at the top of the dialog.

The top icon is usually a folder, with ".." next to it. Click this, and you'll go "up" one level in the hierarchy of folders. I'd stay away from this one, if you don't know what you are doing. If you click it by mistake, just click "Cancel" to leave the Save dialog, and start again. (It can easily take you to places you shouldn't be, if you want your computer to do its other jobs the way you like them done.

The next two icons are also folder icons. They are identified as @lib$ and @usr$. These seem to operate almost like shortcuts. They DON'T entirely act like anything I've ever seen in the Windows File Explorer.

I'd stay away from clicking @usr$

Which leaves us with @lib$, which I WOULD have you click!

If the system was set up as I suggested, after clicking @lib$ you should see a folder like "Fred's Programs" on offer. (If your name is Fred, that would be the place for you to save things.) Click on that to get into "your space" on the hard drive.

To recap what we have so far, without all the advice and warnings...

When it is time to save something....
-- click File... Save...
-- in the "Save" dialog, click on @lib$
-- that should take you to a place with a folder that is YOURS.
-- click on that.

Now you are in the right place to save your program. You should see the names of programs you have saved so far.

And, good news, I think that once you've got it right once, the computer will remember where you want to save programs, and just go straight there usually.

Give your program a name. Keep it simple. Leave "Tokenized" ticked. Click Save!

So far, so good? What happens when it is time to get rid of some? Or maybe make a sub-folder within your folder? I think for these tasks, you need to use File Explorer. (If you make changes with File Explorer, they won't immediately show in the BBC BASIC Save dialog, if you have one open. Close it. Reopen it. Now, I think!, you'll see your changes.

If you ask to save something that you are working on, if it has already been saved once, subsequent saves will just happen.

If you use "SAVE AS" and try (whether by mistake or deliberately) to save something with a name that is already in use, you will be asked if you want to over-write the previous file.

WHAT WAS ALL THAT ABOUT???

That was my best shot at the "save" topic.

Happily I know a lot more about "everything" else.

For instance!...

Why did we bother to save our program? So we could re-load it easily at some future time. And we can!

You just click on File/ Load in the IDE, navigate to YOUR folder, and click on the program you want to load into the IDE.

Whew! See? I TOLD you that the Save hassles were just an isolated glitch.



A few words from the sponsors...

Please get in touch if you discover flaws in this page. Please mention the page's URL. (wywtk.com/prgm/bas/bas1.htm).

If you found this of interest, please mention in forums, give it a Facebook "like", Google "Plus", or whatever. If you want more of this stuff, help!? There's not much point in me writing these things, if no one feels they are of any use.



index sitemap
What's New at the Site Advanced search
Search tool (free) provided by FreeFind... whom I've used since 2002. Happy with it, obviously!

Unlike the clever Google search engine, this one merely looks for the words you type, so....
*    Spell them properly.
*    Don't bother with "How do I get rich?" That will merely return pages with "how", "do", "I"....

Please also note that I have four other sites, and that this search will not include them. They have their own search buttons.

My SheepdogSoftware.co.uk site, where you'll find my main homepage. It has links for other areas, such as education, programming, investing.

My SheepdogGuides.com site.

My SkyWoof.com site.

My site at Arunet.




How to email or write this page's editor, Tom Boyd. Please cite page's URL if you write.


Valid HTML? Page has been tested for compliance with INDUSTRY (not MS-only) standards, using the free, publicly accessible validator at validator.w3.org.

AND tested for... Valid CSS?



(eXTReMe tracker icon) Why is there a script or hidden graphic on this page? I have my web-traffic monitored for me by eXTReMe tracker. They offer a free tracker. If you want to try one, check out their site. Neither my webpages nor my programs incorporate spyware, but if the page has Google ads, they also involve scripts. Why do I mention the script? Be sure you know all you need to about spyware.

....... P a g e . . . E n d s .....