Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

identify dynamicly the last character of a character string

Former Member
0 Kudos

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

1 ACCEPTED SOLUTION

Former Member
0 Kudos
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.
6 REPLIES 6

Former Member
0 Kudos
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.

0 Kudos

hi.

data

w_char type string.

w_strlen = strlen( w_char).

w_strlen = w_strlen - 1.

write w_char+w_strlen(1).

regards,

ananth.

Former Member
0 Kudos

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

Former Member
0 Kudos

Hi,

use SHIFT v_STR circular.

then

v_letter = v_str+0(1).

regards,

anji

Former Member
0 Kudos

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

Former Member
0 Kudos

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.