PROGRESS 4GL - IF 条件是否支持维数组?
PROGRESS 4GL - does IF condition supports for dimensional array?
我是 progress 4GL 语言的新手。我写了一个逻辑,它试图检查维数组的 <> "" 值并给出语法错误。任何人都可以帮助我在哪里犯错误以及我写的逻辑是否正确?
DEFINE VARIABLE anotarray AS CHARACTER NO-UNDO.
DEFINE VARIABLE barray AS CHARACTER EXTENT 3 NO-UNDO.
ASSIGN
barray[1] = "yes"
barray[2] = "no"
anotarray = ""
.
/***value can be stored randomly in variable barray. so we cannot specify [1],[2],[3] for if condition***/
/***based on req. I need to check both anotarray or barray <> "" ***/
IF (anotarray OR barray ) <> "" THEN DISP barray.
/*** ERROR thrown- An array was specified in an expression, on the right-hand side of an assignment, or as a parameter when no array is appropriate or expected. (361)*** /
此语法无效:IF (anotarray OR barray) <> "" THEN ...
您必须循环遍历数组的所有元素。您可以使用 DO
statement and the EXTENT
function.
此外,您必须将两个变量与空字符串进行比较:IF anotarray <> "" OR barray[ix] <> "" THEN ...
此代码应该有效:
DEFINE VARIABLE anotarray AS CHARACTER NO-UNDO.
DEFINE VARIABLE barray AS CHARACTER EXTENT 3 NO-UNDO.
DEFINE VARIABLE ix AS INTEGER NO-UNDO.
ASSIGN
barray[1] = "yes"
barray[2] = "no"
anotarray = ""
.
DO ix = 1 TO EXTENT(barray):
IF barray[ix] <> "" OR anotarray <> "" THEN DISP barray[ix].
END.
你这个表达式有两个问题:
anotarray or barray
一个是您报告的错误361。该错误是因为您无法一次检查整个数组。您需要检查数组的每个元素。
另一个问题是 OR 比较逻辑值而不是字符值。
所以你可能想写的更像是:
if ( anotearry <> "" or barray[1] <> "" or barray[2] ) then display barray.
我是 progress 4GL 语言的新手。我写了一个逻辑,它试图检查维数组的 <> "" 值并给出语法错误。任何人都可以帮助我在哪里犯错误以及我写的逻辑是否正确?
DEFINE VARIABLE anotarray AS CHARACTER NO-UNDO.
DEFINE VARIABLE barray AS CHARACTER EXTENT 3 NO-UNDO.
ASSIGN
barray[1] = "yes"
barray[2] = "no"
anotarray = ""
.
/***value can be stored randomly in variable barray. so we cannot specify [1],[2],[3] for if condition***/
/***based on req. I need to check both anotarray or barray <> "" ***/
IF (anotarray OR barray ) <> "" THEN DISP barray.
/*** ERROR thrown- An array was specified in an expression, on the right-hand side of an assignment, or as a parameter when no array is appropriate or expected. (361)*** /
此语法无效:IF (anotarray OR barray) <> "" THEN ...
您必须循环遍历数组的所有元素。您可以使用 DO
statement and the EXTENT
function.
此外,您必须将两个变量与空字符串进行比较:IF anotarray <> "" OR barray[ix] <> "" THEN ...
此代码应该有效:
DEFINE VARIABLE anotarray AS CHARACTER NO-UNDO.
DEFINE VARIABLE barray AS CHARACTER EXTENT 3 NO-UNDO.
DEFINE VARIABLE ix AS INTEGER NO-UNDO.
ASSIGN
barray[1] = "yes"
barray[2] = "no"
anotarray = ""
.
DO ix = 1 TO EXTENT(barray):
IF barray[ix] <> "" OR anotarray <> "" THEN DISP barray[ix].
END.
你这个表达式有两个问题:
anotarray or barray
一个是您报告的错误361。该错误是因为您无法一次检查整个数组。您需要检查数组的每个元素。
另一个问题是 OR 比较逻辑值而不是字符值。
所以你可能想写的更像是:
if ( anotearry <> "" or barray[1] <> "" or barray[2] ) then display barray.