Skip to main content
Despite the fairly recent addition of real functions and subs to the language, Liberty Basic still pushes you to use the old gosub/return construct. This pressure is not obvious until you're actually writing programs.

Let's see how the pressure builds:
  1. Parameters passed to a function or sub are "by value". This means that a copy is made and no changes can be made to original variable in the function call.

  2. Global variables are not visible in a function or sub with the exception of arrays, structs, handles and system variables.

  3. Sometimes you need to return more than one value.

  4. Using single-dimensioned, 1-element arrays as global variables is ugly.

  5. The cleanest solution is to make the code global as a chunk of gosub/return code.

This might be a partial answer to the question I had about why so many Liberty Basic programmers keep on using this construct instead of switching entirely to functions and subs.

There are a few things that require functions -- recursion and useful code libraries.

Comments

Popular posts from this blog

BASIC turns 50

Well, the BASIC language actually turned 50 on May 1, 2014, and I'm very late to the party. Born at Dartmouth in 1964 (along with the first commercial time sharing), here is the university's tribute page . There is even a great 38 minute documentary that they made for the occasion. 10 PRINT "ENJOY" 20 GOTO 10

Tiny Basic tinkering

One of the examples on the Run Basic website is a port of Tiny Basic . It's fun to play with and is very much like the interactive, command line Basics found on early personal computers. In fact, I think Tiny Basic was the dialect used on the TRS-80 Model 1. I'm currently working on modifying Tiny Basic to run the Sieve benchmark. Tiny Basic needs two things: profiling and array support . I've already added profiling support for the RUN command. Tiny Basic now displays the running time of a program in milliseconds. The last step is to add array support. Tiny Basic only supports the numeric variables 'a' to 'z'. I'm adding a single array to the environment in order to port the Sieve program. The array will be called a(). I will post the modified Tiny Basic code to the Run Basic Programming Wiki when finished. The whole point of this exercise, however, is to see how fast the Tiny Basic interpreter runs the Sieve benchmark and compare it to the others i...

Run BASIC Hosting Service Launched

The new Run BASIC hosting service launched at midnight! Please visit http://runbasichosting.com for more details. Monthly and annual subscriptions are available. Run BASIC , a product by ShopTalk Systems, is a tool that makes it easy to create your own web applications. No computer science degree required . Run BASIC Hosting is a service that makes it easy to deploy your applications to the Internet. No IT experience required .