Fill A Long Text String

Accepted Solution Solved
Reply
Super Contributor
Posts: 358
Accepted Solution

Fill A Long Text String

Hi All:

I have a 1000 character variable that I would like to fill a large portion with '0' (zeros).

I tried substr(myfield,100,900) = 900*'0';

This worked (almost) - generating a

Character values have been converted to numeric values at the places given by: (Line)Smiley SadColumn).

But the record was not filled with the zeros.

So - I used a do loop and it worked, by loading 1 byte at a time.

Is there any way to load the file with a more simple statement?


Accepted Solutions
Solution
‎07-17-2013 12:16 PM
Super User
Posts: 5,503

Re: Fill A Long Text String

Try it this way:

substr(myfield,100,900) = repeat('0', 899);

Note that 899 is correct, not 900.  This says start with '0', then repeat it an additional 899 times.

Should do the trick.

View solution in original post


All Replies
Super User
Posts: 19,789

Re: Fill A Long Text String

You can use translate to convert characters you want to 0. Can you provide more details of what you're trying to do?

Solution
‎07-17-2013 12:16 PM
Super User
Posts: 5,503

Re: Fill A Long Text String

Try it this way:

substr(myfield,100,900) = repeat('0', 899);

Note that 899 is correct, not 900.  This says start with '0', then repeat it an additional 899 times.

Should do the trick.

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 2 replies
  • 160 views
  • 0 likes
  • 3 in conversation