Reputation: 177
I am new to progress 4gl but don't know how to write a logic to get the last value after the last comma and last before value using comma separator. Please help
define variable cdata as character no-undo initial "1,14,13,45".
define variable lvc_data1 as character no-undo.
define variable lvc_data2 as character no-undo.
Expected Results to be assigned (using only separator):
lvc_data1 = "45"
lvc_data2 = "1,14,13"
Upvotes: 0
Views: 381
Reputation: 7192
The last element is easy with ENTRY and NUM-ENTRIES. For the other ones, I'm using SUBSTRING and R-INDEX:
define variable cdata as character no-undo initial "1,14,13,45".
define variable lvc_data1 as character no-undo.
define variable lvc_data2 as character no-undo.
MESSAGE ENTRY (NUM-ENTRIES (cdata), cdata) SKIP
SUBSTRING (cdata, 1, R-INDEX (cdata, ",") - 1 )
VIEW-AS ALERT-BOX INFORMATION BUTTONS OK.
Upvotes: 3