03-15-2007 2:10 PM
Hello Dear!
Is there way to identify dynamicly the last character of a character string
e.g.
char a = 'hallooooooooo:)'.
the searched and find character is )
or
char b = '56565544fgfhjhgg#'.
the searched and find character is #.
Regards
Ilhan
03-15-2007 2:13 PM
data : v_char(15) value 'hallooooooooo:)',
v_last(1),
v_len type i.
v_len = strlen( v_char ).
v_len = v_len - 1.
v_last = v_char+v_len(1).
write : v_last.
03-15-2007 2:13 PM
data : v_char(15) value 'hallooooooooo:)',
v_last(1),
v_len type i.
v_len = strlen( v_char ).
v_len = v_len - 1.
v_last = v_char+v_len(1).
write : v_last.
03-15-2007 2:18 PM
hi.
data
w_char type string.
w_strlen = strlen( w_char).
w_strlen = w_strlen - 1.
write w_char+w_strlen(1).
regards,
ananth.
03-15-2007 2:14 PM
Hello,
Do like this:
DATA : V_FILE TYPE STRING .
DATA: LEN TYPE I.
V_FILE = ''56565544fgfhjhgg#'.
LEN = STRLEN( V_FILE ).
LEN = LEN - 1.
WRITE: V_FILE+LEN(1).
Output will be #
Regards,
Vasanth
03-15-2007 2:15 PM
Hi,
use SHIFT v_STR circular.
then
v_letter = v_str+0(1).
regards,
anji
03-15-2007 2:19 PM
Hi Ertas,
Calculate the length of character variable and get the last character.
DATA b(15) value '56565544fgfhjhgg#'.
data v_length type i.
v_length = strlen( b ).
write:/ 'Last character is: ', b+v_length(1).
Thanks,
Vinay
03-15-2007 2:25 PM
Just a warning to everyone who has proposed an answer based on (string length - 1) as the offset, you also need to take care of the null string. Otherwise you may get a runtime errror.
So you need to put your code within if strelen > 0. endif.