如何在开放边缘进度4gl中检查字符串是否是回文

时间:2015-06-25 05:19:07

标签: progress-4gl openedge

如何在开放边缘进度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" ).

1 个答案:

答案 0 :(得分:2)

完整的OpenEdge文档集可以在这里找到:

https://community.progress.com/community_groups/openedge_general/w/openedgegeneral/1329.openedge-product-documentation-overview.aspx

如您所见,没有内置的反向字符串函数。

您所需要的功能就像上面所说的那样。

使用该函数确定字符串是否为回文:

myString = "asdf".
if myString = reverseString( myString ) then
  message "yes," myString "is a palindrome".
 else
  message "no," myString "is not a palindrome".