cancel
Showing results for 
Search instead for 
Did you mean: 

seperate a string

Former Member
0 Kudos

Hello-

I have a field that is a 'string' which can have 1 value in it, 4 characters, or it can have numerous values in it, up to 240 characters.  The string could look like:

1234

or

123456789012 ....up to 240 characters

It will always be either 4 or in increments of 4.  There is nothing separating the data. I would like it to show every 4 characters + a 'space' + the next 4 characters + 'space', etc.

1234

or

1234 5678 9012

Any help?

thanks!

Accepted Solutions (1)

Accepted Solutions (1)

abhilash_kumar
Active Contributor
0 Kudos

Hi Jennifer,

Try:

stringvar s := {string_field};

numbervar i;

for i := 1 to len(s) STEP 4 do

(

    stringvar s1 := s1 + s[i to i+3] + ' ';

);

s1;

-Abhilash

Former Member
0 Kudos

Hello-

That did not seem to work.  It is picking up the first record and keeping it the same and then adding +1 to each record.

So the first record was (its a ship to code):

MADI which read it correctly

the second record is PERS and returning the data as:

MADIMADIMADIMADI

I should also mention I am grouping on this field as well.  There is not always multiple codes in one string.

thank you


abhilash_kumar
Active Contributor
0 Kudos

If this is being used on the details section, then make the variables 'local', like this:

local stringvar s := {string_field};

local numbervar i;

-Abhilash

Former Member
0 Kudos

It is being used in the group field, not details

abhilash_kumar
Active Contributor
0 Kudos

Make the variables 'local' like I suggested above; that should do the trick.

-Abhilash

Former Member
0 Kudos

This worked, thank you!

Answers (1)

Answers (1)

nilesh_pawar6
Participant
0 Kudos

Hi Jennifer,

use this only

stringvar s := {string_field};

numbervar i;

for i := 1 to len(s) STEP 4 do

(

    stringvar s1 := s1 + s[i to i+3] + ' ';

);

s1;

in field format of group field (right click to goup field> Format Field>Display string )

open its formula window and paste above expression.

It will definately work.

i try this scenario in my report        field value                 20150218155527323699001

                                                       outpout printed         2015 0218 1555 2732 3699 001

Regards,

Nilesh