Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

PROGRESS 4GL – does IF condition supports for dimensional array?

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)*** /

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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.
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading