RGUTUU ;CAIRO/DKM - UUEncode and UUDecode functions.;04-Sep-1998 11:26;DKM
;;2.1;RUN TIME LIBRARY;;Mar 22, 1999
;=================================================================
ENCODE(X) ;
N RGZ,RGZ1,RGZ2,RGZ3,RGZ4,RGZ5,RGZ6
S RGZ=$$INIT,RGZ1=""
F RGZ2=1:3:$L(X) D
.S RGZ3=0,RGZ6=""
.F RGZ4=0:1:2 D
..S RGZ5=$A(X,RGZ2+RGZ4),RGZ3=RGZ3*256+$S(RGZ5<0:0,1:RGZ5)
.F RGZ4=1:1:4 S RGZ6=$E(RGZ,RGZ3#64+2)_RGZ6,RGZ3=RGZ3\64
.S RGZ1=RGZ1_RGZ6
S RGZ2=$L(X)#3
S:RGZ2 RGZ3=$L(RGZ1),$E(RGZ1,RGZ3-2+RGZ2,RGZ3)=$E("==",RGZ2,2)
Q RGZ1
DECODE(X) ;
N RGZ,RGZ1,RGZ2,RGZ3,RGZ4,RGZ5,RGZ6
S RGZ=$$INIT,RGZ1=""
F RGZ2=1:4:$L(X) D
.S RGZ3=0,RGZ6=""
.F RGZ4=0:1:3 D
..S RGZ5=$F(RGZ,$E(X,RGZ2+RGZ4))-3
..S RGZ3=RGZ3*64+$S(RGZ5<0:0,1:RGZ5)
.F RGZ4=0:1:2 S RGZ6=$C(RGZ3#256)_RGZ6,RGZ3=RGZ3\256
.S RGZ1=RGZ1_RGZ6
Q $E(RGZ1,1,$L(RGZ1)-$L(X,"=")+1)
INIT() Q "=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HRGUTUU 946 printed Nov 22, 2024@17:47:33 Page 2
RGUTUU ;CAIRO/DKM - UUEncode and UUDecode functions.;04-Sep-1998 11:26;DKM
+1 ;;2.1;RUN TIME LIBRARY;;Mar 22, 1999
+2 ;=================================================================
ENCODE(X) ;
+1 NEW RGZ,RGZ1,RGZ2,RGZ3,RGZ4,RGZ5,RGZ6
+2 SET RGZ=$$INIT
SET RGZ1=""
+3 FOR RGZ2=1:3:$LENGTH(X)
Begin DoDot:1
+4 SET RGZ3=0
SET RGZ6=""
+5 FOR RGZ4=0:1:2
Begin DoDot:2
+6 SET RGZ5=$ASCII(X,RGZ2+RGZ4)
SET RGZ3=RGZ3*256+$SELECT(RGZ5<0:0,1:RGZ5)
End DoDot:2
+7 FOR RGZ4=1:1:4
SET RGZ6=$EXTRACT(RGZ,RGZ3#64+2)_RGZ6
SET RGZ3=RGZ3\64
+8 SET RGZ1=RGZ1_RGZ6
End DoDot:1
+9 SET RGZ2=$LENGTH(X)#3
+10 if RGZ2
SET RGZ3=$LENGTH(RGZ1)
SET $EXTRACT(RGZ1,RGZ3-2+RGZ2,RGZ3)=$EXTRACT("==",RGZ2,2)
+11 QUIT RGZ1
DECODE(X) ;
+1 NEW RGZ,RGZ1,RGZ2,RGZ3,RGZ4,RGZ5,RGZ6
+2 SET RGZ=$$INIT
SET RGZ1=""
+3 FOR RGZ2=1:4:$LENGTH(X)
Begin DoDot:1
+4 SET RGZ3=0
SET RGZ6=""
+5 FOR RGZ4=0:1:3
Begin DoDot:2
+6 SET RGZ5=$FIND(RGZ,$EXTRACT(X,RGZ2+RGZ4))-3
+7 SET RGZ3=RGZ3*64+$SELECT(RGZ5<0:0,1:RGZ5)
End DoDot:2
+8 FOR RGZ4=0:1:2
SET RGZ6=$CHAR(RGZ3#256)_RGZ6
SET RGZ3=RGZ3\256
+9 SET RGZ1=RGZ1_RGZ6
End DoDot:1
+10 QUIT $EXTRACT(RGZ1,1,$LENGTH(RGZ1)-$LENGTH(X,"=")+1)
INIT() QUIT "=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"