And now something spooky for Halloween!
This little shocker dates from 2002. A quick search unearthed dozens of duplicates already on the web, but the link to the picture is broken in most of them. Here it is restored to all its former glory thanks to the Internet Archive’s Wayback Machine.
I’m back after a long hiatus with a Batch file that trims leading and trailing whitespace from a string. The program won’t choke on “poison characters” and doesn’t care about the state of delayed expansion. At last, something other people may find useful!
To achieve this, however, I’ve had to employ several advanced Batch programming techniques. The code may be difficult for beginners to follow, but I’ve tried to explain how the program works and I’ve included links to fuller explanations of some of the techniques used.
Apologies for not posting in a while.
I’ve come to the realisation that my blog needs an overhaul. One or two posts have become obsolete, a few links need updating, and my Batch programs need rewriting.
Stay tuned for updates!
In a previous post, I talked about how to count the number of lines in a text file. I explained the technique of piping the output from
type file.txt into
find /c /v "" and wrapping the whole thing inside a
for /f loop to store the result in a variable. A simple and effective solution to a common Batch programming task.
Too bad it doesn’t work…
A large part of programming in Batch is taken up with processing text files. By “text file”, I mean a plain text file with Windows line endings. And “plain text” means no nasty control characters such as Control-Z or the infamous Null Character.
For example, the former is used by
copy /a and
type as the end-of-file marker, while
echo interpret the latter as the end of input.
So it’s always a good idea to scan any text files of unknown origin for these troublesome characters before doing anything else. Which is why I wrote the
ctrlscan.cmd program described below…
Happy Easter, everybody! Here’s a classic joke for you. If you haven’t read it in a while, it will make you laugh all over again. And if you haven’t read it before… well, you’re in for a treat!
I don’t normally reproduce jokes that are already all over the web like a rash, but I couldn’t find out where it originated from, and besides, it’s one of my favourites.
Happy St Patrick’s Day to all my readers!
Hope you enjoy the following. Apologies if you’ve read it before. But it’s worth revisiting because it’s guaranteed to make you laugh—especially if you’ve had a few whiskeys! Plus I added a few links and additional material you mightn’t have seen elsewhere.
A class of schoolkids were given a project to decorate a flowerpot they could take home and show off to their parents. They wanted a plant that was easy to take care of, so it was decided to use cactuses.
ASCII has 33 control characters. Many of them are defunct or are used for purposes for which they were not originally intended. Most of them are unprintable and some can cause problems if not filtered out of input. All the same, a handful of these characters have proven to be indispensible when it comes to performing certain tasks in Batch.
In this post, I’ll show you commonly-used techniques for generating specific control characters, as well as two lesser-known methods for storing almost any control character in a variable. But finding uses for them is an entirely different matter. One which will be covered in an upcoming post.
I use a screen reader called JAWS (and sometimes NVDA) to browse the web and for updating my blog. It does a pretty good job of most things. But it can’t cope with WP’s visual editor. One consequence of which is that I can’t create image galleries or slideshows—at least, not by conventional means.
This post is based on lessons learnt from putting together a selection of my favourite viral images and outlines an accessible, do-it-yourself alternative to WP’s proprietary method for creating slideshows.
I realise this topic is mostly of academic interest these days, but I decided to archive an updated version of the post for posterity. And the fact that I put a lot of work into it, dammit!
This is a follow-up to my recent post on how to store the nth line of a text file in a variable. The solution given won’t work for extremely long lines because the line requested by the user is stored in a variable and variables in Batch can only hold up to 8191 characters.
If you need to select an extremely long line from a file and save it to a new file, there is a workaround. But it ain’t pretty, or efficient. It involves
findstr, and a whole lot of temporary files.
This question is sometimes asked on the GMAT exam, allegedly.
A woman drives to work every morning at an average speed of 30kmph. In the evening, she drives home the same distance at an average speed of 40kmph. What is her average speed over both journeys?
HINT: The answer isn't 35kmph!
1985 Blue Volkswagen Golf