如何在开放边缘进度4gl中检查给定字符串是否为回文?是否有任何反向字符串函数内置进度4gl?
FUNCTION reverseString RETURNS CHARACTER (
INPUT i_c AS CHARACTER
):
DEFINE VARIABLE cresult AS CHARACTER NO-UNDO.
DEFINE VARIABLE ii AS INTEGER NO-UNDO.
DO ii = LENGTH( i_c ) TO 1 BY -1:
cresult = cresult + SUBSTRING( i_c, ii, 1 ).
END.
RETURN cresult.
END FUNCTION.
display reverseString( "asdf" ).
答案 0 :(得分:2)
完整的OpenEdge文档集可以在这里找到:
如您所见,没有内置的反向字符串函数。
您所需要的功能就像上面所说的那样。
使用该函数确定字符串是否为回文:
myString = "asdf".
if myString = reverseString( myString ) then
message "yes," myString "is a palindrome".
else
message "no," myString "is not a palindrome".