Information générale
Catégorie:
Codage, syntaxe et commandes
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
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement