Reputation: 17
Let's say I wanted to do a FOR EACH of 3 tables/fields:
slmast.name
slmast.acode
slmast.address.
Usually, they are presented neatly with nothing separating them.
However, would I also be able to use the DELIMITER statement to separate them, or add commas/ speech marks?
For example:
FOR EACH slmast.
DISPLAY (DELIMITER) "," slmast.name slmast.acode slmast.address
Upvotes: 0
Views: 189
Reputation: 7192
You should use the SUBSTITUTE() function:
FOR EACH slmast NO-LOCK:
DISPLAY
SUBSTITUTE ("&1,&2,&3", slmast.name, slmast.acode, slmast.address) FORMAT "x(60)"
.
END.
Upvotes: 2
Reputation: 14020
No, DELIMITER is not an option for DISPLAY.
You could do as Mike suggests and build a string with SUBSTITUTE or you could add the desired commas like so:
for each slmast no-lock:
display
name + "," format "x(30)"
acode + ","
address + "," format "x(30)"
.
end.
This will make nice columns if that's what you want whereas Mike's code will eliminate spaces - which, alternatively, might be what you want.
You need the FORMAT phrase if the width will exceed the default format of 8. I left acode unadorned to show the default.
Upvotes: 2