Application Development and Automation 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: 
Read only

help

Former Member
0 Likes
781

Hi,

How to get the last character of character value? for example: '1226262M', I wanna get the suffix 'M'. Length of the character can be varying.

Many thanks.

Alia

1 ACCEPTED SOLUTION
Read only

vladimir_golovtchiner
Participant
0 Likes
758

Hi,

try that:

data: len type i,

result(1).

parameters word(20).

len = strlen( word ) - 1.

result = word+len(1).

write result.

best regards

Vladimir

6 REPLIES 6
Read only

Former Member
0 Likes
758

Hi,

Alia can you be much clear plzzzz.

Why means Length of the character or charecter no is varying?

Thanks.

Read only

vladimir_golovtchiner
Participant
0 Likes
759

Hi,

try that:

data: len type i,

result(1).

parameters word(20).

len = strlen( word ) - 1.

result = word+len(1).

write result.

best regards

Vladimir

Read only

Former Member
0 Likes
758

use fm STRING_REVERSE and take 1st character from result.

Read only

Former Member
0 Likes
758

hi,

data i type i,

data x(15) type c,

y type c,

x = '1226262M'

i = strlen( x )

i = i - 2.

y = x+i(1).

cheers,

sasi

Read only

Former Member
0 Likes
758

Hy Alia

you can use the command strlen to get the length of the string.

len = strlen(your_string).

and then use SHIFT.

I put some example code.

data len type i.

data my_string type string value '1226262M'.

len = strlen( my_string ).

len = len - 1.

shift my_string by len.

that's all. In my_string variable you'll have 'M'.

By enzo

Read only

animesh_kumar2
Active Participant
0 Likes
758

Hi,

there are many string manipulation functions so take a look of them first, u will get many ways to do this.

You can measure the length of the string through strlen() function and then shift your string length - 1 place and you will get the desired value.

you can use this:

data: a type string value '1226262M'.

data: b type i.

b = strlen( a ) - 1.

shift a by b places.

write /: a.

Regards,

Animesh