直接上代码:
#检查输入的值是否合法 FUNCTION p003_check2(p_str) DEFINE p_str STRING DEFINE l_str01,l_str02 STRING DEFINE l_i,l_j,l_cnt SMALLINT LET l_result = TRUE IF p_str IS NOT NULL THEN LET l_cnt = p_str.getLength() #获取字符串长度 LET l_i = p_str.getIndexOf('.',1) #获取小数点位置 IF l_i = 0 THEN #不存在小数 FOR l_i = 1 TO l_cnt IF p_str.subString(l_i,l_i) NOT MATCHES "[0-9]" THEN DISPLAY "You must enter numeric data." LET l_result = FALSE EXIT FOR END IF END FOR ELSE LET l_str01 = p_str.subString(1,l_i-1) LET l_str02 = p_str.subString(l_i+1,l_cnt) FOR l_i = 1 TO l_str01.getLength() IF l_str01.subString(l_i,l_i) NOT MATCHES "[0-9]" THEN DISPLAY "You must enter numeric data." LET l_result = FALSE EXIT FOR END IF END FOR FOR l_j = 1 TO l_str02.getLength() IF l_str02.subString(l_j,l_j) NOT MATCHES "[0-9]" THEN DISPLAY "You must enter numeric data." LET l_result = FALSE EXIT FOR END IF END FOR END IF ELSE LET l_result = FALSE END IF RETURN l_result END FUNCTION |
|
沙发#
发布于:2016-12-02 17:45
4gl难道没有类似typeof这样的内置函数么?
查了半天也没有查到。。只能顶你吧 |
|