From 8ee26f7a6d4b4ceadad57c5043dad3a8a1502b28 Mon Sep 17 00:00:00 2001 From: Rob van Son Date: Tue, 16 Nov 2010 10:20:21 +0100 Subject: [PATCH] Normalizing application name use --- Config.praat | 18 +++++++++--------- InitialiseSGC2.praat | 23 ++++++++++++----------- sgc2.praat | 2 ++ 3 files changed, 23 insertions(+), 20 deletions(-) diff --git a/Config.praat b/Config.praat index df9e23f..026b636 100644 --- a/Config.praat +++ b/Config.praat @@ -231,7 +231,7 @@ procedure processConfigDeleteWordlist .clickX .clickY .pressed$ # Do not process undeletable word lists, only those stored in the # preferencesDirectory$ can be deleted - if fileReadable("'preferencesDirectory$'/../.speakgoodchinese2/wordlists/'wordlistName$'") + if fileReadable("'sgc2wordlists$'/'wordlistName$'") call findLabel '.table$' !'.label$' if findLabel.row > 0 select Table '.table$' @@ -290,7 +290,7 @@ procedure processConfigInstallWordlist .clickX .clickY .pressed$ call sgc2wordlist 'homeDirectory$'/My Documents call sgc2wordlist 'homeDirectory$'/My Documents/Downloads call sgc2wordlist 'homeDirectory$'/Desktop - call sgc2wordlist 'preferencesDirectory$'/../.speakgoodchinese2 + call sgc2wordlist 'preferencesMainDir$' endif call load_word_list "'localWordlistDir$'" 0 call Draw_button '.table$' '.label$' 0 @@ -393,7 +393,7 @@ printline '.wordlist_Name$' call readWordlist "'homeDirectory$'/My Documents/Downloads" '.wordlist_Name$''.currentExtension$' call readWordlist "'homeDirectory$'/My Documents" '.wordlist_Name$''.currentExtension$' call readWordlist "'homeDirectory$'/Desktop" '.wordlist_Name$''.currentExtension$' - call readWordlist "'preferencesDirectory$'/../.speakgoodchinese2" '.wordlist_Name$''.currentExtension$' + call readWordlist "'preferencesMainDir$'" '.wordlist_Name$''.currentExtension$' endfor endif endif @@ -576,7 +576,7 @@ procedure load_word_list .localdir$ .relnumber endif # Can this wordlist be deleted? - if fileReadable("'preferencesDirectory$'/../.speakgoodchinese2/wordlists/'wordlistName$'") + if fileReadable("'sgc2wordlists$'/'wordlistName$'") config.deleteWordlist = 0 else config.deleteWordlist = -1 @@ -684,7 +684,7 @@ procedure start_logging .logDirectory$ < 'preferencesLogDir$'/logPerformance.txt .logDirectory$ = extractWord$(.logDirectory$, "") if .logDirectory$ = "" or not fileReadable(.logDirectory$) - .logDirectory$ = "'preferencesDirectory$'/../.speakgoodchinese2/log" + .logDirectory$ = "'preferencesLogDir$'" endif createDirectory("'.logDirectory$'/sgc2log") currentLogDirectory$ = "'.logDirectory$'/sgc2log/log'logtimeStamp$'" @@ -746,8 +746,8 @@ endproc # Uninstall word lists procedure removeWordlist .deletedWordlistName$ .targetDir$ = "" - if fileReadable("'preferencesDirectory$'/../.speakgoodchinese2/wordlists/'.deletedWordlistName$'") - .targetDir$ = "'preferencesDirectory$'/../.speakgoodchinese2/wordlists/'.deletedWordlistName$'" + if fileReadable("'sgc2wordlists$'/'.deletedWordlistName$'") + .targetDir$ = "'sgc2wordlists$'/'.deletedWordlistName$'" endif Create Strings as file list... DeleteList '.targetDir$'/* .numdeleteFiles = Get number of strings @@ -766,7 +766,7 @@ procedure sgc2wordlist .sourceDir$ .sourceDir$ = replace$(.sourceDir$, "preferencesDirectory$", preferencesDirectory$) endif - .targetDirectory$ = "'preferencesDirectory$'/../.speakgoodchinese2/wordlists" + .targetDirectory$ = "'sgc2wordlists$'" if fileReadable(.sourceDir$) Create Strings as file list... PackageList '.sourceDir$'/*.sgc .numFiles = Get number of strings @@ -790,7 +790,7 @@ procedure readWordlist .sourceDir$ .file$ # No use doing anything if the source does not exist if fileReadable("'.sourceDir$'/'.file$'") # What will be the target wordlist directory? - .targetDirectory$ = "'preferencesDirectory$'/../.speakgoodchinese2/wordlists" + .targetDirectory$ = "'sgc2wordlists$'" .dirname$ = left$(.file$, rindex(.file$, ".")-1) if .dirname$ = "" .dirname$ = .file$ diff --git a/InitialiseSGC2.praat b/InitialiseSGC2.praat index 0d461ca..ece359c 100644 --- a/InitialiseSGC2.praat +++ b/InitialiseSGC2.praat @@ -77,9 +77,10 @@ recordingTime = 2 config.language$ = "EN" config.register = 249 config.logPerformance = 0 -preferencesLogDir$ = "'preferencesDirectory$'/../.speakgoodchinese2/log" -preferencesTableDir$ = "'preferencesDirectory$'/../.speakgoodchinese2/Data" -sgc2wordlists$ = "'preferencesDirectory$'/../.speakgoodchinese2/wordlists" +preferencesMainDir$ = "'preferencesDirectory$'/../.'sgc2.demoappname$'" +preferencesLogDir$ = "'preferencesMainDir$'/log" +preferencesTableDir$ = "'preferencesMainDir$'/Data" +sgc2wordlists$ = "'preferencesMainDir$'/wordlists" # Global word lists must be installed BY THE ADMINISTRATOR # This means, create the directory 'globalwordlists$' and # fill it with wordlist directories containing wordlist.Table @@ -115,7 +116,7 @@ call set_up_directories call read_preferences "" # Set up TTS system -speakCommandDir$ = "'preferencesDirectory$'/../.speakgoodchinese2/TTS" +speakCommandDir$ = "'preferencesMainDir$'/TTS" speakCommandFile$ = "" call set_up_TTS @@ -161,7 +162,7 @@ endproc # Make sure all Preferences directories are available procedure set_up_directories - .dirPath$ = "'preferencesDirectory$'/../.speakgoodchinese2" + .dirPath$ = "'preferencesMainDir$'" createDirectory(.dirPath$) createDirectory("'.dirPath$'/wordlists") createDirectory("'.dirPath$'/log") @@ -173,10 +174,10 @@ endproc # procedure read_preferences .preferencesFile$ if not fileReadable(.preferencesFile$) - .preferencesFile$ = preferencesDirectory$+"/../.speakgoodchinese2/sgc2rc.txt" + .preferencesFile$ = preferencesDirectory$+"/../.'sgc2.demoappname$'/sgc2rc.txt" endif if fileReadable(.preferencesFile$) - Read from file... 'preferencesDirectory$'/../.speakgoodchinese2/sgc2rc.txt + Read from file... 'preferencesMainDir$'/sgc2rc.txt .preferenceTable$ = selected$("Table") .numPrefKeys = Get number of rows for .row to .numPrefKeys @@ -201,7 +202,7 @@ endproc procedure write_preferences .preferencesFile$ Create Table with column names... Preferences 0 Key Value if index_regex(.preferencesFile$, "[a-zA-Z0-9]") <= 0 - .preferencesFile$ = preferencesDirectory$ + "/../.speakgoodchinese2/sgc2rc.txt" + .preferencesFile$ = preferencesDirectory$ + "/../.'sgc2.demoappname$'/sgc2rc.txt" endif .row = 0 @@ -277,7 +278,7 @@ endproc # TTS (speech synthesis). Place commands in user info # # Prerequisites -# speakCommandDir$ = "'preferencesDirectory$'/../.speakgoodchinese2/TTS" +# speakCommandDir$ = "'preferencesMainDir$'/TTS" # speakCommandFile$ = "" procedure set_up_TTS if macintosh @@ -526,14 +527,14 @@ endproc # ############################################################### # -# Create a file 'preferencesDirectory$'/../.speakgoodchinese2/log/logPerformance +# Create a file 'preferencesMainDir$'/log/logPerformance # This file contains the path to the target directory where logging # is to be stored. # Note that this procedure is nowhere used in SGC2. It has to # be explicitely called in a separate script. # procedure activate_sgc2_logging .targetDirectory$ - createDirectory("'preferencesDirectory$'/../.speakgoodchinese2") + createDirectory("'preferencesMainDir$'") createDirectory("'preferencesLogDir$'") if startsWith(.targetDirectory$, "~") diff --git a/sgc2.praat b/sgc2.praat index 29ff8be..6366aa9 100644 --- a/sgc2.praat +++ b/sgc2.praat @@ -25,6 +25,8 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA # +# The real application name +sgc2.demoappname$ = "speakgoodchinese2" # Define variable that will be reset in Initialise*.praat # These are simply "useful" defaults -- 2.11.4.GIT