$PBExportHeader$f_psw_zh.srf
global type f_psw_zh from function_object
end type

forward prototypes
global function string f_psw_zh (string obj_string, integer add_expr, string keystr)
end prototypes

global function string f_psw_zh (string obj_string, integer add_expr, string keystr);//f_psw_zh
IF ISNULL(obj_string) THEN RETURN obj_string
INT LS_XX,STR_LEN,LS_YY
STRING RT_STRING='',ZH_STR='',FORMAT_STR
STR_LEN=len(obj_string)
IF STR_LEN=0 THEN RETURN ''

//FORMAT_STR=RIGHT(STRING(Pi(10)/1.11111,'0.###############'),15)
FORMAT_STR=keystr

FOR LS_YY=1 TO (STR_LEN/len(FORMAT_STR))+1
	ZH_STR=ZH_STR+FORMAT_STR
NEXT

IF add_expr=0 THEN //ADD
FOR LS_XX=1 TO STR_LEN 
RT_STRING=RT_STRING+CHAR(ASC(Mid (obj_string,LS_XX,1)) + INTEGER(MID(ZH_STR,LS_XX,1)) )//
NEXT
RT_STRING=Reverse(RT_STRING)
ELSE //EXPR
obj_string=Reverse(obj_string)
FOR LS_XX=1 TO STR_LEN 
RT_STRING=RT_STRING+CHAR(ASC(Mid (obj_string,LS_XX,1)) - INTEGER(MID(ZH_STR,LS_XX,1)) )//
NEXT
END IF 

return RT_STRING	
end function

