General information
Category:
Coding, syntax & commands
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)
Previous
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only