'===========================================================================
' Subject: ROT-13 ENCODER/DECODER             Date: 02-27-97 (01:13)       
'  Author: Marc van den Dikkenberg            Code: QB, QBasic, PDS, PB    
'  Origin: excel@xs4all.nl                  Packet: TEXT.ABC
'===========================================================================
' ROT-13 encoder/decoder
' Created 26-02-1997
' By Marc van den Dikkenberg (pb@excelsior.xs4all.nl)
' 
' http://pitel-lnx.ibk.fnt.hvu.nl/~excel/pb.html 
'
test$="This is a test"

print "Original - "test$
call rot13(test$)
print "ROT-13   - "test$

SUB ROT13(test$)
  for tt=1 to len(test$)
    y%=0
    x%=asc(mid$(test$,tt,1))
    if (x%>64 and x%<91) or (x%>96 and x%<123) then
      y%=13
      x%=x%-y%
      if x%<97 and x%>83 then x%=x%+26 else if x%<65 then x%=x%+26
    end if
    mid$(test$,tt,1)=chr$(x%)
  next tt
END SUB
