Path: utzoo!utgpu!jarvis.csri.toronto.edu!clyde.concordia.ca!uunet!wuarchive!kuhub.cc.ukans.edu!anu-news!list From: root@NSFNET-RELAY.AC.UK Newsgroups: news.software.anu-news Subject: Mail Delivery Failure to uk.ac.king - Timeout Message-ID: Date: 30 Dec 89 07:48:42 GMT Sender: ANU-NEWS Discussion Reply-To: root@NSFNET-RELAY.AC.UK Lines: 179 Via: 000040010180.FTP.MAIL; 30 DEC 89 7:51:03 GMT The NIFTP process was unable to deliver your mail to host uk.ac.king over janet. The reason given by the local host was: The NIFTP process gave up after 77 attempts over 168 hours Your message was not delivered to the following addresses: GPKING@uk.ac.kingston Your message begins as follows: Received: from vax.nsfnet-relay.ac.uk by sun.NSFnet-Relay.AC.UK Via Ethernet with SMTP id aa00313; 23 Dec 89 7:11 GMT Received: from sun.nsfnet-relay.ac.uk by vax.NSFnet-Relay.AC.UK via Janet with NIFTP id aa00343; 23 Dec 89 7:05 GMT Received: from UKACRL by UK.AC.RL.IB (Mailer X1.25) with BSMTP id 3573; Sat, 23 Dec 89 07:07:18 GM Received: from NDSUVM1.BITNET by UKACRL.BITNET (Mailer X1.25) with BSMTP id 0514; Sat, 23 Dec 89 07:07:17 G Received: from NDSUVM1.BITNET by NDSUVM1.BITNET (Mailer R2.03B) with BSMTP id 8488; Fri, 22 Dec 89 22:52:21 C Date: Fri, 22 Dec 89 14:07:42 GMT Reply-To: brodie@edu.mcw.fps Original-Sender: ANU-NEWS Discussion From: brodie@edu.mcw.fps Subject: TPU procedure for rot13. My examples. (enjoy) To: Multiple recipients of list ANU-NEWS Sender: ANU-NEWS%earn.ndsuvm1@uk.ac.earn-relay Well, here it is, my first attempt at TPU programming. I have to thanks Geoff for forcing me to do this (well, not forcing, but I needed a good excuse to learn how to do junk inside of TPU for a change.... up to this point, I'd never used my own SECTION file. Damned neat, once you take the time to learn it......) First off, I would like to show you my "first" attempt at a rot-13 procedure. works pretty damned good, for a first try.... (no flames, please. I'm a good programmer, but TPU is totally new to me. It doesn;t help when you don't know all of the neat stuff available..) ! ! TPU procedure to ROT13 a text file. ! Copyright (C) 1989 Kent C. Brodie / Medical College of Wisconsin ! This software is available to all VAX users, and can be distributed ! freely as long as the above copyright is included. So there. ! procedure eve_rot13 message ("Beginning ROT13 procedure..."); letterpat := ANY("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"); position(beginning_of(current_buffer)); ! Go to the star t of the current buffer loop; ! For each character in buffer exitif (mark(none) = end_of(current_buffer)); ! exit if EOF found match_pos := search_quietly (letterpat, FORWARD); ! find the next (A-Z|a-z ) exitif (match_pos = 0); position (match_pos); ! go there letterval := ASCII(current_character); newletter := ""; if (letterval >= 65) and (letterval <= 90) then if (letterval > 77) then letterval := letterval - 13; else letterval := letterval + 13; endif; newletter := ASCII(letterval); else if (letterval >= 97) and (letterval <= 122) then if (letterval > 109) then letterval := letterval - 13; else letterval := letterval + 13; endif; newletter := ASCII(letterval); endif; endif; if (newletter <> "") then deleted_char := erase_character(1); copy_text(newletter); endif; endloop; endprocedure; that was my first try. Then I realized that was pretty gross, so I bettered it. I removed all of those multiple if statements, and used a long alphabet string. Locate the letter, move 13 right, grab the new letter, done. My first example used too many of the old "fortran" or "pascal" methods of doing it. The second pass made use of the TPU string handling junk. much nicer. ! ! TPU procedure to ROT13 a text file. ! Copyright (C) 1989 Kent C. Brodie / Medical College of Wisconsin ! This software is available to all VAX users, and can be distributed ! freely as long as the above copyright is included. So there. ! ! This procedure works by utilizing the string handling capabilities ! of TPU. The string "letters" is used for the rot-ting process, which ! is why there are TWO sets of upper and lower case. In this fashion, ! the "rot" factor (see variable rotfactor) can be changed to create a ! new rot program (such as rot17, etc.). ! procedure eve_rot13 !declare program constants to be used. Change "rotfactor" to do the !rot-ting of your choice. Due to popularity, the default is 13. ! rotfactor := 13; letterpat := ANY("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"); letters := "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmno pqrstuvwxyzabcdefghijklmnopqrstuvwxyz"; message ("Beginning ROT13 procedure..."); position(beginning_of(current_buffer)); ! Go to the top... loop; ! For each character in buffer exitif (mark(none) = end_of(current_buffer)); ! exit if EOF found match_pos := search_quietly (letterpat, FORWARD); ! find the next (A-Z|a-z ) exitif (match_pos = 0); ! exit if no more letters found position (match_pos); ! go there letterpos := index (letters,current_character); ! Look in "letters" for index letterpos := letterpos + rotfactor; ! ad the "rot factor" to the ind ex newletter := substr (letters,letterpos,1); ! create the new letter deleted_char := erase_character(1); ! delete the old character copy_text(newletter); ! replace it with the new one. endloop; endprocedure; Now I thought I was done. Nice, clean, compact code. Then I saw it. (gee, you mean it helps to RTFM?) heh. God bless it, it was right in the (^!%^(&! book. Seems there's this neat little TPU built-in called TRANSLATE that does all the work for you, and is quite flexible. I basically ended up stealing this from the book, but hey, that's what us computer folk do best, make use of someone ELSE's work.. ! ! TPU procedure to ROT13 a text file. ! 12/20/1989 Kent C. Brodie / Medical College of Wisconsin ! ! This procedure example was taken from page 4-352 of the VAXTPU reference ! manual. Seems that TPU has a REAL easy way to do this, using the TRANSLATE ! built-in. ! procedure eve_rot13 translate (current_buffer, "NOPQRSTUVWXYZABCDEFGHIJKLMnopqrstuvwxyzabcdefghijklm", "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"); message ("ROT13 complete.") endprocedure; cute, eh? (and about 10 times faster than my code. *sigh*...) ------------------------------------------------------------------------------- Kent C. Brodie - Systems Manager brodie@mcw.edu Medical College of Wisconsin +1 414 778 4500 "Gee, I hope these are the right coordinates..." -Chief O'Brian; STTNG