Playfair cipher: Difference between revisions

m
→‎{{header|REXX}}: converted a subroutine to in-line. -- ~~~~
m (→‎{{header|REXX}}: shortened a few statements. -- ~~~~)
m (→‎{{header|REXX}}: converted a subroutine to in-line. -- ~~~~)
Line 372:
if length(noX)\==1 then call err '"ommitted" letter must be only one letter'
if length(newK)<3 then call err 'cypher key is too short, must be > 1 character.'
if \isLetdatatype(noX,'M') then call err '"omitted" letter must be a Latin alphabet letter.'
if pos(noX,oldX)\==0 then call err 'PHRASE can''t contain the "OMIT" character: ' noX
fill=space(translate('ABCDEFGHIJKLMNOPQRSTUVWXYZ',,noX),0) /*remove NOX*/
Line 400:
@@: parse arg Xrow,Xcol; return @.Xrow.Xcol
err: say; say '***error!***' arg(1); say; exit 13
isLet: return datatype(arg(1),'Mixed')
row: ?=pos(arg(1),grid); Xpos=(?-1)//5+1; return (4+?)%5
/*──────────────────────────────────LR subroutine───────────────────────*/
Line 406 ⟶ 405:
rowL=row(L); colL=Xpos; rowR=row(R); colR=Xpos; return
/*──────────────────────────────────SCRUB subroutine────────────────────*/
scrub: procedure; arg stuff /*ARG ARG capitalizes all arguments.*/
$=; do j=1 for length(stuff); _=substr(stuff,j,1)
if isLetdatatype(_,'M') then $=$||_ /*only use Latin alphabet letters.*/
end /*j*/
return $