Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid use of select all Remove #82

Open
tsostarics opened this issue Jun 25, 2024 · 0 comments
Open

Avoid use of select all Remove #82

tsostarics opened this issue Jun 25, 2024 · 0 comments
Labels
good first issue Good for newcomers Local App For issues specifically with the local version Praat Related to praat integration with the app

Comments

@tsostarics
Copy link
Owner

Currently the Close Praat Objects button just uses a temporary script to execute select all then Remove, but this will cause people to lose any new objects that they may have created while inspecting files.

A safer approach would be to set up a Table object whenever a script is first run from PitchMendR, then append indices for each file that's loaded during the session. The close objects button would then look up the indices in the Table object and remove the files one by one.

So something like

Setup (add to temp_praat_script_utils.R):

# If no table object exists already, create one
tableObj = undefined
nocheck selectObject = "Table objsFromPitchMendR"
tableObj = nocheck selected()
if tableObj = undefined
  tableObj = Create Table with column names: "objsFromPitchMendR", 1, { "objIndex" }
endif
selectObject: tableObj
nrows = Get number of Rows

Appending (add to sendToPraat reactive in module_praat.R):

# ...file was loaded...
soundObj = selected("Sound")
textgridObj = selected("TextGrid")

selectObject: "Table objsFromPitchMendR"
Append row
nrows = Get number of Rows
Set numeric value: nrows, "objIndex", soundObj

Append row
nrows = nrows+1
Set numeric value: nrows, "objIndex", textgridObj

Removing (add to closePraatFiles reactive in module_praat.R)

selectObject = "Table objsFromPitchMendR"

nRows = Get number of rows

for i from 1 to nRows
  objNumber = Get value: 1, "objIndex"
  nocheck removeObject: objNumber
  nocheck Remove row: 1
endfor

@tsostarics tsostarics added good first issue Good for newcomers Praat Related to praat integration with the app Local App For issues specifically with the local version labels Jun 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers Local App For issues specifically with the local version Praat Related to praat integration with the app
Projects
None yet
Development

No branches or pull requests

1 participant