Tag Archives: automation

Coronavirus and cavemen

It seems only a few years ago that, when I walked around my house, the lights wouldn’t turn on automatically! For younger readers, I should explain that in the past you actually had to go to a particular place on the wall and press a switch if you wanted to be able to see things!

Can you imagine the inconvenience if, say, you had your hands full at the time? And when you left the room, if you wanted to save power, you’d have to do the same thing again, and then repeat it as you went into the next room. So people had to install switches in all the places they thought they might go in and out of rooms. They had to come up with complex wiring schemes because you might want to turn lights on at the bottom of a staircase and turn them off at the top, when the upstairs and downstairs lights were normally on different electrical circuits!

It’s hard to believe, in this era of easy home automation, that there are some people still living this caveman-like existence, but it’s true, just as there are those who, when they want to listen to the news, turn a physical dial instead of just talking to their smart speaker! Those whose house doesn’t know when they’re in movie-watching mode, so they have to turn the TV on and off with a remote control.

This is, of course, terribly inconvenient for those people who still embrace the ‘retro’ approach to life, but now it has an extra drawback: every one of those switches, buttons, knobs is a hot-spot for potential virus transmission. How are those people meant to protect their family from infection if, carrying in groceries or deliveries from the outside world, they have to press a light switch that everybody else in the family is going to touch later that day? And if, without thinking, they draw the curtains by hand, how many hands will touch the same spot later?

And that’s just home automation. When the lockdown is lifted, just imagine those poor people who have to go back to work in non-automated workplaces! The potential for contagion is terrifying.

But yes, my young friends, that’s what the world really used to be like for most people! Amazing, but true.

Boredom, Toothbrushes and Terminals

When I was a child, we were not allowed to be bored. Boredom, my mother insisted, was a sign of laziness and lack of imagination, and nobody fortunate enough to have all their faculties intact should complain of it.

Some of this came, I think, from lessons my grandfather had instilled in her. Some of it may have been because we had just come back from several years in northern Kenya, where kids in extreme poverty who had no toys would just make their own out of sticks and bits of wire, and play happily with them for hours. Who were we, with boxes full of toys, shelves full of books, and minds full of stories, to complain of boredom? (And that was when the Web and YouTube were still decades away. There’s surely no excuse now!)

Anyway, it was a great lesson, and one that’s always stuck with me. I don’t remember ever being bored in my life, though the nearest I’ve come has not been when I’ve nothing to do, but when I’ve had to do some tedious repetitive task for hours on end…

Of toothbrushes and terminals

In my teens, I had a holiday job for a couple of weeks at the local factory where they made Wisdom toothbrushes. The company was changing the prices of the whole stock, and my job was to sit in front of the mainframe terminal and adjust the wholesale price of the blue toothbrush in a particular range from 23.4p to 23.9p, then do the same for the red toothbrush, the pink toothbrush, the yellow, the white… and so on for every colour they made — there were many — after which I would move on to the next range.

The problem was that this involved navigating very slowly through a deep hierarchical menu which was totally unsuited for this purpose. Today, if these were rows in a spreadsheet, it would be done in about 20 minutes. But we didn’t have spreadsheets back then, my lad. Instead, I had to dig about six layers into the keyboard-driven menu system for the particular stock item, make the change, and then exit from each layer to get back to the top before moving onto the next one.

There was no way to bypass these steps, to speed up the process. No way out of the menu. The display, which I think was probably something like the VT220 pictured above, updated very slowly over its slow connection to an overloaded mainframe. This explained why they had to employ me for many days to perform this simple task. It also taught me a lot about user interface design.

However…

It turned out that the terminal wasn’t completely dumb. On one of our tea-breaks — and yes, we really did have a tea-lady who would come through the office with a trolley of clinking cups at the allotted time — I discovered, in the back of a desk drawer, a manual for the terminal.

I found out that it could be programmed through a simple menu to send a set of keystrokes when it was switched on and connected to the mainframe, in order to identify itself, login, or whatever. This facility wasn’t used in our system, but — and this was the moment of enlightenment for me — you could also cause the sequence to be sent at any time by pressing Ctrl-Break! So I could use it as a kind of macro-recording system (not that I would have known of that concept back then).

Once I started on a new range of, say, the Mickey Mouse toothbrushes, I would work out the sequence of keystrokes needed to update one price: enter, right cursor, down, down, down, right, up, 23.9, enter, escape, enter, escape, escape, or whatever, followed by the down arrow to get to the next toothbrush. I’d program that into the terminal’s setup menu and then just hit Ctrl-Break a dozen times and sit back and watch the menu update as fast as the mainframe could manage (which wasn’t very fast).

Later that day, my boss — a great guy — came by and saw me reclining in my chair, reading something. “Having a quiet afternoon, are we, Quentin?”, he asked.

“No, I’m busy”, I explained, and gestured to the screen, where the all-too-familiar menus seemed to be operating themselves at great speed while I sat back and sipped my tea.

I’ll never forget the expression on his face.

However, I guess all such Sorcerer’s Apprentice tales must have a cautionary aspect to them. In my case, the work was finished much sooner, so I was out of a job.

Perhaps there’s a lesson there. In that case, though, I can’t say I was too sorry!

Printing a booklet on a Mac

I had a 47-page PDF document that I wanted to turn into a compact A5 booklet – you know, one of those things where you get out the big stapler and make something like this:

Unfortunately, you need to print page 39 on the same page as page 10, and then pages 40 and 9 on the other side, etc, and when you get to anything more than about 4 pages it’s hard and tedious to do this by hand and get it right. My HP printer driver had a ‘booklet’ facility, and it worked OK for 8 pages, but let me down when given any more.

Now, there are utilities you can buy which can do exactly this, but why would I spend a tenner or two when I could instead use a few otherwise lucrative working hours and build one myself?

So here’s my solution, which could be a lot tidier, but does the only tricky bit of the job: getting the pages in the right order. It’s an Automator script which you can run as a service: once installed, you can right-click on a PDF and select Services, and you should find a ‘Make Booklet PDF’ option. It produces a new PDF on your Desktop with appropriately shuffled pages. You can then just print that using Preview as follows:

  • Go into the Layout section of the Print dialog.
  • Select Two-Sided Printing
  • Set Pages per Sheet to ‘2’
  • Set the ‘Two-Sided’ option to ‘Short-Edge Binding’

Now, please note: You should understand how this works before trying it! It’s not complex, and I could have made it much prettier and self-explanatory, but I was using Automator, which is so far from a real programming language as to be frustrating. It does, however, have a few useful ways of manipulating PDFs without having to install anything else, and my script will at least prompt you with some of the following information when you run it.

OK,

  • First, the number of pages in your starting PDF must be a multiple of 4. Fortunately, you can easily append blank pages in Preview if needed. Select the last page and choose ‘Edit > Insert > Blank Page’ as often as needed and then save. The script will warn you if your page count isn’t right.

  • Then when you run the script, it will create a folder called ‘booklet-pages’ on your desktop. In here, it will create one PDF for each page of your document.

  • Finally, it will work out what order these pages should be in, and create a new ‘booklet.pdf’ on your desktop with the pages reassembled in that order.

  • You can then delete the ‘booklet-pages’ folder.

So, here’s a zip file containing the Automator script. You should be able to double-click it and open it in Automator if you want to see what’s inside, but I think if you put it into your ~/Library/Services folder within your home directory, it will probably just appear as a service if you right-click on a PDF file in the Finder.

Make Booklet PDF on desktop.zip

Hope it’s useful to someone! Sorry I can’t provide any support if you try it, but recommendations and improvements are welcome from anybody with more Automator stamina than me! All I can say is that it works nicely on my Mac running High Sierra (10.13.6).

© Copyright Quentin Stafford-Fraser