$INCLUDE "rapidq.inc"
DECLARE SUB do_it
DIM lin$ AS STRING
DIM kar$ AS STRING
DIM pass$ AS STRING
DIM new_kar$ AS STRING
DIM new_line$ AS STRING
DIM mode$ AS STRING
DIM line_len# AS INTEGER
DIM line_loop# AS INTEGER
DIM kar# AS INTEGER
DIM scram# AS INTEGER
DIM pass_len# AS INTEGER
pass$ = "wrialpliidaqm"
pass_len# = LEN(pass$)
lin$ = "Scott is called Sand Dune because he lives near the Atlantic Ocean"
?lin$
mode$ = "1"
do_it
?new_line$
lin$ = new_line$
mode$ = "0"
do_it
?new_line$
SUB do_it
line_len# = LEN(lin$)
new_line$ = ""
FOR line_loop# = 1 TO line_len#
kar$ = MID$(lin$, line_loop#, 1)
kar# = ASC(kar$)
scram# = line_loop# MOD pass_len#
IF mode$ = "1" THEN
kar# = kar# + ASC( MID$(pass$, scram#, 1) )
ELSE
kar# = kar# - ASC( MID$(pass$, scram#, 1) )
END IF
new_kar$ = CHR$(kar#)
new_line$ = new_line$ + new_kar$
NEXT
END SUB
|