Am Sat, 02 Jul 2011 15:40:31 +0100 (BST) schrieb (Ted Harding) <ted.hard...@wlandres.net>:
> On 02-Jul-11 13:55:10, erich hoffmann wrote: [...] > > > > Is it possible to split arguments into single characters so that I > > could > > write > > > > .ch A4a72 > > > > and get the same result, like with the split() function in perl or > > awk? [...] > There is the request .substring which you could use to perform > such operations, provided you write the macro in terms of known > lengths/positions of substrings: > > - Request: .substring str n1 [n2] [...] > > Does this help? > > Ted. This is exactly what I had in mind. It not only helps me in this case, but as well in another project I have in mind. Thanks a lot! I put my macros below. They are a bit complicated, because I need not only e.g. 'A4a72' , but 'A#4a72' (a sharp) and 'Ab4a72', and then I need sometimes the first number ('\*[fing]') underlined. There is just one problem left, the position of the chords on the line; this is why I inserted a \*[space] definition as 2nd argument. I tried to insert tabs, but the distances came out weird. OK but this is a good step and I can work with it. Again, thanks! erich ------------------------ Here is a sample input: .AKK Ab3a°4 "\ " .akk A#3a°4 " " .AKK A3a°4 "\ \ " .akk Ab3a°4 " " .AKK A#3a°4 "\ " .akk A3a°4 Here are the macros: .de AKK .ds bass \\$1 .substring bass 0 0 .ds altt .ds fing \\$1 .substring fing 1 1 .ds chor \\$1 .substring chor 2 -2 .ds chfi \\$1 .substring chfi -1 -1 .if `\\*[fing]`b` \{\ .ds bass \\$1 .substring bass 0 0 .ds altt \\$1 .substring altt 1 1 .ds fing \\$1 .substring fing 2 2 .ds chor \\$1 .substring chor 3 -2 .ds chfi \\$1 .substring chfi -1 -1 \} .if `\\*[fing]`#` \{\ .ds bass \\$1 .substring bass 0 0 .ds altt \\$1 .substring altt 1 1 .ds fing \\$1 .substring fing 2 2 .ds chor \\$1 .substring chor 3 -2 .ds chfi \\$1 .substring chfi -1 -1 \} \} .ds bassP \\*[bass] .ds alttP \s-8\u\\*[altt]\d\s+8 .ds fingP \s-8\d\\*[fing]\u\s+8 .ds chorP \s-8\u\\*[chor]\d\s+8 .ds chfiP \s-8\\*[chfi]\s+8 .ds space \\$2 \f(CB \\*[bassP]\\*[alttP]\\*[fingP]\\*[chorP]\\*[chfiP]\\*[space] \fP .. .de akk .ds Akkord \\$1 .ds bass \\$1 .substring bass 0 0 .ds altt .ds fing \\$1 .substring fing 1 1 .ds chor \\$1 .substring chor 2 -2 .ds chfi \\$1 .substring chfi -1 -1 .if `\\*[fing]`b` \{\ .ds bass \\$1 .substring bass 0 0 .ds altt \\$1 .substring altt 1 1 .ds fing \\$1 .substring fing 2 2 .ds chor \\$1 .substring chor 3 -2 .ds chfi \\$1 .substring chfi -1 -1 \} .if `\\*[fing]`#` \{\ .ds bass \\$1 .substring bass 0 0 .ds altt \\$1 .substring altt 1 1 .ds fing \\$1 .substring fing 2 2 .ds chor \\$1 .substring chor 3 -2 .ds chfi \\$1 .substring chfi -1 -1 \} \} .ds bassP \\*[bass] .ds alttP \s-8\u\\*[altt]\d\s+8 .ds fingP \s-8\d\o´\\*[fing]_´\u\s+8 .ds chorP \s-8\u\\*[chor]\d\s+8 .ds chfiP \s-8\\*[chfi]\s+8 .ds space \\$2 \f(CB \\*[bassP]\\*[alttP]\\*[fingP]\\*[chorP]\\*[chfiP]\\*[space] \fP ..