Posiblyquotename issue?
ubi
I am using version 6.2.2.2.
I wrote a function (which used to work fine) which automatically quote the path name of the waves which are availiable.
FUNCTION/S Quoted(path)
string path
variable i
for(i=0;i<itemsinlist(path,":");i+=1)
path=ReplaceString(StringFromList(i, path,":"), path, PossiblyQuoteName(StringFromList(i, path,":")))
endfor
return path
END
string path
variable i
for(i=0;i<itemsinlist(path,":");i+=1)
path=ReplaceString(StringFromList(i, path,":"), path, PossiblyQuoteName(StringFromList(i, path,":")))
endfor
return path
END
I noticed last week that the output of this function gives me now a wrong path. E.g. for a wave with the path root:Data:0708M9:0708M9_up, the function returns root:Data:'0708M9':'0708M9'_up which in turn induces a lot of other errors in my other function.
I did not noticed such errors before. Maybe something changed in the code of the igor functions changed?
Does someone have an idea?
I tried it in Igor Pro 6.06, 6.12 and 6.22A and got the same result (root:Data:'0708M9':'0708M9'_up). However PossiblyQuoteName("0708M9_up") returns the right thing in all versions.
Here is my rewrite of your function to make it clearer. Also it returns the right thing for "root:Data:0708M9:0708M9_up".
String path
Variable len = strlen(path)
if (len == 0)
return ""
endif
String pathOut = ""
Variable i
Variable numItems = ItemsInList(path,":")
for(i=0; i<numItems; i+=1)
String item = StringFromList(i, path,":")
String quotedItem = PossiblyQuoteName(item)
if (strlen(pathOut) > 0)
pathOut += ":"
endif
pathOut += quotedItem
// Printf "%d, \"%s\", \"%s\", \"%s\"\r", i, item, quotedItem, pathOut
endfor
String lastChar
lastChar = path[len-1]
if (CmpStr(lastChar,":") == 0)
pathOut += ":"
endif
return pathOut
End
<pre><code class="language-igor">
July 10, 2011 at 11:48 pm - Permalink
You can fix this by adding ", 0, 1" to the end of your ReplaceString call. This sets two optional parameters, caseSensitive=0 and maxReplacements=1.
I still prefer my version because it is easier to understand.
July 10, 2011 at 11:57 pm - Permalink
Thank you very much!!
July 11, 2011 at 12:55 am - Permalink