Path: utzoo!utgpu!jarvis.csri.toronto.edu!clyde.concordia.ca!uunet!dayton.saic.com!fac2 From: fac2@dayton.saic.com (Earle Ake) Newsgroups: news.software.anu-news Subject: Re: RE: rot13 utility in DCL. (TPU solution!) Message-ID: <874.25922aa1@dayton.saic.com> Date: 22 Dec 89 18:22:41 GMT References: <8912200842.AA22375@uunet.uu.net> <3286.2590eeeb@fps.mcw.edu> Organization: Science Applications Intl. Corp., Dayton, Ohio Lines: 62 In article <3286.2590eeeb@fps.mcw.edu>, brodie@fps.mcw.edu writes: > In article <8912200842.AA22375@uunet.uu.net>, munnari!csc.anu.oz.au!gih900@UUNET.UU.NET (Geoff Huston) writes: > >> Wouldn't it be better to have a TPU edit procedure called rot13 to allow you >> to rot the necessary bits?? >> (said he trying to avoid having to add the code) I wasn't doing much today so I took out the TPU manual and discovered that TPU has a function called TRANSLATE which will do what I wanted. The example even shows a way to use it to rotate every character by 13 to 'encrypt' them! Sounds like just what I have been looking for. I am using Ted Nieland's EDT-Plus editor so the procedure will have to be modified slightly for use with an other TPU based editor. I started with the procedure that changes the case of the letters either one at a time or those within the select range. Instead of using the change_case function, I made it the TRANSLATE function. I have defined the key to be GOLD-T as that was not being used. Let me know what you think. -- _____________________________________________________________________________ ____ ____ ___ Earle Ake /___ /___/ / / Science Applications International Corporation ____// / / /__ Dayton, Ohio ----------------------------------------------------------------------------- Internet: fac2%dayton.saic.com@uunet.uu.net uucp: uunet!dayvb!fac2 !EDTP ROT13 ! PROCEDURE EDTP$rot13 !gold r (rot13) LOCAL character ; !check for active select EDTP$select_range; if EDTP$x_select_range <> 0 then TRANSLATE (EDTP$x_select_range, "NOPQRSTUVWXYZABCDEFGHIJKLMnopqrstuvwxyzabcdefghijklm", "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"); EDTP$x_select_range:=0; return; endif; !change case of current character if current_character <> EDTP$x_empty then character :=current_character; TRANSLATE (character, "NOPQRSTUVWXYZABCDEFGHIJKLMnopqrstuvwxyzabcdefghijklm", "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"); erase_character(1); copy_text(character); if current_direction <> forward then move_horizontal(-2); endif; return endif; ENDPROCEDURE DEFINE_KEY('EDTP$rot13',key_name('T',shift_key),"rot13"); ! rot13