Page 1 of 1

Remove Tab space

Posted: September 29th, 2018, 2:18 pm
by khurshid.arshad
Dear Team;

How can i remove Tab Space from the text.
I am using bar code scanner to scan bar during interview.

Best regards.
a.

Re: Remove Tab space

Posted: October 1st, 2018, 1:44 am
by aaronw
I would write a user-defined function to handle this. I wrote a naive example that removes spaces to give you the general idea. As I loop through the string I ignore any space, but copy all other characters. After the function has run my new string will have no spaces.
function string removeSpaces(string strIn)

    string strOut;
    numeric len = length(strIn);
    numeric j = 1;

    do numeric i = 1 while i <= len
        if strIn[i:1] <> " " then
            strOut[j:1] = strIn[i:1];
            inc(j);
        endif;
    enddo;

    removeSpaces = strOut;

end;

Re: Remove Tab space

Posted: October 2nd, 2018, 8:12 am
by khurshid.arshad
Dear;

Thank you for the reply.

I don't want to remove this space because based on these spaces i am extracting text.

The other thing is, this is not a simple space, it is a tab space.

Thanks.
a.

Re: Remove Tab space

Posted: October 2nd, 2018, 8:14 am
by josh
It is not possible to enter a tab character in CSEntry. Tab moves you to the next field.

Re: Remove Tab space

Posted: October 2nd, 2018, 10:10 am
by khurshid.arshad
Dear Josh


Actually i am using a bar code scanner from the play store to scan Bar on my tablet.

When i scan and past the text and press next to extract text based on the space it does not work because this space is tab ( i think so).

When i remove this space and give the space manually then it works.

So my question is, how can i replace this space with actual space.

Best regards.
a.

Re: Remove Tab space

Posted: October 2nd, 2018, 10:39 am
by josh
You are right, you can enter a tab character by pasting. You should be able to check for a tab character in logic by testing if a character is equal to " " (in case it doesn't look correct on the forum, that is a double quote followed by hitting the tab key followed by another double quote). To replace the tab with a space you would do something like the following:
do numeric i = 1 while i <= length(MYFIELD)
    
if MYFIELD[i:1] = " " then
        MYFIELD[i:
1] = " ";
    
endif;
enddo;
Note that in the if condition it is a tab character (" + tab + ") and not a space but in the assignment statement below it is a space.