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

dynamic length String manipulation

Former Member
0 Likes
1,569

Hi Folks,

I want to get a variable which contains '*'.

But length will decide dynamically.

Can anyone help me in this?

length = strlen (input) - 4.

do length times

concatnate length '*' into mask.

enddo.

But here i want to have '*' marks length times in mask.

Thanks in advance.

Rgds

Bhavani

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,310

hi,

i don't know whether i understannd your probs

data mask(100) type c.

length = strlen (input) - 4.

clear mask.

do length times

concatnate mask '*' into mask.

enddo.

cheers,

sasi

10 REPLIES 10
Read only

Former Member
0 Likes
1,310

Try this

data test(30)

data num type i.

num = 5.

clear test(num) with '*'.

write test.

Cheers.

Read only

Former Member
0 Likes
1,311

hi,

i don't know whether i understannd your probs

data mask(100) type c.

length = strlen (input) - 4.

clear mask.

do length times

concatnate mask '*' into mask.

enddo.

cheers,

sasi

Read only

0 Likes
1,310

Hi Sasi,

I tried the same, but not working.

By end of stmt it is having only one '*'.

It should contain length number of times the '*'.

Thanks

Bhavani

Read only

0 Likes
1,310

Did you try this

<b>data mask(100) type c.

length = strleninput) - 4.

clear mask(length) with '*'.</b>

Check in debugging if length has correct value.

cheers.

Read only

0 Likes
1,310

hi

this should work,

check your variable length (mask)

data mask(100) type c.

data length type i value 10.

clear mask.

do length times.

concatenate mask '*' into mask.

enddo.

cheers,

sasi

Read only

0 Likes
1,310

Sanjay,

In debugging it is taking only 1 char length.

Cheers

Read only

0 Likes
1,310

Hi

try this

data mask(100) type c.

data pos type i.

length = strlen (input) - 4.

clear mask.

do length times.

write '*' to mask+pos(1).

pos = pos + 1.

enddo.

Max

Read only

0 Likes
1,310

So then the problem is with

length = strlen (input) - 4.

Check what is the value in length after this staement .

Cheers.

Read only

0 Likes
1,310

Hi,

The code given by sasi is working correctly. when you are saying that "<i>By end of stmt it is having only one ''.It should contain length number of times the ''.</i>", did you check the value of LENGTH?

Thanks,

Rajeev

Read only

Former Member
0 Likes
1,310

for dynamic length use a string type variable

try this code...

data : t1 type string.

str type c.

str = '*'.

do length times. "length is your calculated variable

concatenate t1 str into t1.

enddo.

write 😕 t1.

rgds,

PJ