Working with text in Igor Pro
Igor's string toolkit is small and every piece of it is a function.
Function/S CleanName(String raw)
String name = TrimString(raw)
name = ReplaceString(" ", name, "_")
name = LowerStr(name)
if (strlen(name) == 0)
return "unnamed"
endif
if (StringMatch(name, "temp*"))
name = "scratch_" + name
endif
return name
End
How it works
strlen,cmpstrandstringmatchmeasure and compare.num2strandstr2numcross between text and numbers.ReplaceStringandUpperStrreturn a new string, as everything does.
Keywords and builtins used here
EndFunctionLowerStrReplaceStringStringStringMatchTrimStringendififreturnstrlen
The run, in numbers
- Lines
- 15
- Characters to type
- 249
- Tokens
- 60
- Three-star pace
- 75 tpm
At the three-star pace of 75 tokens a minute, this run takes about 48 seconds.
Step 1 of 4 in Text, step 12 of 18 in Language basics.