Okay so we have a list 'p' constituting of elements as pin names.
p = ("GIO<0>" "G1E<1>" "GAE2<2>" "G3F1<3>")
And the task is to add the under-braces numeric value with 4 and convert this array into
p = ("GIO<4>" "G1E<5>" "GAE2<6>" "G3F1<7>")
I did these operations in perl and also bridged the gap between perl and skill.
But since this script has to be linked to a bind key hence I want to do the string operations in skill only. Is there any skill code or so by which we can edit the numeric portion ( only under the braces) of the string and then return it back to the 'p' array?
Here is one way to do it:
p = list("GIO<0>" "G1E<1>" "GAE2<2>" "G3F1<3>")
procedure(myAdjustBit(nameList delta) let((newNameList parsed prefix suffix newSuffix newName) foreach(name nameList parsed=parseString(name "<>") prefix=car(parsed) suffix=evalstring(cadr(parsed)) newSuffix=suffix+delta newName=sprintf(nil "%s<%d>" prefix newSuffix) newNameList = cons(newName newNameList) ) reverse(newNameList) ) ;let) ;proc
In reply to dmay:
Thanks, Derek. I had forgotten that parseString can take more than one parsing character