From 3a4b127be90c218b25ed254dd3f082bff6d99c37 Mon Sep 17 00:00:00 2001 From: Rob van Son Date: Fri, 10 Aug 2012 17:07:39 +0200 Subject: [PATCH] Check before loading table --- Config.praat | 23 +++++++++++++++-------- sgc2.praat | 40 +++++++++++++++++++++++++++++++++++----- 2 files changed, 50 insertions(+), 13 deletions(-) diff --git a/Config.praat b/Config.praat index a71d605..adbca48 100644 --- a/Config.praat +++ b/Config.praat @@ -98,6 +98,10 @@ endproc # Set the correct button states after redrawing the window procedure setConfigMainPage + call testLoadTable SummaryToneEvaluation + if testLoadTable.table <= 0 + call Draw_button 'config$' PerfSummary 1 + endif # Handle logging buttons with forced button draw if fileReadable("'preferencesLogDir$'/logPerformance.txt") call Draw_button 'config$' +!Logging 'config.logPerformance' @@ -323,16 +327,19 @@ endproc procedure processConfigPerfSummary .clickX .clickY .pressed$ .table$ = "Config" .label$ = "PerfSummary" - call Draw_button '.table$' '.label$' 1 - call loadTable SummaryToneEvaluation - call write_tabbed_table SummaryToneEvaluation Evaluation_'config.language$' - demoWaitForInput() - select Table SummaryToneEvaluation - Remove + call testLoadTable SummaryToneEvaluation + if testLoadTable.table > 0 + call Draw_button '.table$' '.label$' 1 + call loadTable SummaryToneEvaluation + call write_tabbed_table SummaryToneEvaluation Evaluation_'config.language$' + demoWaitForInput() + select Table SummaryToneEvaluation + Remove - call Draw_button '.table$' '.label$' 0 - call Draw_config_page + call Draw_button '.table$' '.label$' 0 + call Draw_config_page + endif endproc procedure processConfigListPerf .clickX .clickY .pressed$ diff --git a/sgc2.praat b/sgc2.praat index 57e3e59..c3f0649 100644 --- a/sgc2.praat +++ b/sgc2.praat @@ -1233,10 +1233,30 @@ procedure loadTable .tableName$ elsif variableExists("procCreate'.tableVariableName$'$") call Create'.tableVariableName$' else + call write_text_popup Helvetica 14 '.tableName$' cannot be found + demoWaitForInput() exit '.tableName$' cannot be found endif endproc +procedure testLoadTable .tableName$ + .table = 0 + .tableVariableName$ = replace_regex$(.tableName$, "[^\w]", "_", 0); + # Search for the table in local, preference, and global directories + if fileReadable("'localTableDir$'/'.tableName$'.Table") + .table = 1 + elsif fileReadable("'preferencesTableDir$'/'.tableName$'.Table") + .table = 2 + elsif fileReadable("'globaltablelists$'/'.tableName$'.Table") + .table = 3 + # Load them from script + elsif variableExists("procCreate'.tableVariableName$'$") + .table = 4 + else + .table = 0 + endif +endproc + procedure checkTable .tableName$ .available = 0 if fileReadable("'localTableDir$'/'.tableName$'.Table") @@ -1262,9 +1282,13 @@ procedure write_text_table .table$ .lineHeight = 2.5 # Get table with text and longest line - call loadTable '.table$' - .instructionText = selected() - .numLines = Get number of rows + .numLines = 0 + call testLoadTable '.table$' + if testLoadTable.table <= 0 + call loadTable '.table$' + .instructionText = selected() + .numLines = Get number of rows + endif .instructionFontSize = 14 .referenceText$ = "" .maxlenght = 0 @@ -1349,6 +1373,8 @@ procedure write_text_table .table$ select '.instructionText' Remove + + label ESCAPEwrite_text_table endproc @@ -1361,8 +1387,11 @@ procedure write_tabbed_table .table$ .labelTextTable$ .lineHeight = 2.5 # Get table with text and longest line - call loadTable '.labelTextTable$' - .labelText$ = selected$("Table") + call testLoadTable '.table$' + if testLoadTable.table <= 0 + call loadTable '.labelTextTable$' + .labelText$ = selected$("Table") + endif select Table '.table$' .tabbedText = selected() @@ -1456,6 +1485,7 @@ procedure write_tabbed_table .table$ .labelTextTable$ select Table '.labelText$' Remove + label ESCAPEwrite_tabbed_table endproc # Create a pop-up window with a given text -- 2.11.4.GIT