proc Penta() integer tempo=0, tempo2=0, rc=0, i=0, min1,max1,min2,max2,min3,max3 integer min4,max4,min5,max5, tsum, offset, av14, av15, av24, av25, av3 string stempo[8], stempo2[8], buildline[80], spos[8], stem[5] GoToLine(2) //Looking for tempo GoToColumn(2) rc = lFind("Tempo","c") //Look for "Tempo" in Col 2 line 2. if (rc == 0) Warn("A tempo marking must preceed the pentuplets") Exit() endif lfind("[0-9]#","cx") //Look for the first digits on this line stempo = GetFoundText() //Read the found string tempo = Val(stempo) //Convert to integer tempo2 = tempo * 5 / 4 //Find the tempo during the pentuplets stempo2= Str(tempo2) //Convert back to string DelLine() //Replace the tempo line, this & next two lines buildline=Format("|Tempo|Tempo:",stempo2,"|Pos:8|Visibility:Never") InsertLine(buildline) // Warn("Tempo: ",tempo," ,tempo2: ",tempo2) // Warn(stempo," ",stempo2) for i=3 to 7 //Checking for a note or chord ONLY GoToLine(i) GoToColumn(2) if lfind("{Note}|{Chord}","cx") else rc = 0 Warn("Line ",i," was not a note or chord") endif GoToColumn(2) if lfind("Dur:16th","c") else rc = 0 Warn("Line ",i," was not a 16th") endif lReplace("\|Opts:.*$","","cxn") endfor if (rc == 0) Warn("I can only process notes and chords.") Exit() endif // The next section determines the highest and lowest note of each // chord, used to determine stem direction and the location of the "5" // above (or below) the beamed pentuplets. I wish Semware supported // arrays so I wouldn't have five copies of the following. GoToLine(3) GoToColumn(2) if (lFind("Note","c")) lfind("Pos:","c") //Find where the note is. lfind("-*[0-9]#","+xc") //Next char, reg expression, current line spos=GetFoundText() //Look for - sign & max number of digits min1= Val(spos) // Convert from string to integer max1= min1 // Only one note so they are same. else //Must be a chord lfind("Pos:","c") //Find where the note is. lfind("-*[0-9]#","+xc") //Next char, reg expression, current line spos=GetFoundText() //Look for - sign & max number of digits min1= Val(spos) // Convert from string to integer EndLine() // go to end of line and backup lfind("-*[0-9]#","bxc") //Backwards char, reg expression, current line spos=GetFoundText() //Look for - sign & max number of digits max1= Val(spos) endif // Warn("Min pos is: ",min1," max pos is: ",max1) GoToLine(4) GoToColumn(2) if (lFind("Note","c")) lfind("Pos:","c") //Find where the note is. lfind("-*[0-9]#","+xc") //Next char, reg expression, current line spos=GetFoundText() //Look for - sign & max number of digits min2= Val(spos) // Convert from string to integer max2= min2 // Only one note so they are same. else //Must be a chord lfind("Pos:","c") //Find where the note is. lfind("-*[0-9]#","+xc") //Next char, reg expression, current line spos=GetFoundText() //Look for - sign & max number of digits min2= Val(spos) // Convert from string to integer EndLine() // go to end of line and backup lfind("-*[0-9]#","bxc") //Backwards char, reg expression, current line spos=GetFoundText() //Look for - sign & max number of digits max2= Val(spos) endif // Warn("Min pos is: ",min2," max pos is: ",max2) GoToLine(5) GoToColumn(2) if (lFind("Note","c")) lfind("Pos:","c") //Find where the note is. lfind("-*[0-9]#","+xc") //Next char, reg expression, current line spos=GetFoundText() //Look for - sign & max number of digits min3= Val(spos) // Convert from string to integer max3= min3 // Only one note so they are same. else //Must be a chord lfind("Pos:","c") //Find where the note is. lfind("-*[0-9]#","+xc") //Next char, reg expression, current line spos=GetFoundText() //Look for - sign & max number of digits min3= Val(spos) // Convert from string to integer EndLine() // go to end of line and backup lfind("-*[0-9]#","bxc") //Backwards char, reg expression, current line spos=GetFoundText() //Look for - sign & max number of digits max3= Val(spos) endif // Warn("Min pos is: ",min3," max pos is: ",max3) GoToLine(6) GoToColumn(2) if (lFind("Note","c")) lfind("Pos:","c") //Find where the note is. lfind("-*[0-9]#","+xc") //Next char, reg expression, current line spos=GetFoundText() //Look for - sign & max number of digits min4= Val(spos) // Convert from string to integer max4= min4 // Only one note so they are same. else //Must be a chord lfind("Pos:","c") //Find where the note is. lfind("-*[0-9]#","+xc") //Next char, reg expression, current line spos=GetFoundText() //Look for - sign & max number of digits min4= Val(spos) // Convert from string to integer EndLine() // go to end of line and backup lfind("-*[0-9]#","bxc") //Backwards char, reg expression, current line spos=GetFoundText() //Look for - sign & max number of digits max4= Val(spos) endif // Warn("Min pos is: ",min4," max pos is: ",max4) GoToLine(7) GoToColumn(2) if (lFind("Note","c")) lfind("Pos:","c") //Find where the note is. lfind("-*[0-9]#","+xc") //Next char, reg expression, current line spos=GetFoundText() //Look for - sign & max number of digits min5= Val(spos) // Convert from string to integer max5= min5 // Only one note so they are same. else //Must be a chord lfind("Pos:","c") //Find where the note is. lfind("-*[0-9]#","+xc") //Next char, reg expression, current line spos=GetFoundText() //Look for - sign & max number of digits min5= Val(spos) // Convert from string to integer EndLine() // go to end of line and backup lfind("-*[0-9]#","bxc") //Backwards char, reg expression, current line spos=GetFoundText() //Look for - sign & max number of digits max5= Val(spos) endif // Warn("Min pos is: ",min5," max pos is: ",max5) tsum = max1 + min1 + max2 + min2 + max3 + min3 + max4 + min4 + max5 + min5 if (tsum < 0) stem = "Up" offset = 9 av3 = max3 else stem = "Down" offset = -9 av3 = min3 endif if offset > 0 // Stem up, looking for highest note to place the "5" av14 = (max1 + max4) / 2 av15 = (max1 + max5) / 2 av24 = (max2 + max4) / 2 av25 = (max2 + max5) / 2 av3 = iif ( av14 > av3, av14, av3) av3 = iif ( av15 > av3, av15, av3) av3 = iif ( av24 > av3, av24, av3) av3 = iif ( av25 > av3, av25, av3) else av14 = (min1 + min4) / 2 av15 = (min1 + min5) / 2 av24 = (min2 + min4) / 2 av25 = (min2 + min5) / 2 av3 = iif ( av14 < av3, av14, av3) av3 = iif ( av15 < av3, av15, av3) av3 = iif ( av24 < av3, av24, av3) av3 = iif ( av25 < av3, av25, av3) endif offset = offset + av3 buildline = Format("|Opts:Stem=",stem,",Beam") for i = 3 to 7 // Beam the notes GoToLine(i) GoToColumn(10) lReplace("$",buildline,"xcn") if (i == 3) lReplace("$","=First","xcn") elseif (i == 7) lReplace("$","=End","xcn") endif // Warn("i = ",i) endfor buildline = Format('|Text|Text:"5"|Font:StaffItalic|Pos:', offset, '|Justify:Right|Placement:AtNextNote') GoToLine(5) InsertLine(buildline) GoToLine(9) buildline=Format("|Tempo|Tempo:",stempo,"|Pos:8|Visibility:Never") InsertLine(buildline) end proc Main() //Remove digits from clipboard PasteFromWinClip() //Copy from system clipboard Penta() GoToLine(1) //Prep to mark all editspace MarkLine() //Mark from front end EndFile() //Go to last line MarkLine() //Entire editspace is marked CopyToWinClip() // and will be written back to clipboard AbandonEditor() //Shutdown w/o prompt to save. end