以下是引用shenkj001在2017-3-27 16:03:54的发言:
运行下边代码,提示下标超界
?gcfun(63389)
FUNCTION gcfun(num)
IF num < 1
RETURN ""
ENDIF
LOCAL a[1], c1, c2, c3, c4, c5
ALINES(a, "一,二,三,四,五,六,七,八,九", ",")
c1 = num%10
c2 = INT(num/10%10)
c3 = int(num/100%10)
c4 = int(num/(10*10*10))
c5 = int(num/(10*10*10*10))
RETURN IIF(c5>0,IIF(c5>0,a[c5],"")+"万","")+IIF(c4>0, IIF(c4>0,a[c4],"")+"千","")+IIF(c3>0, IIF(c3>0,a[c3],"")+"百","")+IIF(c2>0, IIF(c2>0,a[c2],"")+ "十","")+;
IIF(c2=0,IIF(c1=0,"","零"),"")+ IIF(c1>0, a[c1], "")
ENDIF
ENDIF
ENDFUNC
?gcfun(63389)
FUNCTION gcfun(num)
IF num < 1
RETURN ""
ENDIF
LOCAL a[1], c1, c2, c3, c4, c5
ALINES(a, "一,二,三,四,五,六,七,八,九", ",")
c1 = num%10
c2 = INT(num/10%10)
c3 = int(num/100%10)
c4 = int(num/(10*10*10))
c5 = int(num/(10*10*10*10))
?c1,c2,c3,c4,c5
*
RETURN IIF(c5>0,IIF(c5>0,a[c5],"")+"万","")+IIF(c4>0, IIF(c4>0,a[c4],"")+"千","")+IIF(c3>0, IIF(c3>0,a[c3],"")+"百","")+IIF(c2>0, IIF(c2>0,a[c2],"")+ "十","")+;
IIF(c2=0,IIF(c1=0,"","零"),"")+ IIF(c1>0, a[c1], "")
* ENDIF &&语法错误,多出
* ENDIF &&语法错误,多出
ENDFUNC
参数c1,c2,c3,c4,c5的值分别是9,8,3,63,你在a[c5]就是a[63],肯定超出。