09-27-2005 9:59 AM
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
09-27-2005 10:05 AM
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
09-27-2005 10:03 AM
Hi,
Alia can you be much clear plzzzz.
Why means Length of the character or charecter no is varying?
Thanks.
09-27-2005 10:05 AM
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
09-27-2005 10:06 AM
09-27-2005 10:06 AM
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
09-27-2005 10:14 AM
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
09-27-2005 10:42 AM
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