众里寻它千百度,暮然回首却在VFP论坛处,多谢TonyDeng版主共享
天道酬勤
CLOSE TABLES SET SAFETY OFF USE PY ALIAS PY CREATE CURSOR TABNAME (XM C(6),QP C(10),JP C(1)) SELECT TABNAME INSERT INTO TABNAME VALUES ("张一","","") INSERT INTO TABNAME VALUES ("王一","","") INSERT INTO TABNAME VALUES ("李一","","") INSERT INTO TABNAME VALUES ("杨一","","") SCAN REPLACE QP WITH PY(LEFTC(XM,1),2) IN TABNAME REPLACE JP WITH PY(LEFTC(XM,1),1) IN TABNAME ENDSCAN BROWSE SET SAFETY ON *----取拼音函数 FUNCTION PY PARAMETERS C,N *---- 如果N=1 转换为简拼,N=2 转换为全拼 C:要转换的汉字 LOCAL CPY,ZF STORE "" TO CPY,ZF FOR I=1 TO LEN(ALLTRIM(C)) IF ASC(SUBSTR(ALLTRIM(C),I,1))>128 ZF=SUBSTR(ALLTRIM(C),I,2) SELECT PY LOCATE FOR HZ==ZF IF FOUND() CPY=CPY+IIF(N=1,UPPER(ALLTRIM(LEFT(PY,1))),PROPER(ALLTRIM(PY))) ELSE CPY=CPY+ZF ENDIF I=I+1 ELSE CPY=CPY+SUBSTR(ALLTRIM(C),I,1) ENDIF ENDFOR RETURN CPY