How to remove CRLF from a string

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

Post Reply
Tiger
Posts: 74
Joined: Mon Aug 31, 2015 11:28 am
Location: Taipei

How to remove CRLF from a string

Post by Tiger »

I get a string from excel and I need to remove the CRLF from the string. I test following codes but it can't work... :(

G_VISITOR := ALLTRIM(Cell2CHR(aExcel[i,2]))
IF AT(CHR(13)+CHR(10), G_VISITOR) > 0
STRTRAN(G_VISITOR,CHR(13)=cHR(10),"")
ENDIF

Thanks for any help.
Tiger
Posts: 74
Joined: Mon Aug 31, 2015 11:28 am
Location: Taipei

Re: How to remove CRLF from a string

Post by Tiger »

Sorry , a typo .... STRTRAN(G_VISITOR,CHR(13)+cHR(10),"")
ASESORMIX
Posts: 216
Joined: Thu Oct 25, 2012 8:08 pm
Location: Bqto, Venezuela

Re: How to remove CRLF from a string

Post by ASESORMIX »

G_VISITOR := STRTRAN(G_VISITOR,CHR(13)+cHR(10),"")
Tiger
Posts: 74
Joined: Mon Aug 31, 2015 11:28 am
Location: Taipei

Re: How to remove CRLF from a string

Post by Tiger »

Thanks for your help, but it can't work...

what I want is to convert following string to single line.

From

AA、
BB、
CC、
DD、
EE、
FF、
GG

To

AA、BB、CC、DD、EE、FF、GG

Thanks.
ASESORMIX
Posts: 216
Joined: Thu Oct 25, 2012 8:08 pm
Location: Bqto, Venezuela

Re: How to remove CRLF from a string

Post by ASESORMIX »

Code: Select all


SALTO := CHR(13)+CHR(10)

G_VISITOR := "AA,"+SALTO+"BB,"+SALTO+"CC,"+SALTO+"DD,"+SALTO+"EE,"+SALTO
MSGDEBUG( G_VISITOR  )
MSGINFO( G_VISITOR  )

G_VISITOR := STRTRAN( G_VISITOR, SALTO ,"")    
MSGDEBUG( G_VISITOR  )
MSGINFO( G_VISITOR  )

ASESORMIX
Posts: 216
Joined: Thu Oct 25, 2012 8:08 pm
Location: Bqto, Venezuela

Re: How to remove CRLF from a string

Post by ASESORMIX »

Surely, there is another character present. this character could be a tab ( chr(9) )
edk
Posts: 999
Joined: Thu Oct 16, 2014 11:35 am
Location: Poland

Re: How to remove CRLF from a string

Post by edk »

IMHO better solution is to use G_VISITOR := hb_StrReplace( G_VISITOR, CRLF, "")
This function will remove all CR and/or LF
Tiger
Posts: 74
Joined: Mon Aug 31, 2015 11:28 am
Location: Taipei

Re: How to remove CRLF from a string

Post by Tiger »

Many thanks for all your help, now it works by using this function hb_StrReplace( G_VISITOR, CRLF, "")
Post Reply