Reputation: 177
I am new to progress 4GL language. I have written a logic which is trying to check <> "" values for dimensional arrays and giving syntax error. Can anyone pls help me where I am making mistakes and the logic I written is correct or not?
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)*** /
Upvotes: 0
Views: 770
Reputation: 14020
You have two problems in this expression:
anotarray or barray
One is the error 361 that you have reported. That error is because you cannot check the entire array all at once. You need to check each element of the array.
The other issue is that OR compares logical values not character values.
So what you probably want to write is something more like:
if ( anotearry <> "" or barray[1] <> "" or barray[2] ) then display barray.
Upvotes: 4
Reputation: 5667
This syntax is not valid : IF (anotarray OR barray) <> "" THEN ...
You have to cycle through all elements of your array. You can do it using a DO
statement and the EXTENT
function.
Also, you have to compare both variables to the empty string : IF anotarray <> "" OR barray[ix] <> "" THEN ...
This code should work :
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.
Upvotes: 5