Installing Chipmunk BASIC on CentOS 7
Back To BASIC – Chipmunk BASIC 3.1 on CENTOS 7
Back in December of 2014, I posted an article where I converted a BASIC program from the 1982 Commodore 64 Users Guide and converted it to a BASH script on CENTOS 6.5, you can read the article by clicking here (https://www.catracing.org/hendrb/bash-script-guess-number/). Month after month this has been one the most popular posts on my blog. So Ibegan to wonder, instead of converting the program to BASH, what options are there for us to actually program and run BASIC programs natively under LINUX.
When I primarily used a Mac computer, there was a version of BASIC written for MacOSX called Chipmunk BASIC. So off I went to Google, and found the authors web page. Sure enough there is a compiled version for LINUX. So just what is Chipmunk BASIC? Direct from the authors website, “ Programming Language. Chipmunk Basic presents a vintage traditional command-line console programming environment, and supports a very simple, old-fashioned, and easy-to-learn Basic Programming Language syntax.” This sounds like what I am looking for!
There are a couple of catches. one is that you have to download and install the program and the MAN pages manually. No sweat, I am up for the challenge! The second catch is that this version of BASIC must be run in a GUI under X Windows. Once XWindows server has been installed and started, you can access Chipmunk BASIC from a terminal or remote session however.
Actually, it turned out to be a very very simple process. Let’s take a look by installing it on my demo virtual box.
First lets see if we have some prerequisite utilities installed that will allow us to download and uncompress the BASIC program files. An easy way to check to see if you already have these utilities installed is to see if the MAN pages are installed
$ man wget
If the man page displays then the utility is installed.
If the utility is not installed (As is the case of unzip), you will receive an error message, which is displayed below when I try and view the MAN page for unzip.
So lets go ahead and install unzip using the yum command.
$ sudo yum install unzip
You must also have a desktop environment installed, so if you installed CENTOS 7 using the minimum install and only use via a console, or a remote shell. We will install GNOME Desktop now.
$sudo yum groups install “GNOME Desktop”
You can either start the X Windows Server now, or after we install Chipmunk BASIC install. To do this, simply execute the following command.
$ startx
We are now ready to download Chipmunk BASIC, Cd to the directory that you want the file to be downloaded to, I have a subdirectory in my HOME directory called Downloads, which I will make sure I am in and if not I will change to that directory.
$ pwd
/home/username
I am not in the correct directory, but since I am in my home directory, a simple cd to Downloads will work.
$ cd Downloads
[username@cr-demo Downloads]$
As you can see, the CD was successful. If I was somewhere else on the system, say /etc. I can easily get to my home directory using the ~ shortcut.
[username@cr-demo etc]$ cd ~
[username@cr-demo ~]$ pwd
/home/username
Example II:
[username@cr-demo etc]$ cd ~/Downloads
[username@cr-demo Downloads]$
As mentioned above, to actually download the Chipmunk BASIC archive, we use the wget command, with the URL as noted below.
Example I:
$ wget http://www.nicholson.com/rhn/files/cbas367b5-linux-x86_64.zip
You will then see the following screen, and the file should be downloaded.
If you now do a directory listing, you will see your file.
[username@cr-demo Downloads]$ ll
total 180
-rw-rw-r--. 1 local_hendrb01 local_hendrb01 183652 Jun 24 2014 cbas367b5-linux-x86_64.zip
Now we must unzip the file
Usage: unzip filename.zip -d destination_folder
Since we just want the file unzipped to our current directory, we will just enter unzip filename.zip
Example I:
We now have 4 new files in our Downloads directory, you can delete the zip file using the rm command if you want to.
$ rm cbas367b5-linux-x86_64.zip
The 4 new files are
-r-xr-xr-x. 1 username groupname 335192 Jun 24 2014 basic
-r--r--r--. 1 username groupname 52635 Apr 22 2011 basic.man.txt
drwxrwxr-x. 2 username groupname 20 Dec 30 20:28 man
-r--r--r--. 1 username groupname 3412 Jun 24 2014 README
File descriptions:basic is the main basic executable, you will want to move this file to /usr/bin
Example:
$ mv basic /usr/bin
Lets also make sure that the owner and group are set to root root. Since it was unzipped under out normal user account, it will most likely show your username. Not sure if this will cause issues or not, but better be safe than sorry!
Example:
$ ll basic
-r-xr-xr-x. 1 username groupname 335192 Jun 24 2014 basic
$sudo chown root:root basic
$ ll basic
-r-xr-xr-x. 1 root root 335192 Jun 24 2014 basic
Now let’s put the man file where they belong, if we currently try and perform a man on BASIC, we will receive the following error.
EXAMPLE:
$ man basic
No manual entry for basic
How do we know where our man files are located anyway? Simply use the manpath command.
Example:
$manpath
/usr/local/share/man:/usr/share/man/overrides:/usr/share/man
Now we need to determine where the specific man page belongs, have you ever wondered what the number in parentheses means next to the command in a man page? It denotes what type of command it is. Here is a cheat sheet.
1.General commands
2.System calls
3.C library functions
4.Special files (usually devices, those found in /dev) and drivers
5.File formats and conventions
6.Games and screensavers
7.Miscellanea
8.System administration commands and daemons
So let’s go ahead and put basic in the man1 folder, change the owner to the root user and the root group.
First cd to ~\Downloads
Then let’s move the file.
Example:
$ mv man/basic 1 /usr/share/man/man1
$ sudo chown root:root /usr/share/man/man1/basic.1
Now let’ test.
$ man basic
The following screen should now be displayed.
We are now finished installing BASIC. You can now delete the files from your Downloads directory if you wish.
We are however not done with this tutorial! Why go to all this trouble, just to install a programming language, if we are not going to use it to write programs?
So let’s take the number guessing game from the Commodore Users Guide again and see how it works in Chipmunk Basic!
You can either enter the program from within Chipmunk BASIC, by entering basic at a prompt.
$ basic
Or you can enter the program in any text editor, such as vi, or nano. Like this.
So go ahead and load a text editor of your choice. Then have fun typing in the below program!
1 rem **************************************************************************
2 rem * Guess Random Number *
3 rem * Originally Published In The 1982 Commodore 64 Users Guide *
4 rem * Converted to Chipmunk Basic By: Brent Hendricks *
5 rem * Used for a programming demo for installing Chipmunk BASIC *
6 rem * on CentOS Linux 7, March 12 2016. *
7 rem * BASIC program released into the public domain. *
8 rem * Article text is copyright Brent’s World. Reproduction *
9 rem * in part of in whole may be done only with permission from *
10 rem * the author. *
11 rem * *
12 rem * Please visit Brent’s World “An American Expat Living In *
13 rem * South Korea, for this and other great articles. *
14 rem * www.catracing.org/hendrb *
15 rem ************************************************************************
20 clear
22 cls
23 gosub 120
25 input “Enter Upper Limit For Guess. “,li
30 nm = rnd(li)+1
35 cn = 0
40 print “OK, I’ve got the number.” : print
50 input “What is your guess? “,gu
55 cn = cn+1
60 if gu > nm then print “Nope! My number is lower!” : print : goto 50
70 if gu < nm then print “Nope! My number is higher!” : print : goto 50
80 print “GREAT!! You got my number!”
85 print “In Only “;cn;”guesses.” : print
90 print “Do you want to try another? “;an$
92 get an$ : if an$ = “” then 90
95 if an$ = “Y” or an$ = “YES” or an$ = “y” or an$ = “yes” then 22
110 end
120 print “**************************************************************************”
122 print “* Guess Random Number *”
123 print “* Originally Published In The 1982 Commodore 64 Users Guide *”
124 print “* Converted to Chipmunk Basic By: Brent Hendricks. *”
125 print “* Used for a programming demo for installing Chipmunk BASIC *”
126 print “* on CentOS Linux 7, March 12 2016. *”
127 print “* BASIC program released into the public domain. *”
128 print “* Article text is copyright Brent’s World. Reproduction *”
129 print “* in part of in whole may be done only with permission from *”
130 print “* the author. *”
140 print “* *”
150 print “* Please visit Brent’s World. An American Expat Living In *”
160 print “* South Korea, for this and other great articles. *”
170 print “* www.catracing.org/hendrb *”
180 print “**************************************************************”*********”
200 return
I hope you enjoyed the blog, and that you will enjoy Chipmunk BASIC. Please continue to come back for more great articles from Brent’s World.
Comments
Installing Chipmunk BASIC on CentOS 7 — No Comments
HTML tags allowed in your comment: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>