Carl I think the delimiter is (hex) C3 BF
This looks to be UTF-8 encoding of a high values byte (FFh). In fact you can see the EF BB BF (hex) first three characters in the file which are the UTF-8 byte order mark.
Someone (me?) should make a little utility “CwFindClean” to make it easy to zap.
OK then, never one to shirk a challenge when it involves string manipulation I have knocked up function to do this using StringTheory (my favourite third party tool).
As always there are numerous ways to do these things - you might, for example, think to do a split on the entries then delete excess entries from the lines queue and then join the remaining entries. While Split and Join are fast, they are not needed in this case.
TrimProperty PROCEDURE (STRING pFileName,STRING pProperty,STRING pDelim,LONG pEntriesToRetain=20)
st StringTheory
lStart Long
lEnd Long
CODE
if ~st.loadFile(pFileName) then stop('failed to load file' & clip(pFileName) & '<13,10>Error: ' & st.LastError); return.
st.findBetweenPosition('<' & clip(pProperty) & ' value="','" />', lStart, lEnd)
if lStart <= 0 or lStart > lEnd then return.
loop pEntriesToRetain times
lStart = st.findChars(pDelim,lStart+1,lEnd)
if ~lStart then break.
end
if lStart ! if more entries than desired, make a backup then remove extra entries
st.saveFile(TimeStampFileName(pFileName))
st.removeFromPosition(lStart, lEnd - lStart + 1) ! remove extra entries
st.saveFile(pFileName)
end
I put the time-stamping of the file name (used above to create a backup) into a separate procedure as it is likely to be reusable:
TimeStampFileName PROCEDURE (STRING pFileName)
st StringTheory
CODE
if ~pFileName then return ''.
st.setvalue(st.PathOnly(pFileName))
st.append(st.FileNameOnly(pFileName,false) & ' on ' & format(today(),@d12) & |
' at ' & format(clock(),@T05) & format(clock()%100,@N02) & |
'.' & st.ExtensionOnly(pFileName),,'\')
return st.getValue()
as I always say, with ST you can accomplish a lot with just a few lines of code.
OK to use it:
TrimProperty(‘C:\Users\Geoff\AppData\Roaming\SoftVelocity\Clarion\11.0\ClarionProperties.xml’,‘FindPatterns’,‘<0C3h,0BFh>’)
or
myFile = 'C:\Users\Geoff\AppData\Roaming\SoftVelocity\Clarion\11.0\ClarionProperties.xml'
TrimProperty(myFile,'FindPatterns','<0C3h,0BFh>')
that will retain the default 20 entries.
what if I want to retain 50 entries?
TrimProperty(myFile,‘FindPatterns’,‘<0C3h,0BFh>’,50)
what if I want to clear it out completely?
TrimProperty(myFile,‘FindPatterns’,‘<0C3h,0BFh>’,0)
and clear out ReplacePatterns?
TrimProperty(myFile,‘ReplacePatterns’,‘<0C3h,0BFh>’,0)
anyway hopefully that will be of use
cheers
Geoff R