hi
and happy new year
i need help.
i would like to save a variable in a repeat.
sorry not easy to explain.
i’ve 1 variable who change in the repeat and i try to save the variable in each repeat.
activate application "Pro Tools"
tell application "System Events"
tell process "Pro Tools"
tell (1st window whose title contains "Edit: ")
delay 0.1
--count the number of selected track
set trck to (count of static text of UI element 2 of (every row of table 3 whose selected is true))
--repeat with count
repeat with a from 1 to trck
--value of tc in
set deb to get value of text field 1 of group 4
--select next cue in pro tools
key code 48 using control down
log deb
end repeat
end tell
end tell
end tell
the log message it’s what a i’ m trying to save
(01:00:00:05)
(01:00:00:09)
(01:00:02:01)
(01:00:02:19)
(01:00:04:19)
(01:00:05:09)
(01:00:06:06)
(01:00:07:23)
but no success
sorry but it’s really hard to explain.
Thank you in advance.
best
-- defines the path of the log file --Edit to fit your need
set targetFile to (path to desktop as text) & "myReport_tropeRyM.txt"
set quitBtn to "Quit"
set resetBtn to "Reset the log"
set appendBtn to "Append to existing log"
set myChoice to display dialog "What want you to do ?" buttons {quitBtn, resetBtn, appendBtn} default button appendBtn cancel button quitBtn
set myChoice to button returned of myChoice
if myChoice is resetBtn then
my writeTo(targetFile, "", «class utf8», false) --
end if
activate application "Pro Tools"
tell application "System Events"
tell process "Pro Tools"
tell (1st window whose title contains "Edit: ")
delay 0.1
--count the number of selected track
set trck to (count of static text of UI element 2 of (every row of table 3 whose selected is true))
--repeat with count
repeat with a from 1 to trck
--value of tc in
set deb to get value of text field 1 of group 4
--select next cue in pro tools
key code 48 using control down
log deb
-- append sequentially the value deb in a text file.
my writeTo(targetFile, (deb as text) & linefeed, «class utf8», true)
end repeat
end tell
end tell
end tell
#=====
(*
Handler borrowed to Regulus6633 - http://macscripter.net/viewtopic.php?id=36861
*)
on writeTo(targetFile, theData, dataType, apendData)
-- targetFile is the path to the file you want to write
-- theData is the data you want in the file.
-- dataType is the data type of theData and it can be text, list, record etc.
-- apendData is true to append theData to the end of the current contents of the file or false to overwrite it
try
set targetFile to targetFile as «class furl»
set openFile to open for access targetFile with write permission
if not apendData then set eof openFile to 0
write theData to openFile starting at eof as dataType
close access openFile
return true
on error
try
close access file targetFile
end try
return false
end try
end writeTo
#=====
Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) dimanche 12 janvier 2020 22:33:49
set forTests to true -- Edit to fit your need
-- true --> create a set of fake values
-- false --> use Protool
-- defines the path of the log file -- Edit to fit your need
set targetFile to (path to desktop as text) & "myReport_tropeRyM.txt"
set cancelBtn to "Cancel"
set resetBtn to "Reset the log"
set appendBtn to "Append to existing log"
set readInClip to "read to clipboard"
set readInTEdit to "read with TextEdit"
set myWorksheet to "Numbers"
set readInWorksheet to "read with " & myWorksheet
set OKbtn to "OK"
set myChoice to choose from list {resetBtn, appendBtn, readInClip, readInTEdit, readInWorksheet} with title "What want you to do ?" OK button name OKbtn cancel button name cancelBtn without multiple selections allowed
if myChoice is false then return -- Hit Cancel
set myChoice to item 1 of myChoice
if myChoice is readInClip then
try
set the clipboard to (read file targetFile as «class utf8»)
end try
else if myChoice is readInTEdit then
try
tell application "TextEdit"
open file targetFile
end tell
end try
else if myChoice is readInWorksheet then
try
tell application myWorksheet
open file targetFile
end tell
end try
else if myChoice is in {resetBtn, appendBtn} then
if myChoice is in resetBtn then
my writeTo(targetFile, "", «class utf8», false) --
end if
if forTests then
-- build fake datas
repeat 10 times
set deb to some text item of "0123456789"
set deb to deb & some text item of "0123456789"
set deb to deb & ":"
set deb to deb & some text item of "0123456789"
set deb to deb & some text item of "0123456789"
set deb to deb & ":"
set deb to deb & some text item of "0123456789"
set deb to deb & some text item of "0123456789"
set deb to deb & ":"
set deb to deb & some text item of "0123456789"
set deb to deb & some text item of "0123456789"
my writeTo(targetFile, (deb as text) & linefeed, «class utf8», true)
end repeat
else
-- build real datas
activate application "Pro Tools"
tell application "System Events"
tell process "Pro Tools"
tell (1st window whose title contains "Edit: ")
delay 0.1
--count the number of selected track
set trck to (count of static text of UI element 2 of (every row of table 3 whose selected is true))
--repeat with count
repeat with a from 1 to trck
--value of tc in
set deb to get value of text field 1 of group 4
--select next cue in pro tools
key code 48 using control down
--log deb
-- append sequentially the value deb in a text file.
my writeTo(targetFile, (deb as text) & linefeed, «class utf8», true)
end repeat
end tell -- tell (1st window
end tell -- tell process "Pro Tools"
end tell -- application "System Events"
end if
end if
#=====
(*
Handler borrowed to Regulus6633 - http://macscripter.net/viewtopic.php?id=36861
*)
on writeTo(targetFile, theData, dataType, apendData)
-- targetFile is the path to the file you want to write
-- theData is the data you want in the file.
-- dataType is the data type of theData and it can be text, list, record etc.
-- apendData is true to append theData to the end of the current contents of the file or false to overwrite it
try
set targetFile to targetFile as «class furl»
set openFile to open for access targetFile with write permission
if not apendData then set eof openFile to 0
write theData to openFile starting at eof as dataType
close access openFile
return true
on error
try
close access file targetFile
end try
return false
end try
end writeTo
#=====
Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) lundi 13 janvier 2020 07:22:26