Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Detecting carriage return in memo field
Message
De
31/07/1998 15:15:08
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00123123
Message ID:
00123164
Vues:
24
This is what I came up with. I'm finding CHR(13)+CHR(10) and replacing it with '\n'. The only thing is that cComment is not continuous string, looks like this:

Comment Line 1\n
Comment Line 2\n
Comment Line 3

I need it to look like this:

Comment Line 1\n Comment Line 2\n Comment Line 3

I thought the following code would do it. (Sorry Michael, you should have already received this)

The output is going into a JavaScript array value and can not have any hard carriage returns.

CLEAR
? SpecChar(CHR(13)+CHR(10),'fieldname','\n')
***
FUNCTION SpecChar
* pcSearchValue = What do I want to replace
* pcFieldName = Where is the data at
* pcInsertValue = What do I want to replace it with
* cComment = Resulting output
* nCnt = Count the number of instances
* nBegin = Where to begin
PARAMETERS pcSearchValue,pcFieldName,pcInsertValue
cComment=''
nCnt=1
nBegin=1
DO WHILE .t.
IF ATC(pcSearchValue,&pcFieldName,nCnt)=0
cComment=cComment+TRIM(SUBSTR(&pcFieldName,nBegin,LEN(&pcFieldName)))
EXIT
ELSE
cComment=cComment+TRIM(SUBSTR(&pcFieldName,nBegin,(ATC(pcSearchValue,&pcFieldName,nCnt))-nBegin)+pcInsertValue+SUBSTR(&pcFieldName,ATC(pcSearchValue,&pcFieldName,nCnt)+1,1))
nBegin=ATC(pcSearchValue,&pcFieldName,nCnt)+LEN(pcInsertValue)
nCnt=nCnt+1
ENDIF
ENDDO
RETURN TRIM(cComment)
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform