JetByte Ltd - The Right Code Right Now Contract Programming and Consulting Services
Home button
News button
Services button
Clients button
Portfolio button
Resources button
Guestbook button
Contact button

Contact us

Back

Article

Line Wrapper

An output buffer for an old and primitive online system. It wraps text to fit terminal widths.

I have fond memories of this particular piece of code as I used it as a sampler that I sent out with my CV when I was initially looking to become a programmer. I don't know if it helped me get taken seriously but I like to think it did...

What's a line wrapper?

Back in 1992 I was writing multi user adventure games. Or at least I was trying to. My hardware budget didn't run to much so I was initially doing it all under DOS... This wasn't as daft as it now sounds (though it was pretty daft) there were actually several games up and running and taking money that ran on pretty laughable hardware... Anyway, I knew a guy with a Unix box, so I was porting to that...

When you played these games you typed away at a terminal for hours on end. The worst games assumed you had X width (where X was usually 80 cols), but back then you couldn't make these assumptions as people played these games on Spectrums and Commodor64s and all sorts of rubbish. The best word wrapped their output. I wanted my game to be one of the best, so I wrote an output wrapper... I'd been playing around with Borland C++ and originally wrote it as a class but, well, the rest of the game was being ported to Unix and didn't have a C++ compiler on the Unix box... Besides at the time this C++ thing didn't really look like it was going to take off...

From what I remember the wrapper did all kinds of clever things, like wrap your input as well as the game's output... That's not as easy as it sounds as you have to display the characters as they are typed but may need to backspace over an incomplete word and display it on the following line if it wont fit.

Sounds pretty crap, I know, but that's pretty much all it does.

The code uses a debugging memory allocation library that I wrote. It was kinda funky and saved me lots of time tracking those horrible memory problems you could get on systems that offered no memory protection...

Download

The source for the line wrapper was originally DOS or Unix and built with either Borland C++ v3.1 or cc on unix boxes. I grabbed it, stuffed it into VC++ v5.0 and commented out any horrible DOSisms or Borlandesque reasons why I wouldn't compile under NT. Can't say I tested this "port" very hard though...

 Download Wrapper.zip

1 2 3 4 5

comment on this article
read other visitors' comments

back to top