I made a command line personal assistant in BASIC

I am not 100% serious about this application, however, just to amuse some students I have written a personal digital assistant app in BBC BASIC for Windows.

Introducing Susan - your command line personal assistant.

Susan running in Windows 10
Susan can:

  • compose email;
  • keep you up to date with the news and weather;
  • solve mathematical expressions;
  • remember your wife's birthday;
  • search The Web;
  • run macros and scripts;
  • keep time;
  • say stuff
For the full list of features see the online help, or Susan's homepage.

The current version ( is available to download.  Should there be much interest in Susan, I'll add some new features (possibly alarms and reminders first).

I would appreciate helpful feedback through the social media links at the top right of this page. 

Robot arms with FUZE

I recently bought a couple of Raspberry Pi FUZE computers with Robot arm kit.

FUZE powered Raspberry Pi with Robot Arm kit available on Amazon right now.

Check it out on Amazon: FUZE powered by Raspberry Pi (RPi V2) - FUZE-T2-R Teach Kids to Code Unit English Keyboard with Printed Project Cards & Robot Arm Kit - Black/Red

Thanks very much to Nathan and Sam for assembling the two arms.

The FUZE computer is very similar in feel to the old BBC Microcomputer, but it is a Raspberry Pi under the hood.  It does all the usual Raspberry Pi things with the addition of FUZE BASIC pre-installed: a dialect of BASIC that allows you to program the robot arms.  The feel of the user guide is very similar to the old BBC Microcomputer user manual.

The robot arms have five motors that can be activated individually.  These motors control the rotation of the base, the shoulder joints, elbow, the wrist and the gripper.  You can program it to pick up objects and move them around.  One project I intend to do is to use one of my robots as an automatic air freshener.  Every few hours the gripper will squeeze a can of freshener into the room.

Code to control the robot arm

When you first get your robot set up you will want to start to control it.  The code that comes with the FUZE BASIC instruction book is rather limited.  I wanted finer control over the start and stop of the motors as well as the ability to control several of the machine's motors at once.

Presented here is my first attempt at some control code for the robot should it be of use to anyone.

You use the cursor keys to control the body and shoulder; Q/A/W/S for the wrist and elbow; Z/X for the gripper; ENTER to toggle the light, and SPACE for 'emergency stop' (you will need it!).  Type the program into the FUZE BASIC editor, or copy from this page and save it as 'robot.fuze'.  If in doubt contact me and I'll send you the file for your pi.

REM version
PROC resetArm
PROC displayInstructions

leftBodyOn = FALSE
rightBodyOn = FALSE
upShoulderOn = FALSE
downShoulderOn = FALSE
upElbowOn = FALSE
downElbowOn = FALSE
upWristOn = FALSE
downWristOn = FALSE
openGripperOn = FALSE
closeGripperOn = FALSE
lightOn = FALSE

key = INKEY
SWITCH (key)
REM right cursor - move body right
CASE 331
IF rightBodyOn THEN
armBody (0)
rightBodyOn = FALSE
armBody (1)
rightBodyOn = TRUE

REM left cursor - move body left
CASE 330
IF leftBodyOn THEN
armBody (0)
leftBodyOn = FALSE
armBody (-1)
leftBodyOn = TRUE

REM space - reset
PROC resetArm

REM up cursor - move shoulder up
CASE 332
IF upShoulderOn THEN
armShoulder (0)
upShoulderOn = FALSE
armShoulder (1)
upShoulderOn = TRUE

REM down cursor - move shoulder down
CASE 333
IF downShoulderOn THEN
armShoulder (0)
downShoulderOn = FALSE
armShoulder (-1)
downShoulderOn = TRUE

REM W - move elbow up
CASE 87, 119
IF upElbowOn THEN
armElbow (0)
      upElbowOn = FALSE
      armElbow (1)
upElbowOn = TRUE

REM S - move elbow down
CASE 83, 115
IF downElbowOn THEN
armElbow (0)
      downElbowOn = FALSE
armElbow (-1)
downElbowOn = TRUE

REM Q - move wrist up
CASE 81, 113
IF upWristOn THEN
armWrist (0)
upWristOn = FALSE
armWrist (1) 
upWristOn = TRUE 

REM A - move wrist down
CASE 65, 97
IF downWristOn THEN 
armWrist (0)
downWristOn = FALSE
armWrist (-1) 
downWristOn = TRUE

REM Z - close gripper
CASE 88, 120
IF closeGripperOn THEN   
armGripper (0)
closeGripperOn = FALSE
armGripper (-1)
closeGripperOn = TRUE

REM X - open Gripper
CASE 90, 122
IF openGripperOn THEN
armGripper (0)
openGripperOn = FALSE
armGripper (1)
openGripperOn = TRUE

REM ENTER - light on/off
IF lightOn THEN
armLight (0)
lightOn = FALSE
armLight (1)
lightOn = TRUE



DEF PROC resetArm
armBody (0)
armShoulder (0)
armElbow (0)
armWrist (0)
armGripper (0)
armLight (0)

DEF PROC displayInstructions
fontScale (2, 2)
INK = Red
PRINT "The Robots are revolting!"
INK = White
hvTab (0, 2)
INK = Green
INK = White
PRINT "Cursor keys"
INK = Green
PRINT "WRIST up/down"
INK = White
INK = Green
PRINT "ELBOW up/down"
INK = White
INK = Green
PRINT "GRIPPER close/open"
INK = White
INK = Green
PRINT "LIGHT on/off"
INK = White
INK = Green
INK = White

I thoroughly recommend the FUZE or the robot arms (which will work with your current Raspberry Pi).  The robot will take about three hours to assemble and you will need a small screwdriver, a set of small pliers and a four 'D' batteries.

My Library

Are you sitting comfortably?  Good, then I will begin.

Once upon a time I used to loan books to friends.  Then I would forget all about it and spend hours searching for a book that was never returned (I am equally guilty at not returning books).

One solution is to take a photo of your friend holding the item and keep it on your phone so you don't forget.

I am, however, finding this app very useful at present.

My Library from smartcodeworks is surprisingly fun to use and makes managing your book library painless.  You simply scan the bar-code on the back of your book and the app retrieves the vital information and stores it in your phone.

Some of my books.

I recently moved house a couple of times, and today I got two cardboard boxes with about one hundred books between them out of storage. After evicting a spider, who had set up home in one of the boxes, I got to work scanning.  It didn't take long to scan all books into the app.

My Library app view on my awesome Lumia 950.

The My Library app has some solid features.

  • Scan by bar code.
  • Books or CD (but not DVD)
  • Manual entry.
  • Search title/author.
  • Live tile.
  • Back up to OneDrive.
  • Export to Excel spread sheet.
  • List by author/title/category.
  • Book reviews and price guide.
You can edit each entry, for example, the 'status' of the book can be set from 'purchased' to 'loaned' (so you can keep track of who has your books), 'wishlist' (you saw the book in a bookshop and plan to get it in the future, and 'borrowed' (it wasn't your book in the first place.

You can also write your own comment on each book.

The app copes well with bar-codes that don't belong to books. Here I am scanning a carton of semi-skimmed milk.

Stuff I would like to see

  • The ad-free version currently costs £2.29, but I won't be upgrading until there is a Windows 10 desktop app.
  • A search by author or title feature would be useful too. Currently it searches both.
  • Some different skins would be preferable as the main 'wood' themed one is rather dull. Just a plain dark theme would be good.
  • The ability to look up a book by ISBN on eBay. My dad wants this feature so he can keep track of the possible value of his rare books.  Last summer I wrote him a JavaScript app that does this, however it lacked the 'lookup by bar-code' feature of 'My Library' phone app.
It's worth how much?!

Old books without bar-codes need to be entered manually. :-(

Next steps for bibliophiles would be to look at other book sharing technology.  There is Google books which although I have never explored it fully allows you to share the information about books you have uploaded to your Android devices to be shared on G+. I have also stumbled upon Shelfari by Amazon (which may be less evil than Google), but that's another story for another day.

Bug squashed in data logger

Ooops!  I've just spotted a bug in my Raspberry Pi Sense HAT datalogging script.  The 'time' command causes the system to crash.  This is because you can't concatenate a date/time object to a string without first converting it to a string.  

The code should read:

    def do_time(self, args):
        """\n>Displays the current date/time"""

It is all fixed now.

Four weeks with #Microsoft Band 2

I have been wearing a Microsoft Band 2 for four weeks now.  This post is a tour of the features I have been using.

You can get a good deal on microsoft band at Amazon:
Microsoft Band 2 - Medium
Microsoft Band 2 - Large

The 'me' tile.
The 'me' tile shows the time at a glance like any good watch should.  You can also get the date, calories burned, steps taken, heart rate, flights of stairs climbed, steps taken and distance walked.

Swiping left brings up your tiles.  Maximum thirteen tiles can be pinned and three can be viewed at any one time.  Someone has just sent me a message - wooo! 
Tiles I have been using regularly in the order I have them pinned:

  • Messaging.  Lets me view the SMS arriving on my Lumia 950.  There is even an option to reply from this tile.
  • Facebook Messenger.  Lets me view my Messenger conversations.
  • Email. I get a lot of email. I can see from a glance if important messages are arriving without getting my phone out or logging into a computer.
  • Cortana.  This tile gives me regular messages from Cortana and lets me set reminders on the go by speaking into the microphone.
  • Calls. This lets me know who is ringing me with options to auto reply with SMS if I happen to be in a meeting or driving.
  • Calendar.  This is a digest of all my calendars and is very useful for seeing what is coming up next.  Notifications arrive for whatever reminders I may have set.
  • Sleep.  This tracks my sleeping patterns.  More about this later.
  • Alarms.  This tile lets me set alarms, reminders or run a stopwatch.  Useful for playing Cosmic Encounter.
  • Weather. A weekly forecast for my current location.
  • UV. Ultra violet light tracker.  Presumably useful for when I am sun bathing, but currently completely useless in the English winter.
  • Facebook.  See who is liking who.  Who's posting photos of their dinner.  Never miss a thing!
  • Twitter.  See who is following me.
  • Notes.  This is a third party app called 'Band companion'.  The notes app allows me to send notes from my Lumia 950 directly to my band.  It is the equivalent of writing notes on my hand with a biro, expect less messy.  This app also has features for remote camera shutter control and a battery indicator.
Stuff the band does but I don't use

I don't play golf.  I think that it is a massive waste of land.  In my opinion golf courses should be replaced with trees.  If we played cricket the same way we played golf we would play one over and then walk to another pitch to play the next one.  It just wouldn't be allowed.  Anyway, with that rant over, if I did play golf I would want my band 2 with me.  Not only does it know which golf course I am on using the GPS, it can also keep track of my score.

Most of my evenings are spent playing with computers, or other such geeky pastimes, but should I feel so inclined the band comes packed with apps for managing your workout, bike rides and runs.  It is not waterproof, so there is no functions for swimmers. 

The dashboard

As useful as the band is as a productivity tool, it really comes to life when you log into the Microsoft Health Dashboard.  Here you can track your steps taken or calories burned; organise workouts or compare yourself to other users.

Here was may last seven days in terms of how far I moved.  Verdict: could do better.

Here is my sleep record for the past several weeks. You can either tell the band that you are going to bed or the band will auto detect your sleep when it notices that you aren't moving very much and your resting heart rate has decreased.  I haven't had much sleep lately. Verdict: I'll catch up at the weekend.

The dashboard also gives you some useful comparisons with other people who are like you.  Here I can compare my resting heart rate and sleep efficiency with others in my age group.

Stuff the band 2 needs
I use Wunderlist a lot.  It would be useful if I could view my lists on my band.

Final verdict
Pretty awesome.  I love the health tracking element which is very useful even for someone like me who doesn't exercise much for fun.  The battery life could be improved.  I will get about 48 hours of constant use, but I'm lucky if my Lumia 950 will keep up with that.  There are some other features I didn't mention like the Bluetooth music controls which allows you to play and skip the music on your phone.  I don't have music on my phone - I keep it on my Raspberry Pi.

Plus one Geek Experience Point to Microsoft (who really don't need it) for the Band 2.

#microsoft #band2

Programming in the classroom using SHAPES

Thanks to Rachel Bush for producing some fabulous resources for using SHAPES in the classroom.

Rachel's resources are suitable for year 5-7 programmers (ages 9+)
SHAPES is a programming language for teaching kids the basics of computer programming and coordinates. They learn through creating pretty images using programming statements.

SHAPES is an easy introduction to computer programming.  It's tried and tested with kids and they love it.

Coded with SHAPES

Find all our SHAPES posts.
Open Rachel's SHAPES resources.
Open the SHAPES download page.

Raspberry Pi Sense HAT data logger

I have been working on a command line temperature/humidity/pressure data logger for my Raspberry Pi Sense HAT.

You can get the Python code from this folder.

The data logger command line running on the Raspberry Pi 2 showing all available commands.

The script provides the following commands for accessing the Sense HAT sensors:

  • temp (gets the current temperature)
  • pressure (gets the current air pressure)
  • humid (gets the current relative humidity)
  • time (gets the current time/date)

You can also set up a 'log' which will automatically log data from the sensors to a csv file. The duration of the log run and the time interval between measurements can be set through commands.

This log shows the change in temperature and humidity over a few hours.
Running a log.

Sense HAT data logger 01

OK it is day two with my Raspberry Pi Sense HAT and here is my first attempt at a data logger program.  You can read about my first day with Sense HAT and the problems I have encountered so far.

This program simply logs the time, temperature, humidity and air pressure every six seconds.  The data is saved into a text file for later inspection.

Is it getting hot in here? Actually this is the temperature of the air just near the CPU (I am actually really cold right now in my hovel - please send warm jumpers).

I have read the output file over my home server and produced this graph in Windows 10.

# Data Logging App
# Logs the time, temperature, humidity and air pressure
# Tim Street
# 2015-01-14
# version history
# ---------------
#   logger class with time, temp, humidity and pressure

from datetime import datetime
import time
from sense_hat import SenseHat

FILE_PATH = "log.csv" # file path used to log data

class logger:
    """ A logger provides methods for reading the sensor values and saving to a file """
    def __init__(self, filepath):
        self.__time = 0
        self.__temp = 0
        self.__humidity = 0
        self.__pressure = 0
        self.__sense = SenseHat()
        self.__savepath = filepath

    def __str__(self):
        """ String representation of logger """
        return "Time:\t\t"+str(self.getTime())+"\nTemp:\t\t"+str(self.getTemp())+"C\nHumidity:\t"+str(self.getHumidity())+"%\nPressure:\t"+str(self.getPressure())+"mb"

    def __toCSV(self):
        """ Retuns a CSV file line """
        return str(self.getTime())+","+str(self.getTemp())+","+str(self.getHumidity())+","+str(self.getPressure())+",\n"

    def __setTime( self ):
        """ sets log to current date and time """
        self.__time = datetime.today()

    def getTime(self):
        """ returns the date and time from the log """
        return self.__time

    def __setTemp(self):
        """ logs the current temperature """
        self.__temp = self.__sense.get_temperature()

    def getTemp(self):
        """ returns the temperature """
        return self.__temp

    def __setHumidity(self):
        """ logs the current humidity """
        self.__humidity = self.__sense.get_humidity()

    def getHumidity(self):
        """ returns the humidity """
        return self.__humidity

    def __setPressure(self):
        """ logs the current air pressure """
        self.__pressure = self.__sense.get_pressure()

    def getPressure(self):
        """ returns the pressure """
        return self.__pressure

    def update(self):
        """ updates all sensors """

    def save(self):
        file = open(self.__savepath, 'a')
        file.write( self.__toCSV() )

log = logger( FILE_PATH )
while True:

The program needs to append a comma separated file "log.csv" which you can create yourself, or run the script below to create it automatically.

# creates a new output file
file = open("log.csv", "w")
file.write("time,temp /C,humidity /%,pressure /mb\n")

Features I intend to implement next:
  • Command line interface
  • Multiple logs by name
  • Option to toggle sensors on off
  • Variable log sleep time
  • LED matrix icons for each state - 'ready', 'sensing', 'writing', 'sleeping'
Well that's it for now, but do check back soon!

#raspberrypi #pi #sensehat #python #datalogging

Hello Sense HAT

Yesterday I bought one of the wonderful Sense HAT boards from element14.com. The Sense HAT provides an 8x8 LED maxtrix display, accelerometer, gyroscope, magnetometer, air pressure sensor, temperature sensor and air pressure sensor, as well as a small joystick.  Basically a bundle of sensors that plug in directly to the GPIO pins on your Raspberry Pi. They are well worth purchasing should you wish to upgrade your Pi.  I would like to set up a data- logging weather station, however I have only had time for a brief experiment with the features so far.

Follow link for buying options.

Setting up is very easy: the board just plugs straight in and the online instructions are very easy to follow. I suggest you download the Sense HAT Python API or you wont get very far with Sense HAT.

Listed in this post are two of my 'hello world' programs.

Space Invader

I am your father...
This program creates a space invader tile on the LED matrix display and flashes the colours.

# Displays a space invader on the LED panel
# and flashes the colours a bit
import time
from sense_hat import SenseHat

def getInvader():
    return [
            O, O, X, X, X, X, O, O,
            O, X, X, X, X, X, X, O,
            X, X, O, X, X, O, X, X,
            X, X, X, X, X, X, X, X,
            X, X, X, X, X, X, X, X,
            O, X, X, O, O, X, X, O,
            O, X, X, O, O, X, X, O,
            O, X, O, O, O, O, X, O

sense = SenseHat()

while True:
    for r in range(255, 0,-5):
        for b in range(0, 255,5):
            X = [r, 0, 0]
            O = [0, 0, b]
            sense.set_pixels( getInvader() )


Displaying a scrolling display of the sensor outputs.
This program simply displays a continuous scrolling readout of the temperature and air pressure. The colour of the display depends on the current air temperature.

# Displays the temperature and pressure
# on the LED panel
import time
from sense_hat import SenseHat

sense = SenseHat()

while True:
    # find temp in celsius
    t = sense.get_temperature_from_humidity()
    # find temp in fahrenheit
    f = ((t/5)*9)+32
    # find pressure in mb
    p = int(sense.get_pressure())
    # find display colour
    # this depends on the current tremperature
    if t<12:
        myCol = [ 0, 200, 230 ] # a cold colour
    elif t<22:
        myCol = [ 0, 220, 0 ] # a neutral colour
    elif t<29:
        myCol = [ 200, 100, 0 ] # a warm colour
        myCol = [250, 0, 0 ] # very hot colour
    #display message
    sense.show_message( str((int(t*10))/10)+"C   "+str((int(f*10))/10)+"F    "+str(p)+"mb", text_colour=myCol)

Sense HAT reading the wrong temperature

One problem: the temperature sensor is positioned on the board so that it is directly above your Raspberry Pi processor. This means that it picks up the ambient air temperature as well as some of the heat from the processor. Positioning the Pi vertically along its widest edge alleviates some of this problem due to better convection however not altogether.

I do not have a decent thermometer to test the callibration, however I suspect that the Pi can become inaccurate by 12 degrees Celsius or greater.

The manufacturers make no apologies for this.

One solution is to make a heuristic algorithm (a fudge-y guess) at the temperature, however this is not very satisfactory.

Another solution will be to position the Sense HAT further away from the motherboard using a 40 pin ribbon cable and GPIO cobbler. I have a 20cm cable currently with the Royal Mail (along with some blu-tak). I'll let you know how I get on with this.

Still awake? That's all for now, but try these...
More Raspberry Pi adventures.
More programming things.
Something completely different.

#raspberrypi #senseHAT

RISC OS Pi replaces my DAB Digital Radio

I have been playing with my Raspberry Pi RISC OS set-up, trying to find some 'essential' every-day apps for productivity on a cold English morning.  Here is my list:

Internet Radio

Long time followers of this blog will know that I like to get the shipping forecast in the morning before I go out in my boat. Having access to Internet radio is therefore a must. This is a nice light Internet radio client for RISC OS Pi available in the Plingstore. It comes with 25 pre-set radio stations including all of the BBC.

Humber, Thames. Southeast veering southwest 4 or 5, occasionally 6 later. Thundery showers. Moderate or good, occasionally poor.

Weather UK

Simply a weather RSS viewer for viewing the weather in your area (UK only).

Q: What kind of math do Snowy Owls like? A: Owlgebra.

News UK

This picks up the BBC news RSS feed. Clicking on items will load the article in your browser.

If only I could get it to make me coffee... Well, there is a GPIO library.....


Simply displays the date and time on the icon bar.  You can see it running in the screenshot above.

How a Raspberry Pi could replace my DAB radio

There are two things I like about this. First, by having it in the 'run at startup' folder you get an analogue clock with seconds hand in your icon bar - as close to a 'live tile' as you will get in RISC OS Pi. Secondly you can have multiple alarms (I am not sure what the maximum is) and alarms can seemingly be set years (months, weeks or days) into the future.  There are options for 'working week', 'repeating alarms'.  There is a 'Task Alarm' which allows you to boot up another RISC OS Pi app at at particular time of the day - for example to load the radio player just in time for the shipping forecast.  Simply drag the appropriate app into the alarm dialogue box. Repeating alarms can be programmed to run on particular intervals, or on the first Sunday of each Month.

Th..th..that's all folks...
That's all for now. If you haven't already installed RISC OS Pi, then it is worth doing. Considering it is nearly 30 years old.. it has just replaced my DAB digital radio.

Music on Console for Raspberry Pi

Following on from last week's post on setting up my RISC OS Pi machine as a media center, I started to play around with the Raspbian distribution. I needed a lightweight media app to play music as i work, and a little research led me to MOC, or Music On Console.

The MOC console running on Raspbian.
This is very straight-forward.  If you are interested, type:

sudo apt-get install moc

Launch the application with:


MOC will run even if you don't have a GUI installed.  You can even close the terminal window or tab and your music will continue to play.

General Instructions

MOC is very simple to use. Navigation through your folder structure uses the cursor keys. Press 'Enter' to play.  Press 'n' to skip to the next track.

Press 'h' for help. This will bring up the list of keyboard short-cuts for controlling the system.  I have only just scratched the surface here.

It is also possible to control MOC from the command line through flags, ie characters following a dash.  For example, to stop the current playback, use:

mocp -s

Or, to display information about the current song file:

mocp -i

Th..th..that's all folks!
MOC looks good and I look forward to experimenting with all that it can do over the next few weeks. It really is a very lightweight app - it is currently using less than 1% of my system resources.

Playing with RISC OS for Raspberry Pi, day 3

So today my 32GB micro SD card arrived for my Raspberry Pi 2.  I used Noobs to flash it with RISC OS Pi, OpenELEC, OSMC and Raspbian.

Let's ignore for a minute the fact that the first thing I did was to accidentally delete a whole load of important system files from the RISC OS Pi. Once you delete a file on RISC OS it seems that there is no way back. No surprises there. Surprisingly it seems that the system managed to soldier on without various important files, complaining only now and again that it didn't know what it was doing. I did, however, have the sense to repair the install in Noobs. This took a couple of hours.

Finally I had a working version of RISC OS again. I haven't installed any apps on the device at all yet (not even the screen- shot software).

RISC OS straight out of the box.

I decided that my main goal was to write some code to manage the function keys, in other words, to bind some macros to the programmable function keys to perform various jobs.

To do this I would need to write some BASIC code.

You can write code in the 'Edit' program in your Apps folder. In the Edit menu, navigate to 'Set type' and type 'BASIC'. then save the file somewhere sensible on your SD card.

How to save text files as executable BASIC files.

My first line of code.

My first macro creates a nice-looking command prompt environment. If you didn't already know, by pressing F12 in RISC OS you enter a command prompt which allows you to enter operating system commands. Let's do something with this.

The code is:

*key 1 *basic|M: MODE 12:COLOUR 40+128:CLS:COLOUR0:*desktop|Mhelp|M

It's all one line, but it means:

  1. Bind to function key 1 (F1 key).
  2. Switch to ARM BASIC.
  3. Enter Graphics mode 12.
  4. Set the background colour to  cyan (a sort of bluey-green).
  5. Clear the screen to this colour.
  6. Set foreground (text) colour to black.
  7. Switch out of ARM BASIC back to the OS command prompt.
  8. Pull up some help messages.

NOTE: The colon (:) is a statement separator in ARM BASIC, and the pipe M (|M) is a carriage return.

So what does it do?

Well, it brings up a rather nice looking command prompt.  Run the program and then press F12 to enter the command prompt and F1 to run the script.
My first 'Hello World' program in RISC OS.

Automating the process.

You can add other macro bindings to the other function keys, so it would be useful to have them all available (ie pre-bound to the function keys) when the system boots. To do this add your BASIC script file to the !BOOT folder.

Here's how to make a BASIC script run when the computer loads:
  1. Open the Apps folder
  2. Open !Boot
  3. Open the 'Boot' folder.
  4. Open the 'Run' folder.
  5. Drag your BASIC script file to the 'Run at startup' list.

Your program will auto-load when the machine boots up and your macros will be automatically bound to the function keys.

Working out how to use RISC OS Pi

Other things I have discovered about RISC OS today

  • The pressing SHIFT+'break' key on your keyboard acts just like the 'break' key on your BBC Microcomputer.  I think this is the same as pressing CRTL+SHIFT+F12. I never owned an Archimedes computer so I can't tell you how they behaved.
  • Don't set a hard drive password for RISC OS. Terrible things will happen if you do.
  • Don't delete important system files by accident or on purpose. Nothing good will come of this.
  • Don't use RISC OS for any web-based thing that requires a password. I don't think that security is at the heart of this OS as it is in modern operating systems.

Still awake?

Follow this link for more of my RISC OS adventures on the Raspberry Pi, or for my general Raspberry Pi adventures.

#RaspberryPi #RPi #RISCOS #RISC


It's been a long day, so no computing-related posts.  Although I have been playing around with my Raspberry Pi and building some new websites there is nothing new to show at this stage.  Instead here are some photos of my #Lego #TARDIS (from Doctor Who).  This was built from a kit that a kind relative gave to me over Christmas.

LEGO Ideas Doctor Who Assembly Kit

Idris: No. You were thinking you could build a working TARDIS console out of broken remnants of a hundred different models. And you don’t care that it’s impossible? The Doctor: It’s not impossible as long as we’re alive. Rory and Amy need me. So yeah, we’re gonna build a TARDIS.

The Doctor: Ah. Right. Yes. Bigger on the inside. Do you like it? Wilfred: I thought it’d be cleaner. The Doctor: Cleaner?! I could take you back home right now. Wilfred: Listen Doctor. If this is a time machine, that man you’re chasing. Why can’t you just pop back to yesterday and catch him?

River Song: Use the stabilisers! The Doctor: It doesn't have stabilisers! River Song: The blue switches! The Doctor: The blue ones don't do anything, they're just... blue! River Song: Yes they're blue: they're the blue stabilisers! [presses the button and the TARDIS indeed stabilises] See? The Doctor: Yeah? Well, it's boring now, isn't it? They're boring-ers! They're blue... boring-ers!

The Doctor: The metal’s just battle armor. The real Dalek creature’s inside. Statten: What does it look like? The Doctor: A nightmare. A mutation. The Dalek race was genetically engineered. Every single emotion was removed except hate. Statten: Genetically engineered. By whom? The Doctor: By a genius, Van Statten. By a man who was king of his own little world. You’d like him.

Reading and writing temporary files 02

Last time I looked at two programs: one creates a temporary file and the other one reads it.

The two programs here are an improvement.  They contain some error checking for the case when it is not possible to read and or write to the temp folder for whatever reason.  The second program also deletes the temporary file once it has read from it (this is a good idea so you don't fill up your Temp folder with lots of garbage).  Finally, the temp file can contain any number of lines of text.  Each line is stored in the text file as separated by double forward slash characters //.

You might also be interested in reading a text file byte by byte.

Code for program one:

     REM this program writes a
     REM temporary text file

text$ = ""
     in$ = CHR$(255)
     PRINT "Enter text at prompt. Press enter to finish."
     WHILE in$ <> ""
       INPUT ">" in$
       IF in$<> "" text$ +=  (in$ + "//" )

REM create the file
PRINT "writing temp file"
     errmessage$ = ""
     IF NOT(FN_createTempFile( "mytemp.tmp", text$, errmessage$ ) ) THEN

DEFFN_createTempFile( filename$, text$, RETURN message$ )
     REM writes the text into the temp file whose
     REM filename is passed in filename$
ON ERROR LOCAL message$ = "Cannot create temp file.": ENDPROC
     file% = OPENOUT( @tmp$+filename$ )
     PRINT#file%, text$
     = TRUE

Code for program two:

      REM this program reads from a
     REM temp text file of any length
     REM and deletes it after use

INSTALL @lib$+"stringlib"

     filename$ = "mytemp.tmp"
     PRINT "looking for the text file."
     errmessage$ = ""
     text$ = FN_readTempFile( filename$, errmessage$)
     IF errmessage$ = "" THEN
REM finished with temp file so delete it
IF NOTFN_deleteTempFile( filename$, errmessage$ ) THEN
"Temp file deleted"
         PRINT "file contains:"
         PROC_showText( text$ )



DEFPROC_showText( this$ )
     LOCAL parts%
     LOCAL a$()
     LOCAL i%
     DIM a$(1)

     parts% = FN_split(this$, "//", a$() )

     FOR i% = 0 TO parts%-1
       PRINT STR$(i%)": "a$(i%)

DEFFN_readTempFile( filename$, RETURN message$ )
     REM reads the temporary file and returns the text
     REM as a string
ON ERROR LOCAL message$ = "Cannot read from temp file." : = ""
     LOCAL file%, temp$
     file% = OPENIN( @tmp$+filename$ )
     WHILE NOT(EOF#file%)
       INPUT#file%, temp$
       text$ += (temp$+CHR$(13)+CHR$(10))
     = text$

     DEFFN_deleteTempFile( filename$, RETURN message$ )
     ON ERROR LOCAL message$ = "Cannot delete temp file": = FALSE
"DEL "+@tmp$+filename$
     = TRUE

Reading and writing temporary files 01

Just because I was asked this question today:
How do you read and write to temporary files in BBC BASIC for Windows?

We shall create one temporary file in program one, which will write a short message and the current time into a text file.  Program two will read the text from this file and display on the screen.

Code for Program one:

     REM this program writes a
     REM temporary text file

text1$ = "Hello, this file was created by program 1 @"
     text2$ = TIME$

     REM create the file
PRINT "writing temp file"
     PROC_createTempFile( "mytemp.tmp", text1$+text2$ )
     PRINT "done"

DEFPROC_createTempFile( filename$, text$ )
     REM writes the text into the temp file whose
     REM filename is passed in filename$
LOCAL file%
     file% = OPENOUT( @tmp$+filename$ )
     PRINT#file%, text$

Code for Program two:

     REM this program reads from a
     REM temporary text file

PRINT "looking for the text file."
     text$ = FN_readTempFile( "mytemp.tmp" )
     PRINT "file contains:"
     PRINT text$

DEFFN_readTempFile( filename$ )
     REM reads the temporary file and returns the text
     REM as a string
LOCAL file%, temp$
     file% = OPENIN( @tmp$+filename$ )
     INPUT#file%, temp$
     = temp$

If you need to navigate through Windows file explorer to find the files yourself then you should find that these programs are reading and writing to a folder located at %USERPROFILE%\AppData\Local\Temp

It would certainly be an advantage to delete the file after it has been used.  Also, it would be better if we could deal with unexpected behaviour and variable sized data lengths.

I will look at some improvements to this code in the next post.

OSMC, or, what I did with my Pi next

Whilst waiting for a new larger SD card I thought I would give OSMC (Open Source Media Center) for Raspberry Pi a try.

The OSMC interface looking rather pretty.

OSMC is a Linux-based entertainment system. I've got mine hooked up to a 2TB external hard disk from which it effortlessly plays my music, movies and pictures. It also displays the weather (although curiously only in Heathrow) and  OSMC also comes with the capability to install various apps.  I've got the OneDrive and Flickr apps so I can view my cloud photo collection (my collection of cloud photos is impressive). There are also add-ons for Dropbox, Facebook, YouTube, eBooks, email, quizzes, RSS editors... etc....

Really, my RISC OS media center doesn't get a look-in anymore.

Now for some useful OSMC videos:

"It's a media player. It plays media. That's what media players do." - A video from ExplainingComputers

#OSMC #Raspberry Pi


Blog Archive