Hello MacScripter.
I’ve got a script that opens a program and find and copy some information.
I would then like to replace some of the information within the tell tags.
Is this possible
When I move the “set the MidiNoteNames to replace_chars(MidiNoteNames, “C-2”, “00”)
etc…” before the end tell tag I get an error message
I’ve tried to minimize the code to only the necessary bits.
Hope that’s ok.
on replace_chars(this_text, search_string, replacement_string)
set AppleScript's text item delimiters to the search_string
set the item_list to every text item of this_text
set AppleScript's text item delimiters to the replacement_string
set this_text to the item_list as string
set AppleScript's text item delimiters to ""
return this_text
end replace_chars
tell application "Finder"
tell application "System Events"
set PT to the first application process whose creator type is "PTul"
tell PT
activate
set frontmost to true
set myList to "C2
D2
F3
A6
F#7"
end tell
end tell
end tell
#These are all the different Midi note names that my program outputs
set the MidiNoteNames to myList as string
#Here I replace the name with a number that I can use in other programs
set the MidiNoteNames to replace_chars(MidiNoteNames, "C-2", "00")
set the MidiNoteNames to replace_chars(MidiNoteNames, "C#-2", "01")
set the MidiNoteNames to replace_chars(MidiNoteNames, "D-2", "02")
set the MidiNoteNames to replace_chars(MidiNoteNames, "Eb-2", "03")
set the MidiNoteNames to replace_chars(MidiNoteNames, "E-2", "04")
set the MidiNoteNames to replace_chars(MidiNoteNames, "F-2", "05")
set the MidiNoteNames to replace_chars(MidiNoteNames, "F#-2", "06")
set the MidiNoteNames to replace_chars(MidiNoteNames, "G-2", "07")
set the MidiNoteNames to replace_chars(MidiNoteNames, "G#-2", "08")
set the MidiNoteNames to replace_chars(MidiNoteNames, "A-2", "09")
set the MidiNoteNames to replace_chars(MidiNoteNames, "Bb-2", "10")
set the MidiNoteNames to replace_chars(MidiNoteNames, "B-2", "11")
set the MidiNoteNames to replace_chars(MidiNoteNames, "C-1", "12")
set the MidiNoteNames to replace_chars(MidiNoteNames, "C#-1", "13")
set the MidiNoteNames to replace_chars(MidiNoteNames, "D-1", "14")
set the MidiNoteNames to replace_chars(MidiNoteNames, "Eb-1", "15")
set the MidiNoteNames to replace_chars(MidiNoteNames, "E-1", "16")
set the MidiNoteNames to replace_chars(MidiNoteNames, "F-1", "17")
set the MidiNoteNames to replace_chars(MidiNoteNames, "F#-1", "18")
set the MidiNoteNames to replace_chars(MidiNoteNames, "G-1", "19")
set the MidiNoteNames to replace_chars(MidiNoteNames, "G#-1", "20")
set the MidiNoteNames to replace_chars(MidiNoteNames, "A-1", "21")
set the MidiNoteNames to replace_chars(MidiNoteNames, "Bb-1", "22")
set the MidiNoteNames to replace_chars(MidiNoteNames, "B-1", "23")
set the MidiNoteNames to replace_chars(MidiNoteNames, "C0", "24")
set the MidiNoteNames to replace_chars(MidiNoteNames, "C#0", "25")
set the MidiNoteNames to replace_chars(MidiNoteNames, "D0", "26")
set the MidiNoteNames to replace_chars(MidiNoteNames, "Eb0", "27")
set the MidiNoteNames to replace_chars(MidiNoteNames, "E0", "28")
set the MidiNoteNames to replace_chars(MidiNoteNames, "F0", "29")
set the MidiNoteNames to replace_chars(MidiNoteNames, "F#0", "30")
set the MidiNoteNames to replace_chars(MidiNoteNames, "G0", "31")
set the MidiNoteNames to replace_chars(MidiNoteNames, "G#0", "32")
set the MidiNoteNames to replace_chars(MidiNoteNames, "A0", "33")
set the MidiNoteNames to replace_chars(MidiNoteNames, "Bb0", "34")
set the MidiNoteNames to replace_chars(MidiNoteNames, "B0", "35")
set the MidiNoteNames to replace_chars(MidiNoteNames, "C1", "36")
set the MidiNoteNames to replace_chars(MidiNoteNames, "C#1", "37")
set the MidiNoteNames to replace_chars(MidiNoteNames, "D1", "38")
set the MidiNoteNames to replace_chars(MidiNoteNames, "Eb1", "39")
set the MidiNoteNames to replace_chars(MidiNoteNames, "E1", "40")
set the MidiNoteNames to replace_chars(MidiNoteNames, "F1", "41")
set the MidiNoteNames to replace_chars(MidiNoteNames, "F#1", "42")
set the MidiNoteNames to replace_chars(MidiNoteNames, "G1", "43")
set the MidiNoteNames to replace_chars(MidiNoteNames, "G#1", "44")
set the MidiNoteNames to replace_chars(MidiNoteNames, "A1", "45")
set the MidiNoteNames to replace_chars(MidiNoteNames, "Bb1", "46")
set the MidiNoteNames to replace_chars(MidiNoteNames, "B1", "47")
set the MidiNoteNames to replace_chars(MidiNoteNames, "C2", "48")
set the MidiNoteNames to replace_chars(MidiNoteNames, "C#2", "49")
set the MidiNoteNames to replace_chars(MidiNoteNames, "D2", "50")
set the MidiNoteNames to replace_chars(MidiNoteNames, "Eb2", "51")
set the MidiNoteNames to replace_chars(MidiNoteNames, "E2", "52")
set the MidiNoteNames to replace_chars(MidiNoteNames, "F2", "53")
set the MidiNoteNames to replace_chars(MidiNoteNames, "F#2", "54")
set the MidiNoteNames to replace_chars(MidiNoteNames, "G2", "55")
set the MidiNoteNames to replace_chars(MidiNoteNames, "G#2", "56")
set the MidiNoteNames to replace_chars(MidiNoteNames, "A2", "57")
set the MidiNoteNames to replace_chars(MidiNoteNames, "Bb2", "58")
set the MidiNoteNames to replace_chars(MidiNoteNames, "B2", "59")
set the MidiNoteNames to replace_chars(MidiNoteNames, "C3", "60")
set the MidiNoteNames to replace_chars(MidiNoteNames, "C#3", "61")
set the MidiNoteNames to replace_chars(MidiNoteNames, "D3", "62")
set the MidiNoteNames to replace_chars(MidiNoteNames, "Eb3", "63")
set the MidiNoteNames to replace_chars(MidiNoteNames, "E3", "64")
set the MidiNoteNames to replace_chars(MidiNoteNames, "F3", "65")
set the MidiNoteNames to replace_chars(MidiNoteNames, "F#3", "66")
set the MidiNoteNames to replace_chars(MidiNoteNames, "G3", "67")
set the MidiNoteNames to replace_chars(MidiNoteNames, "G#3", "68")
set the MidiNoteNames to replace_chars(MidiNoteNames, "A3", "69")
set the MidiNoteNames to replace_chars(MidiNoteNames, "Bb3", "70")
set the MidiNoteNames to replace_chars(MidiNoteNames, "B3", "71")
set the MidiNoteNames to replace_chars(MidiNoteNames, "C4", "72")
set the MidiNoteNames to replace_chars(MidiNoteNames, "C#4", "73")
set the MidiNoteNames to replace_chars(MidiNoteNames, "D4", "74")
set the MidiNoteNames to replace_chars(MidiNoteNames, "Eb4", "75")
set the MidiNoteNames to replace_chars(MidiNoteNames, "E4", "76")
set the MidiNoteNames to replace_chars(MidiNoteNames, "F4", "77")
set the MidiNoteNames to replace_chars(MidiNoteNames, "F#4", "78")
set the MidiNoteNames to replace_chars(MidiNoteNames, "G4", "79")
set the MidiNoteNames to replace_chars(MidiNoteNames, "G#4", "80")
set the MidiNoteNames to replace_chars(MidiNoteNames, "A4", "81")
set the MidiNoteNames to replace_chars(MidiNoteNames, "Bb4", "82")
set the MidiNoteNames to replace_chars(MidiNoteNames, "B4", "83")
set the MidiNoteNames to replace_chars(MidiNoteNames, "C5", "84")
set the MidiNoteNames to replace_chars(MidiNoteNames, "C#5", "85")
set the MidiNoteNames to replace_chars(MidiNoteNames, "D5", "86")
set the MidiNoteNames to replace_chars(MidiNoteNames, "Eb5", "87")
set the MidiNoteNames to replace_chars(MidiNoteNames, "E5", "88")
set the MidiNoteNames to replace_chars(MidiNoteNames, "F5", "89")
set the MidiNoteNames to replace_chars(MidiNoteNames, "F#5", "90")
set the MidiNoteNames to replace_chars(MidiNoteNames, "G5", "91")
set the MidiNoteNames to replace_chars(MidiNoteNames, "G#5", "92")
set the MidiNoteNames to replace_chars(MidiNoteNames, "A5", "93")
set the MidiNoteNames to replace_chars(MidiNoteNames, "Bb5", "94")
set the MidiNoteNames to replace_chars(MidiNoteNames, "B5", "95")
set the MidiNoteNames to replace_chars(MidiNoteNames, "C6", "96")
set the MidiNoteNames to replace_chars(MidiNoteNames, "C#6", "97")
set the MidiNoteNames to replace_chars(MidiNoteNames, "D6", "98")
set the MidiNoteNames to replace_chars(MidiNoteNames, "Eb6", "99")
set the MidiNoteNames to replace_chars(MidiNoteNames, "E6", "100")
set the MidiNoteNames to replace_chars(MidiNoteNames, "F6", "101")
set the MidiNoteNames to replace_chars(MidiNoteNames, "F#6", "102")
set the MidiNoteNames to replace_chars(MidiNoteNames, "G6", "103")
set the MidiNoteNames to replace_chars(MidiNoteNames, "G#6", "104")
set the MidiNoteNames to replace_chars(MidiNoteNames, "A6", "105")
set the MidiNoteNames to replace_chars(MidiNoteNames, "Bb6", "106")
set the MidiNoteNames to replace_chars(MidiNoteNames, "B6", "107")
set the MidiNoteNames to replace_chars(MidiNoteNames, "C7", "108")
set the MidiNoteNames to replace_chars(MidiNoteNames, "C#7", "109")
set the MidiNoteNames to replace_chars(MidiNoteNames, "D7", "110")
set the MidiNoteNames to replace_chars(MidiNoteNames, "Eb7", "111")
set the MidiNoteNames to replace_chars(MidiNoteNames, "E7", "112")
set the MidiNoteNames to replace_chars(MidiNoteNames, "F7", "113")
set the MidiNoteNames to replace_chars(MidiNoteNames, "F#7", "114")
set the MidiNoteNames to replace_chars(MidiNoteNames, "G7", "115")
set the MidiNoteNames to replace_chars(MidiNoteNames, "G#7", "116")
set the MidiNoteNames to replace_chars(MidiNoteNames, "A7", "117")
set the MidiNoteNames to replace_chars(MidiNoteNames, "Bb7", "118")
set the MidiNoteNames to replace_chars(MidiNoteNames, "B7", "119")
set the MidiNoteNames to replace_chars(MidiNoteNames, "C8", "120")
set the MidiNoteNames to replace_chars(MidiNoteNames, "C#8", "121")
set the MidiNoteNames to replace_chars(MidiNoteNames, "D8", "122")
set the MidiNoteNames to replace_chars(MidiNoteNames, "Eb8", "123")
set the MidiNoteNames to replace_chars(MidiNoteNames, "E8", "124")
set the MidiNoteNames to replace_chars(MidiNoteNames, "F8", "125")
set the MidiNoteNames to replace_chars(MidiNoteNames, "F#8", "126")
set the MidiNoteNames to replace_chars(MidiNoteNames, "G8", "127")
MidiNoteNames
Kind Regards,
Anders Wall