From 5e87a945f6d36091f53ed6123c7892a55a4a9351 Mon Sep 17 00:00:00 2001 From: Rob van Son Date: Tue, 4 Aug 2015 17:25:44 +0200 Subject: [PATCH] Some sanity checks on tables and better error messages --- sgc2.praat | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/sgc2.praat b/sgc2.praat index d8c8de3..fee9287 100644 --- a/sgc2.praat +++ b/sgc2.praat @@ -1350,18 +1350,31 @@ procedure loadTable .tableName$ .tableVariableName$ = replace_regex$(.tableName$, "[^\w]", "_", 0); # Search for the table in local, preference, and global directories if localTableDir$ <> "" and fileReadable("'localTableDir$'/'.tableName$'.Table") - Read from file... 'localTableDir$'/'.tableName$'.Table + .table = Read from file... 'localTableDir$'/'.tableName$'.Table elsif fileReadable("'preferencesTableDir$'/'.tableName$'.Table") - Read from file... 'preferencesTableDir$'/'.tableName$'.Table + .table = Read from file... 'preferencesTableDir$'/'.tableName$'.Table elsif fileReadable("'globaltablelists$'/'.tableName$'.Table") - Read from file... 'globaltablelists$'/'.tableName$'.Table + .table = Read from file... 'globaltablelists$'/'.tableName$'.Table # Load them from script elsif variableExists("procCreate'.tableVariableName$'$") call Create'.tableVariableName$' + Rename: .tableName$ + .table = selected("Table") else - call write_text_popup 'defaultFont$' 14 '.tableName$' cannot be found - demoWaitForInput() - exit '.tableName$' cannot be found + call emergency_table_exit '.tableFileName$' cannot be found + endif + + # Check whether this is a real table + selectObject: .table + .fullName$ = selected$ () + .type$ = extractWord$(.fullName$, "") + if .type$ <> "Table" + Remove + .table = -1 + endif + + if .table <= 0 + call emergency_table_exit '.tableFileName$' corrupted or cannot be found endif endproc -- 2.11.4.GIT