如何在单个if语句中使用多个OR运算符?我试过这种方式,但有一个错误:
表达式或赋值中的数据类型不兼容。
我看了长度函数的文档,它是LENGTH ( {string | raw-expression | blob-field } [ , type ] )
?
这是代码:
DEFINE VARIABLE cMonth AS CHARACTER.
DEFINE VARIABLE cDay AS CHARACTER.
DEFINE VARIABLE cYear AS CHARACTER.
UPDATE cDateFromUser.
cDay = (SUBSTRING(cDateFromUser,1,2)).
cMonth = (SUBSTRING(cDateFromUser,3,2)).
cYear = (SUBSTRING(cDateFromUser,5,4)).
IF (LENGTH(cDay <> 2)) OR (LENGTH(cMonth <> 2)) OR (LENGTH(cYear <> 4)) THEN DO:
/*Code*/
END.
ELSE DO:
/*Code*/
END.
语法不在这里。使用以下IF:
IF (LENGTH(cDay) <> 2) OR (LENGTH(cMonth) <> 2) OR (LENGTH(cYear) <> 4) THEN DO: