10 March 2007

MADAM I'M ADAM

Reading about Steve Wozniak ("Woz") and the computer revolution he helped fuel, I couldn't help wishing I was more involved with the revolution. It's just wishful thinking. It was the early 1980s and I was just a high school lad. I have overcome the language barrier a few years earlier and was comfortable with the English language by then. The revolution was already under way and the computers of the time include the TRS-80 and the Commodore-128. Thanks to my high school buddies M and R, I was enrolled in some computer summer program at Jamaica High School. I learned BASIC on, I believe, the C-128, in glorious colors. Something that I learned back then is useful until this day - string manipulation. Strings in computer programs mean text, as opposed to numbers. One of the exercises that we did involved determining if a string is a palindrome. A palindrome is a phrase that is spelled the same backward and forward, disregarding space and punctuation marks such as comma and apostrophe. Take MADAM I'M ADAM, supposedly something the First Man, Adam, said to the First Woman, Eve, when they, well, first met. Not counting the apostrophe, it's M-A-D-A-M-I-M-A-D-A-M backward and forward. To determine if the phrase is a palindrome, we would have to spell the word backward, picking up one letter at a time from the end. I believe we had to use the MID function to pick up the letters. The syntax for MID is MID({text to extract out of}, {beginning position}, {number of characters to grab}.) For example, MID("Hello", 2, 1) equals to the letter e. A FOR..NEXT loop, with negative step, was needed to walk along the length of the phrase. For other exercises, we learned about the LEFT, RIGHT, LEN, and ASC functions, etc. Really simple stuff but applicable in many situations.

Forward to the year 2007, I have uses for these simple functions in my scripts to retrieve info from Netware eDirectory. Using NDAP programming, I was able to determine the full path of a given username. For example, user John Smith, SmithJ, is an accountant in the New York office, so his fully-qualified name is .SmithJ.Accountant.NYC.USA. Having the full path allows me to add the user to groups via scripts. The only problem is that the path returned via NDAP is the reverse, like NDS:\\Tree\USA\NYC\Accountant\SmithJ. To convert the result to the dot-limited format I had break down path to its components, where each component is separated by slash. Then I pieced the components back together, only I had to start with the last original piece and end with the first original piece. VBScript and NDAP are all modern technologies, but they share the common string functions, such as MID and LEFT, that I learned back in the 80's.

One fun side-effect I had with learning computer in those days was the game Artillery. It was a simple game of two players taking turns shooting projectiles at the other party. Players would enter a number to represent the strength of the projectile and another number for the angle of attack. Now on my PowerBook G4, I have the game Pocket Tank, a descendant of Artillery. Pocket Tank has nice graphic, sound effects, music, options of wind direction and terrains, but the basic idea of adjusting power and angle is still there.

How about a few more palindromes to close off this blog entry?

ABLE WAS I ERE I SAW ELBA
(Supposedly something Napoleon said before he was exiled to Elba Island.)

A MAN A PLAN A CANAL PANAMA!
(How the Panama Canal came into being?)

SEX AT NOON TAXES
(A special kind of taxes for certain activity at 12p.m.)


As you may suspect, palindromes are mostly very contrived, something made up and its existence justified afterward, not something that would occur naturally.

No comments:

Post a Comment