Remove Tab space

Discussions about CSEntry
Forum rules
New release: CSPro 8.0
Post Reply
khurshid.arshad
Posts: 571
Joined: July 9th, 2012, 11:32 am
Location: Islamabad, Pakistan

Remove Tab space

Post 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.
aaronw
Posts: 561
Joined: June 9th, 2016, 9:38 am
Location: Washington, DC

Re: Remove Tab space

Post 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;
khurshid.arshad
Posts: 571
Joined: July 9th, 2012, 11:32 am
Location: Islamabad, Pakistan

Re: Remove Tab space

Post 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.
josh
Posts: 2399
Joined: May 5th, 2014, 12:49 pm
Location: Washington DC

Re: Remove Tab space

Post by josh »

It is not possible to enter a tab character in CSEntry. Tab moves you to the next field.
khurshid.arshad
Posts: 571
Joined: July 9th, 2012, 11:32 am
Location: Islamabad, Pakistan

Re: Remove Tab space

Post 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.
josh
Posts: 2399
Joined: May 5th, 2014, 12:49 pm
Location: Washington DC

Re: Remove Tab space

Post 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.
Post Reply