4 # Praat script handling configuration page
6 # SpeakGoodChinese: Config.praat loads the code needed for the
7 # settings and the Settings page of SpeakGoodChinese.
9 # Copyright (C) 2007-2010 R.J.J.H. van Son and 2010 the Netherlands Cancer Institute
10 # The SpeakGoodChinese team are:
11 # Guangqin Chen, Zhonyan Chen, Stefan de Koning, Eveline van Hagen,
12 # Rob van Son, Dennis Vierkant, David Weenink
14 # This program is free software; you can redistribute it and/or modify
15 # it under the terms of the GNU General Public License as published by
16 # the Free Software Foundation; either version 2 of the License, or
17 # (at your option) any later version.
19 # This program is distributed in the hope that it will be useful,
20 # but WITHOUT ANY WARRANTY; without even the implied warranty of
21 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 # GNU General Public License for more details.
24 # You should have received a copy of the GNU General Public License
25 # along with this program; if not, write to the Free Software
26 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
29 ###############################################################
31 # Button Drawing Routines
33 ###############################################################
35 procedure DrawCredits .color$ .x .y .size
38 call adjustFontSizeOnHeight 'defaultFont$' 24 '.lineheight'
39 .currentFontSize = adjustFontSizeOnHeight.newFontSize
40 demo Paint circle... {0.2,0.2,0.8} '.x' '.y' '.size'
42 demo Text special... '.x' centre '.y' half Times '.currentFontSize' 0 i
45 call set_font_size 'defaultFontSize'
48 procedure DrawDeleteList .color$ .x .y .size
56 .displayWordList$ = replace_regex$(wordlistName$, "[_]", " ", 0)
59 .maxWidth = (.rightX - .leftX)
60 .currentFontSize = defaultFontSize
61 call adjustFontSizeOnWidth 'defaultFont$' '.currentFontSize' '.maxWidth' '.displayWordList$'
62 .currentFontSize = adjustFontSizeOnWidth.newFontSize
63 if adjustFontSizeOnWidth.diff > 0
64 .rightX += adjustFontSizeOnWidth.diff/2
65 .leftX -= adjustFontSizeOnWidth.diff/2
67 call set_font_size '.currentFontSize'
68 demo Paint rectangle... White '.leftX' '.rightX' '.botY' '.topY'
70 demo Text... '.x' Centre '.botY' Bottom '.displayWordList$'
73 call set_font_size 'defaultFontSize'
76 procedure DrawManual .color$ .x .y .size
79 call adjustFontSizeOnHeight 'defaultFont$' 24 '.lineheight'
80 .currentFontSize = adjustFontSizeOnHeight.newFontSize
81 demo Paint circle... {0.2,0.2,0.8} '.x' '.y' '.size'
83 demo Text special... '.x' centre '.y' half Times '.currentFontSize' 0 M
86 call set_font_size 'defaultFontSize'
89 procedure DrawLogging .color$ .x .y .size
93 .color$ = "{0.5,0.5,1}"
97 demo Paint circle... '.color$' '.x' '.y' '.size'
100 ###############################################################
102 # Obligatory button Drawing Routines
104 # These MUST be defined
106 ###############################################################
108 procedure DrawReturn .color$ .x .y .size
109 call DrawConfig '.color$' '.x' '.y' '.size'
112 # Set the correct button states after redrawing the window
113 procedure setConfigMainPage
114 # Handle logging buttons with forced button draw
115 if fileReadable("'preferencesLogDir$'/logPerformance.txt")
116 call Draw_button 'config$' +!Logging 'config.logPerformance'
120 ###############################################################
122 # Button Processing Routines
124 ###############################################################
126 procedure processConfigShuffleLists .clickX .clickY .pressed$
128 .label$ = "ShuffleLists"
129 config.shuffleLists = not config.shuffleLists
130 .displayButton = 2*config.shuffleLists
131 call Draw_button '.table$' '.label$' '.displayButton'
134 procedure processConfigUseSoundExample .clickX .clickY .pressed$
136 .label$ = "UseSoundExample"
137 config.useSoundExample = not config.useSoundExample
138 .displayButton = 2*config.useSoundExample
139 call Draw_button '.table$' '.label$' '.displayButton'
142 procedure processConfigSynthesis .tts$ .clickX .clickY .pressed$
144 .label$ = "Synthesis_'.tts$'"
145 if sgc2.synthesizer > 0 or (speakCommandFile$ <> "" and fileReadable(speakCommandFile$))
146 if config.synthesis$ = ""
147 config.synthesis$ = .tts$
150 config.synthesis$ = ""
154 config.synthesis$ = "_DISABLED_"
157 call Draw_button '.table$' '.label$' '.displayButton'
160 procedure processConfigStrict .clickX .clickY .pressed$
163 config.strict = not config.strict
169 # Change TTS for Strict!
171 call Draw_button '.table$' '.label$' '.displayButton'
174 procedure processConfigDisplayPinyin .clickX .clickY .pressed$
176 .label$ = "DisplayPinyin"
177 config.displayPinyin = not config.displayPinyin
178 .displayButton = 2*config.displayPinyin
179 call Draw_button '.table$' '.label$' '.displayButton'
182 procedure processConfigDisplayChar .clickX .clickY .pressed$
184 .label$ = "DisplayChar"
185 config.displayChar = not config.displayChar
186 .displayButton = 2*config.displayChar
187 call Draw_button 'table$' '.label$' '.displayButton'
190 procedure processConfigDisplayTrans .clickX .clickY .pressed$
192 .label$ = "DisplayTrans"
193 config.displayTrans = not config.displayTrans
194 .displayButton = 2*config.displayTrans
195 call Draw_button 'table$' '.label$' '.displayButton'
198 procedure processConfigDisplayNumbers .clickX .clickY .pressed$
200 .label$ = "DisplayNumbers"
201 config.displayNumbers = not config.displayNumbers
202 .displayButton = 2*config.displayNumbers
203 call Draw_button 'table$' '.label$' '.displayButton'
206 procedure processConfigLanguage .language$ .clickX .clickY .pressed$
208 .label$ = "Language_'.language$'"
209 call processLanguageCodes '.table$' '.label$'
212 procedure processConfigShowBackground .clickX .clickY .pressed$
214 .label$ = "ShowBackground"
215 config.showBackground = not config.showBackground
216 .displayButton = 2*config.showBackground
217 call Draw_button 'table$' '.label$' '.displayButton'
220 procedure processConfigInput .input$ .clickX .clickY .pressed$
222 .label$ = "Input_'.input$'"
223 call Draw_button '.table$' Input_'config.input$' 0
224 config.input$ = .input$
225 call Draw_button '.table$' Input_'config.input$' 2
228 procedure processConfigRegister .register .clickX .clickY .pressed$
230 .label$ = "Register_'.register'"
231 call setRegisterFromLabel '.table$' '.label$'
234 procedure setRegisterFromLabel .table$ .label$
235 call Draw_button '.table$' Register_'config.register' 0
236 call Draw_button '.table$' '.label$' 2
237 # Someone might have to use more than 3 chars for the config.register code
238 .numChars = length(.label$) - length("Register_")
239 .registerText$ = right$(.label$, .numChars)
240 config.register = '.registerText$'
243 procedure processConfigDeleteWordlist .clickX .clickY .pressed$
245 .label$ = "DeleteWordlist"
247 # Do not process undeletable word lists, only those stored in the
248 # preferencesDirectory$ can be deleted
249 if fileReadable("'sgc2wordlists$'/'wordlistName$'") or fileReadable("'sgc2wordlists$'/'wordlistName$'/wordlist.txt") or fileReadable("'sgc2wordlists$'/'wordlistName$'/wordlist.Table")
250 call findLabel '.table$' !'.label$'
252 select Table '.table$'
253 .alertText$ = Get value... 'findLabel.row' Text
254 .confirmKey$ = Get value... 'findLabel.row' Key
255 .popupText$ = Get value... 'findLabel.row' Helptext
257 exit Cannot find delete directive: '.table$' !'.label$'
259 call write_text_popup 'defaultFont$' 14 '.popupText$'
260 call Draw_button '.table$' '.label$' 2
261 alertText$ = .alertText$
262 call Draw_button '.table$' '.label$' 3
265 # Wait for confirmation
267 if demoInput(.confirmKey$)
268 .deleteWordListDir$ = wordlistName$
269 call load_word_list "'localWordlistDir$'" 1
270 call removeWordlist '.deleteWordListDir$'
271 call load_word_list "'localWordlistDir$'" 0
273 call Draw_button '.table$' '.label$' 0
274 call Draw_config_page
278 wordlistTag$ = "Wordlist name"
279 procedure processConfigInstallWordlist .clickX .clickY .pressed$
281 .label$ = "InstallWordlist"
282 call Draw_button '.table$' '.label$' 1
284 # Do not use the automatic sgc list option, ask for a wordlist NAME
286 call findLabel '.table$' '.label$'
288 select Table '.table$'
289 .openDialogue$ = Get value... '.row' Helptext
290 call convert_praat_to_latin1 '.openDialogue$'
291 .openDialogue$ = convert_praat_to_latin1.text$
292 .wordlistButton$ = replace$(wordlistTag$, " ", "_", 0)
293 .wordlistButton$ = replace_regex$(.wordlistButton$, "^.", "\l&", 0)
294 beginPause(.openDialogue$)
295 sentence (wordlistTag$, "")
296 clicked = endPause ("Cancel", "Open", 2, 1)
299 .wordlist_Name$ = '.wordlistButton$'$
301 call install_wordlists_by_name '.wordlist_Name$'
303 call sgc2wordlist 'homeDirectory$'
304 call sgc2wordlist 'homeDirectory$'/Downloads
305 call sgc2wordlist 'homeDirectory$'/Documents
306 call sgc2wordlist 'homeDirectory$'/My Documents
307 call sgc2wordlist 'homeDirectory$'/My Documents/Downloads
308 call sgc2wordlist 'homeDirectory$'/Desktop
309 call sgc2wordlist 'preferencesAppDir$'
311 call load_word_list "'localWordlistDir$'" 0
312 call Draw_button '.table$' '.label$' 0
313 call Draw_config_page
316 procedure processConfigOpenWordlist .clickX .clickY .pressed$
318 .label$ = "OpenWordlist"
319 call Draw_button '.table$' '.label$' 1
322 call findLabel '.table$' '.label$'
324 select Table '.table$'
325 .openDialogue$ = Get value... '.row' Helptext
326 call convert_praat_to_latin1 '.openDialogue$'
327 .openDialogue$ = convert_praat_to_latin1.text$
329 .wordlist_Name$ = chooseReadFile$ (.openDialogue$)
330 call install_wordlists_by_name '.wordlist_Name$'
331 call load_word_list "'localWordlistDir$'" 0
332 call Draw_button '.table$' '.label$' 0
333 call Draw_config_page
336 # Select the words to practise. This is quite a complex piece of code
337 procedure processConfigSelectWords .clickX .clickY .pressed$
339 .label$ = "SelectWords"
340 call Draw_button '.table$' '.label$' 1
343 call findLabel '.table$' '.label$'
345 select Table '.table$'
346 .helpText$ = Get value... '.row' Helptext
347 call convert_praat_to_latin1 '.helpText$'
348 .helpText$ = convert_praat_to_latin1.text$
351 select Table 'wordlist$'
352 .tmpOriginalWordlist = Copy: "Original_'wordlist$'"
356 select Table 'wordlist$'
357 te.numberOfWords = Get number of rows
358 .currentWord = te.currentWord
359 if .currentWord <= 0 or .currentWord > te.numberOfWords or config.shuffleLists
364 call get_feedback_text 'config.language$' Part
365 call convert_praat_to_latin1 'get_feedback_text.text$'
366 .partText$ = convert_praat_to_latin1.text$
367 call get_feedback_text 'config.language$' Tones
368 call convert_praat_to_latin1 'get_feedback_text.text$'
369 .toneText$ = convert_praat_to_latin1.text$
370 call get_feedback_text 'config.language$' Cancel
371 call convert_praat_to_latin1 'get_feedback_text.text$'
372 .cancelText$ = convert_praat_to_latin1.text$
373 call get_feedback_text 'config.language$' Clear
374 call convert_praat_to_latin1 'get_feedback_text.text$'
375 .clearText$ = convert_praat_to_latin1.text$
376 call get_feedback_text 'config.language$' All
377 call convert_praat_to_latin1 'get_feedback_text.text$'
378 .allText$ = convert_praat_to_latin1.text$
379 call get_feedback_text 'config.language$' Previous
380 call convert_praat_to_latin1 'get_feedback_text.text$'
381 .prevWord$ = convert_praat_to_latin1.text$
382 call get_feedback_text 'config.language$' Next
383 call convert_praat_to_latin1 'get_feedback_text.text$'
384 .nextWord$ = convert_praat_to_latin1.text$
385 call get_feedback_text 'config.language$' Continue
386 call convert_praat_to_latin1 'get_feedback_text.text$'
387 .continueText$ = convert_praat_to_latin1.text$
388 call get_feedback_text 'config.language$' Show
389 call convert_praat_to_latin1 'get_feedback_text.text$'
390 .showText$ = convert_praat_to_latin1.text$
392 .pinyinText$ = "Pinyin"
393 .characterText$ = "Character"
396 select Table 'wordlist$'
397 .lessonCol = Get column index: "Lesson"
400 # All shown keeps track whether all words are shown
401 # If so, selecting a lesson is preceded by a Clear All
403 # Sort words for consistent selection interface
404 if config.shuffleLists
405 # Allow subdivision in lessons
407 Sort rows... Lesson Pinyin
413 for .i to te.numberOfWords
414 .currentLesson$ = Get value: .i, "Lesson"
415 if .currentLesson$ <> "" and .currentLesson$ <> "-" and index_regex(.lessonList$, "\t'.currentLesson$'\t") <= 0
416 .lessonList$ = .lessonList$ + .currentLesson$ + tab$
418 .lessonName$['.numLessons'] = .currentLesson$
420 .shown$ = Get value: .i, "Show"
428 .numWordsPerScreen = 15
429 while clicked <> 6 and clicked <> 1
434 select Table 'wordlist$'
435 .lessonCol = Get column index: "Lesson"
436 # Sort words for consistent selection interface
437 if config.shuffleLists
438 # Allow subdivision in lessons
440 Sort rows... Lesson Pinyin
445 .max = .numWordsPerScreen - 1
446 if .currentWord + .max > te.numberOfWords
447 .max = te.numberOfWords - .currentWord
449 for .i from 0 to .numWordsPerScreen - 1
451 .pinyin$[.i] = Get value: .currentWord+.i, "Pinyin"
452 .character$[.i] = Get value: .currentWord+.i, "Character"
455 .lessonNum$[.i] = Get value: .currentWord+.i, "Lesson"
456 .lessonNum$[.i] = " : " + .lessonNum$[.i]
458 .showText$[.i] = .pinyin$['.i']
459 if .character$['.i'] <> "-"
460 .showText$[.i] = .pinyin$['.i']+" ("+.character$['.i']+.lessonNum$['.i']+")"
461 elsif .lessonNum$['.i'] <> ""
462 .showText$[.i] = .pinyin$['.i']+" ( -"+.lessonNum$['.i']+")"
464 .showValueText$[.i] = Get value: .currentWord+.i, "Show"
465 if .showValueText$[.i] = "-"
470 .showVariable$[.i] = replace_regex$(.pinyin$[.i], ".+", "\l&", 0)
471 .showVariable$[.i] = replace_regex$(.showVariable$[.i], " ", "_", 0)
472 .tmp$ = .showVariable$['.i']
473 '.tmp$' = .showValue[.i]
480 # The user text input window (beginPause .... endPause)
481 beginPause(.helpText$)
482 boolean (.showText$[0], .showValue[0])
483 boolean (.showText$[1], .showValue[1])
484 boolean (.showText$[2], .showValue[2])
485 boolean (.showText$[3], .showValue[3])
486 boolean (.showText$[4], .showValue[4])
487 boolean (.showText$[5], .showValue[5])
488 boolean (.showText$[6], .showValue[6])
489 boolean (.showText$[7], .showValue[7])
490 boolean (.showText$[8], .showValue[8])
491 boolean (.showText$[9], .showValue[9])
492 boolean (.showText$[10], .showValue[10])
493 boolean (.showText$[11], .showValue[11])
494 boolean (.showText$[12], .showValue[12])
495 boolean (.showText$[13], .showValue[13])
496 boolean (.showText$[14], .showValue[14])
498 optionMenu: .partText$, 1
501 for .j to .numLessons
502 option: .lessonName$['.j']
505 optionMenu: .toneText$, 1
512 clicked = endPause ("'.cancelText$'", "'.clearText$'", "'.allText$'", "'.prevWord$'", "'.nextWord$'", "'.continueText$'", 6, 1)
515 for .i to te.numberOfWords
516 Set string value: .i, "Show", "-"
520 for .i to te.numberOfWords
521 Set string value: .i, "Show", "+"
525 # Get selected Part BEFORE we do anything else
527 .tmp$ = replace_regex$(.partText$, "^(.)", "\l\1", 0)
528 .lessonSelected = '.tmp$' - 1
530 if .lessonSelected > 0
533 select Table 'wordlist$'
534 for .i to te.numberOfWords
535 # Keep track of whether all are shown
536 .shown$ = Get value: .i, "Show"
541 for .i to te.numberOfWords
543 .currentLesson$ = Get value: .i, "Lesson"
544 if .currentLesson$ = .lessonName$['.lessonSelected']
545 Set string value: .i, "Show", "+"
547 Set string value: .i, "Show", "-"
550 for .i to te.numberOfWords
551 # Keep track of whether all are shown
552 .shown$ = Get value: .i, "Show"
553 if .firstShown <=0 and .shown$ <> "-"
558 for .i from 0 to .max
559 .tmp$ = .showVariable$['.i']
560 .showValue['.i'] = '.tmp$'
561 .showWord$['.i'] = "-"
562 if .showValue['.i'] <> 0
563 .showWord$['.i'] = "+"
565 Set string value: .currentWord+.i, "Show", .showWord$['.i']
568 .tmp$ = replace_regex$(.toneText$, "^(.)", "\l\1", 0)
569 .toneSelected = '.tmp$' - 2
570 if .toneSelected >= 0
571 select Table 'wordlist$'
572 for .i to te.numberOfWords
573 .currentPinyin$ = Get value: .i, "Pinyin"
574 .tmp$ = Get value: .i, "Show"
575 if .tmp$ <> "-" and index(.currentPinyin$, "'.toneSelected'") > 0
576 Set string value: .i, "Show", "+"
578 Set string value: .i, "Show", "-"
586 .currentWord = (.firstShown div .numWordsPerScreen) * .numWordsPerScreen + 1
587 elsif .toneSelected < 0
588 .currentWord -= .numWordsPerScreen
591 .currentWord = (te.numberOfWords div .numWordsPerScreen) * .numWordsPerScreen + 1
595 .currentWord = (.firstShown div .numWordsPerScreen) * .numWordsPerScreen + 1
596 elsif .toneSelected < 0
597 .currentWord += .numWordsPerScreen
599 if .currentWord > te.numberOfWords
604 # Reset and go to the first selected word (can shuffle list)
613 select Table 'wordlist$'
615 select .tmpOriginalWordlist
618 select .tmpOriginalWordlist
620 call Draw_button '.table$' '.label$' 0
623 procedure processConfigPerfSummary .clickX .clickY .pressed$
625 .label$ = "PerfSummary"
627 call testLoadTable SummaryToneEvaluation
628 if testLoadTable.table > 0
629 call Draw_button '.table$' '.label$' 1
630 call loadTable SummaryToneEvaluation
631 call write_tabbed_table SummaryToneEvaluation Evaluation_'config.language$'
633 select Table SummaryToneEvaluation
636 call Draw_button '.table$' '.label$' 0
637 call Draw_config_page
641 # Wipe current performance table and initialize a new one
642 procedure processConfigClearSummary .clickX .clickY .pressed$
644 .label$ = "ClearSummary"
646 call Draw_button '.table$' '.label$' 1
648 select Table '.table$'
649 call findLabel '.table$' !'.label$'
651 .alertText$ = Get value... 'findLabel.row' Text
652 .confirmKey$ = Get value... 'findLabel.row' Key
653 .popupText$ = Get value... 'findLabel.row' Helptext
655 call write_text_popup 'defaultFont$' 14 '.popupText$'
656 call Draw_button '.table$' '.label$' 2
657 alertText$ = .alertText$
658 call Draw_button '.table$' '.label$' 3
661 # Wait for confirmation
663 if demoInput(.confirmKey$)
664 config.savePerf$ = ""
665 call initialize_toneevaluation_tables
669 call Draw_button '.table$' '.label$' 0
670 call Draw_config_page
674 procedure processConfigListPerf .clickX .clickY .pressed$
677 call Draw_button '.table$' '.label$' 1
679 select Table 'initialiseSGC2.toneevaluation_table$'
683 call Draw_button '.table$' '.label$' 0
684 call Draw_config_page
687 procedure processConfigOpenPerf .clickX .clickY .pressed$
690 call Draw_button '.table$' '.label$' 1
693 call findLabel '.table$' !'.label$'
695 select Table '.table$'
696 .openDialogue$ = Get value... '.row' Helptext
697 call convert_praat_to_latin1 '.openDialogue$'
698 .openDialogue$ = convert_praat_to_latin1.text$
699 .defaultName$= "Performance.tsv"
700 if config.savePerf$ <> ""
701 .defaultName$= config.savePerf$
703 .performance_Name$ = chooseReadFile$ (.openDialogue$)
704 if .performance_Name$ <> "" and fileReadable(.performance_Name$)
705 config.savePerf$ = .performance_Name$
706 call initialize_toneevaluation_tables
710 call Draw_button '.table$' '.label$' 0
711 call Draw_config_page
714 procedure processConfigSavePerf .clickX .clickY .pressed$
717 call Draw_button '.table$' '.label$' 1
720 call findLabel '.table$' '.label$'
722 select Table '.table$'
723 .openDialogue$ = Get value... '.row' Helptext
724 call convert_praat_to_latin1 '.openDialogue$'
725 .openDialogue$ = convert_praat_to_latin1.text$
726 .defaultName$= "Performance.tsv"
727 if config.savePerf$ <> ""
728 .defaultName$= config.savePerf$
730 .performance_Name$ = chooseWriteFile$ (.openDialogue$, .defaultName$)
731 if .performance_Name$ <> ""
732 select Table 'initialiseSGC2.toneevaluation_table$'
733 Write to table file... '.performance_Name$'
734 config.savePerf$ = .performance_Name$
737 call Draw_button '.table$' '.label$' 0
738 call Draw_config_page
741 procedure processConfigManual .clickX .clickY .pressed$
744 call Draw_button '.table$' '.label$' 1
745 if fileReadable("ManPages/SpeakGoodChinese_2.man")
746 Read from file... ManPages/SpeakGoodChinese_2.man
748 Go to manual page... SpeakGoodChinese 2
750 # Wait until the manual is put to the background
752 call Draw_button '.table$' '.label$' 0
754 call Draw_config_page
757 ###############################################################
759 # Obligatory button Processing Routines
761 # These MUST be defined
763 ###############################################################
765 procedure processConfigReturn .clickX .clickY .pressed$
768 call Draw_button '.table$' '.label$' 1
769 call write_preferences ""
772 procedure processConfigRefresh .clickX .clickY .pressed$
775 call Draw_config_page
778 procedure processConfigCredits .clickX .clickY .pressed$
781 call Draw_button '.table$' '.label$' 1
782 call write_text_table Credits_'config.language$'
784 call Draw_button '.table$' '.label$' 0
786 call Draw_config_page
789 procedure processConfigHelp .clickX .clickY .pressed$
792 call help_loop '.table$' Draw_config_page
795 ###############################################################
797 # Miscelaneous supporting code
799 ###############################################################
800 procedure install_wordlists_by_name .wordlist_Name$
801 if .wordlist_Name$ <> ""
802 if index(.wordlist_Name$, "wordlist.")
803 .wordlist_Name$ = replace_regex$(.wordlist_Name$, "[/\\]wordlist\.([^/\\]+)$", "", 0)
804 elsif index_regex(.wordlist_Name$, "(?i\.(wav|flac|iaf[fc]|mp3))")
805 .wordlist_Name$ = replace_regex$(.wordlist_Name$, "[/\\][^/\\]+$", "", 0)
807 if index_regex(.wordlist_Name$, "[/\\]")
808 .sourceDir$ = left$(.wordlist_Name$, rindex_regex(.wordlist_Name$, "[/\\]") -1)
809 .file$ = right$(.wordlist_Name$, length(.wordlist_Name$) - rindex_regex(.wordlist_Name$, "[/\\]"))
810 call readWordlist "'.sourceDir$'" '.file$'
813 if index(.wordlist_Name$, ".")
816 .extension1$ = ".sgc"
817 .extension2$ = ".Table"
818 .extension3$ = ".txt"
819 .extension4$ = ".tsv"
821 for .e from .start to 5
822 .currentExtension$ = .extension'.e'$
823 call readWordlist "'homeDirectory$'" '.wordlist_Name$''.currentExtension$'
824 call readWordlist "'homeDirectory$'/Downloads" '.wordlist_Name$''.currentExtension$'
825 call readWordlist "'homeDirectory$'/Documents" '.wordlist_Name$''.currentExtension$'
826 call readWordlist "'homeDirectory$'/My Documents/Downloads" '.wordlist_Name$''.currentExtension$'
827 call readWordlist "'homeDirectory$'/My Documents" '.wordlist_Name$''.currentExtension$'
828 call readWordlist "'homeDirectory$'/Desktop" '.wordlist_Name$''.currentExtension$'
829 call readWordlist "'preferencesAppDir$'" '.wordlist_Name$''.currentExtension$'
835 # Word lists: It is a VERY good idea to make sure that word-lists
837 procedure load_word_list .localdir$ .relnumber
840 # Remove old word list
842 select Table 'wordlist$'
844 call wipeArea 'wipeWordlistArea$'
848 # Create Table that will recieve the wordlists and directories
849 Create Table with column names... AllWordLists 0 Name Directory
850 .te.currentWordlistRow = 0
852 # First the global word lists
853 if fileReadable(globalwordlists$) or fileReadable("'globalwordlists$'/directory.txt")
854 Create Strings as directory list... WordList 'globalwordlists$'
855 .numLists = Get number of strings
857 select Strings WordList
858 .currentName$ = Get string... '.i'
859 if .currentName$ <> "directory.txt"
860 select Table AllWordLists
861 .listExist = Search column: "Name", .currentName$
864 .te.currentWordlistRow = Get number of rows
865 Set string value... '.te.currentWordlistRow' Name '.currentName$'
866 .currentDirectory$ = globalwordlists$+"/"+.currentName$
867 Set string value... '.te.currentWordlistRow' Directory '.currentDirectory$'
871 select Strings WordList
875 # Now the preferences word lists
876 if fileReadable(sgc2wordlists$) or fileReadable("'sgc2wordlists$'/directory.txt")
877 Create Strings as directory list... WordList 'sgc2wordlists$'
878 .numLists = Get number of strings
880 select Strings WordList
881 .currentName$ = Get string... '.i'
882 if .currentName$ <> "directory.txt"
883 select Table AllWordLists
884 .listExist = Search column: "Name", .currentName$
887 .te.currentWordlistRow = Get number of rows
888 Set string value... '.te.currentWordlistRow' Name '.currentName$'
889 .currentDirectory$ = sgc2wordlists$+"/"+.currentName$
890 Set string value... '.te.currentWordlistRow' Directory '.currentDirectory$'
894 select Strings WordList
898 # End with the word lists in the distribution
899 call CreateCreateWordlists
900 select Table CreateWordlists
901 .numLists = Get number of rows
903 select Table CreateWordlists
904 .currentName$ = Get value... '.i' Name
905 if .currentName$ <> "directory.txt"
906 select Table AllWordLists
907 .listExist = Search column: "Name", .currentName$
909 .procedureName$ = replace_regex$(.currentName$, "[^\w\-\.]", "_", 0)
910 select Table AllWordLists
912 .te.currentWordlistRow = Get number of rows
913 Set string value... '.te.currentWordlistRow' Name '.currentName$'
914 .currentDirectory$ = "*call Create'.procedureName$'"
915 Set string value... '.te.currentWordlistRow' Directory '.currentDirectory$'
919 select Table CreateWordlists
922 # Finally, the local word lists
923 if fileReadable(.localdir$) or fileReadable("'.localdir$'/directory.txt")
924 Create Strings as directory list... WordList '.localdir$'
925 .numLists = Get number of strings
927 select Strings WordList
928 .currentName$ = Get string... '.i'
929 if .currentName$ <> "directory.txt"
930 select Table AllWordLists
931 .listExist = Search column: "Name", .currentName$
934 .te.currentWordlistRow = Get number of rows
935 Set string value... '.te.currentWordlistRow' Name '.currentName$'
936 .currentDirectory$ = .localdir$+"/"+.currentName$
937 Set string value... '.te.currentWordlistRow' Directory '.currentDirectory$'
941 select Strings WordList
945 # Get the position of the current word list
946 select Table AllWordLists
948 .numLists = Get number of rows
950 if wordlistName$ <> ""
951 select Table AllWordLists
952 .currentNumber = Search column... Name 'wordlistName$'
955 wordlistNum = .currentNumber + .relnumber
956 if wordlistNum > .numLists
958 elsif wordlistNum < 1 and .numLists > 0
959 wordlistNum = .numLists
961 select Table AllWordLists
962 wordlistName$ = Get value... 'wordlistNum' Name
963 .dirWordlistName$ = Get value... 'wordlistNum' Directory
964 .dirString$ = replace_regex$(.dirWordlistName$, "[ ]", "&", 0)
966 # Read in full tables
967 if fileReadable("'.dirString$'/wordlist.Table")
968 call readTable '.dirString$'/wordlist.Table
969 if readTable.tableID > 0
970 Rename... 'wordlistName$'
971 # Praat wil change the name if it feels like it
972 wordlist$ = selected$("Table")
973 # Add a Sound column if it is not present
974 .soundIndex = Get column index: "Sound"
976 Append column: "Sound"
982 # Handle (legacy) simple word lists
983 elsif fileReadable("'.dirString$'/wordlist.txt")
984 Create Table with column names... "'wordlistName$'" 0 Pinyin Character Sound Translation
985 wordlist$ = selected$("Table")
986 Read Strings from raw text file... '.dirString$'/wordlist.txt
987 Rename... RawWordList
988 .numWordStrings = Get number of strings
989 for .i to .numWordStrings
990 select Strings RawWordList
994 .currentLine$ = Get string... '.i'
995 # Remove leading whitespace
996 .currentLine$ = replace_regex$(.currentLine$, "^[ \t]+", "", 0)
997 .separatorIndex = index_regex(.currentLine$, "[ \t;\-]")
998 if .separatorIndex <= 0
999 .separatorIndex = length(.currentLine$) + 1
1001 .currentPinyin$ = left$(.currentLine$, .separatorIndex-1)
1002 .currentLine$ = right$(.currentLine$, length(.currentLine$) - .separatorIndex)
1003 # There is more on the line, but we do not know what
1004 if length(.currentLine$) > 0
1005 while length(.currentLine$) > 0
1006 .separatorIndex = index_regex(.currentLine$, "[\t;]")
1007 if .separatorIndex <= 0
1008 .separatorIndex = length(.currentLine$)+1
1010 .currentItem$ = left$(.currentLine$, .separatorIndex-1)
1011 .currentLine$ = right$(.currentLine$, length(.currentLine$) - .separatorIndex )
1012 if index_regex(.currentItem$, ".(spx|flac|wav|mp3)")
1014 .currentFile$ = .currentItem$
1015 elsif index_regex(.currentItem$, "[a-zA-Z0-9]") > 0
1017 .currentTrans$ = .currentItem$
1018 elsif index_regex(.currentItem$, "[^ \t\r\l]") > 0 && index_regex(.currentItem$, "[a-zA-Z0-9\-]") <= 0
1020 .currentChar$ = .currentItem$
1024 if .currentFile$ = "-"
1025 if fileReadable("'.dirString$'/'.currentPinyin$'.spx")
1026 .currentFile$ = .currentPinyin$+".spx"
1027 elsif fileReadable("'.dirString$'/'.currentPinyin$'.flac")
1028 .currentFile$ = .currentPinyin$+".flac"
1029 elsif fileReadable("'.dirString$'/'.currentPinyin$'.wav")
1030 .currentFile$ = .currentPinyin$+".wav"
1031 elsif fileReadable("'.dirString$'/'.currentPinyin$'.mp3")
1032 .currentFile$ = .currentPinyin$+".mp3"
1035 select Table 'wordlist$'
1037 Set string value... '.i' Pinyin '.currentPinyin$'
1038 Set string value... '.i' Sound '.currentFile$'
1039 Set string value... '.i' Character '.currentChar$'
1040 Set string value... '.i' Translation '.currentTrans$'
1042 select Strings RawWordList
1045 select Table 'wordlist$'
1046 elsif fileReadable(.dirString$) or fileReadable("'.dirString$'/directory.txt")
1047 Create Table with column names... "'wordlistName$'" 0 Pinyin Sound
1048 wordlist$ = selected$("Table")
1049 Create Strings as file list... RawWordList '.dirString$'/*
1050 .numWordStrings = Get number of strings
1052 for .j to .numWordStrings
1053 select Strings RawWordList
1054 .currentLine$ = Get string... '.j'
1055 .currentFile$ = extractWord$(.currentLine$, "")
1056 if index_regex(.currentFile$, "\.(spx|flac|wav|mp3)")
1057 .currentPinyin$ = left$(.currentFile$, index(.currentFile$, ".")-1)
1058 select Table 'wordlist$'
1061 Set string value... '.i' Pinyin '.currentPinyin$'
1062 Set string value... '.i' Sound '.currentFile$'
1065 select Strings RawWordList
1068 select Table 'wordlist$'
1069 elsif startsWith(.dirString$, "*call ")
1070 .callProcedure$ = right$(.dirString$, length(.dirString$)-1)
1072 wordlist$ = selected$("Table")
1079 # Can this wordlist be deleted?
1080 if fileReadable("'sgc2wordlists$'/'wordlistName$'") or fileReadable("'sgc2wordlists$'/'wordlistName$'/wordlist.txt") or fileReadable("'sgc2wordlists$'/'wordlistName$'/wordlist.Table")
1081 config.deleteWordlist = 0
1083 config.deleteWordlist = -1
1086 # Check first column name and add Character, Translation and Show columns if missing
1088 select Table 'wordlist$'
1089 # HAck to correct odd behavior of tables with unicode characters
1090 .firstColumn$ = Get column label: 1
1091 if index_regex(.firstColumn$, "^[^!-~]") > 0
1092 .firstColumn$ = replace_regex$(.firstColumn$, "^[^!-~]", "", 0)
1093 Set column label (index): 1, .firstColumn$
1096 te.numberOfWords = Get number of rows
1097 .characterColumn = Get column index... Character
1098 if not .characterColumn
1099 Append column... Character
1100 for .i to te.numberOfWords
1101 Set string value... '.i' Character -
1104 .translationColumn = Get column index... Translation
1105 if not .translationColumn
1106 Append column... Translation
1107 for .i to te.numberOfWords
1108 Set string value... '.i' Translation -
1111 .showColumn = Get column index... Show
1113 Append column... Show
1114 for .i to te.numberOfWords
1115 Set string value... '.i' Show +
1120 # Remove all rows without Pinyin
1121 .numRows = Get number of rows
1123 .rowNum = .numRows - i + 1
1124 .pinyinValue$ = Get value... '.rowNum' Pinyin
1125 if not index_regex(.pinyinValue$, "[a-zA-Z0-9]")
1126 Remove row... '.rowNum'
1129 te.numberOfWords = Get number of rows
1131 # Shuffle words if requested
1132 if config.shuffleLists
1138 select Table AllWordLists
1141 # There were no Word Lists
1144 wordlistName$ = wordlistName$+" No Word Lists available"
1146 Create Table with column names... "'wordlistName$'" 0 Pinyin Character Translation Sound
1147 wordlist$ = selected$("Table")
1151 Set string value... '.i' Pinyin ni3hao3
1152 Set string value... '.i' Character 你好
1153 Set string value... '.i' Translation hello
1154 Set string value... '.i' Sound -
1157 Set string value... '.i' Pinyin xie4xie0
1158 Set string value... '.i' Character 谢谢
1159 Set string value... '.i' Translation thanks
1160 Set string value... '.i' Sound -
1163 Set string value... '.i' Pinyin zai4jian4
1164 Set string value... '.i' Character 再见
1165 Set string value... '.i' Translation goodbye
1166 Set string value... '.i' Sound -
1167 te.numberOfWords = Get number of rows
1170 call set_window_title 'buttons$' 'wordlistName$'
1175 select Table 'wordlist$'
1177 if te.currentWord < 0 or te.currentWord > te.numberOfWords
1178 if config.shuffleLists
1183 while .showCurrent$ = "-" and te.currentWord <= te.numberOfWords
1185 if te.currentWord <= te.numberOfWords
1186 .showCurrent$ = Get value... 'te.currentWord' Show
1192 procedure previous_word
1194 select Table 'wordlist$'
1196 if te.currentWord <= 0
1197 if config.shuffleLists
1200 te.currentWord = te.numberOfWords + 1
1202 while .showCurrent$ = "-" and te.currentWord > 0
1204 if te.currentWord > 0
1205 .showCurrent$ = Get value... 'te.currentWord' Show
1211 procedure display_word_list_name
1215 .displayWordList$ = replace_regex$(wordlistName$, "[_]", " ", 0)
1216 call wipeArea 'wipeWordlistArea$'
1217 call adjustFontSizeOnHeight 'defaultFont$' 'defaultFontSize' 5
1218 .currentFontSize = adjustFontSizeOnHeight.newFontSize
1221 demo Text special... '.xtext' Centre '.ytext' Bottom 'defaultFont$' '.currentFontSize' 0 '.displayWordList$'
1224 call set_font_size 'defaultFontSize'
1227 procedure write_word_list
1228 # Write current Pinyin text
1229 call display_text Black
1231 # Write the current word list name
1232 call display_word_list_name
1235 procedure start_logging
1236 if fileReadable("'preferencesLogDir$'/logPerformance.txt")
1237 .logDirectory$ < 'preferencesLogDir$'/logPerformance.txt
1238 .logDirectory$ = extractWord$(.logDirectory$, "")
1239 if .logDirectory$ = "" or not (fileReadable(.logDirectory$) or fileReadable("'.logDirectory$'/directory.txt")
1240 .logDirectory$ = "'preferencesLogDir$'"
1242 currentLogDirectory$ = "'.logDirectory$'/log'logtimeStamp$'"
1243 createDirectory(currentLogDirectory$)
1244 if not fileReadable("'currentLogDirectory$'/wordlist.Table")
1245 .headerLine$ = "Pinyin'tab$'Character'tab$'Sound'newline$'"
1246 .headerLine$ > 'currentLogDirectory$'/wordlist.Table
1249 config.logPerformance = 1
1253 procedure log_command .logtext$
1255 fileappend "'currentLogDirectory$'/logFile.txt" '.logtext$''newline$'
1259 procedure log_performance .recordedSound$ .register .proficiency .pinyin$ .choice$
1261 .currentDate$ = date$()
1262 .timeStamp$ = replace_regex$(.currentDate$, "[^a-zA-Z0-9\-_]", "-", 0)
1263 .choiceText$ = replace_regex$(.choice$, "[^a-zA-Z0-9\-_]", "-", 0)
1265 if config.logPerformance and fileReadable("'preferencesLogDir$'/logPerformance.txt")
1266 .outfilename$ = .pinyin$+"_"+.choice$+"_'.register'_"+.timeStamp$+".wav"
1267 .logtext$ = "# #+.pinyin$+tab$+.choice$+tab$+"'.register'Hz"+tab$+.currentDate$+tab$+.outfilename$+newline$
1269 fileappend 'currentLogDirectory$'/logFile.txt '.logtext$'
1272 fileappend 'currentLogDirectory$'/wordlist.Table '.pinyin$''tab$''.choice$''tab$''.outfilename$''newline$'
1273 # The recorded sound
1274 select Sound 'recordedSound$'
1275 Write to WAV file... 'currentLogDirectory$'/'.outfilename$'
1279 procedure paint_logging_light
1281 .row = Search column... Label !Logging
1283 exit Button Table Config does not have a row with label !Logging
1286 .leftX = Get value... '.row' LeftX
1287 .rightX = Get value... '.row' RightX
1288 .lowY = Get value... '.row' LowY
1289 .highY = Get value... '.row' HighY
1290 .buttonColor$ = Get value... '.row' Color
1291 .centerX = (.leftX + .rightX)/2
1292 .centerY = (.lowY + .highY)/2
1293 .radius = (.highY - .lowY )/(4*2)
1294 .wipeRadius = 1.1*.radius
1295 if config.logPerformance and fileReadable("'preferencesLogDir$'/logPerformance.txt")
1296 demo Paint circle... White '.centerX' '.centerY' '.wipeRadius'
1297 demo Paint circle... '.buttonColor$' '.centerX' '.centerY' '.radius'
1300 demo Paint circle... White '.centerX' '.centerY' '.wipeRadius'
1305 # Uninstall word lists
1306 procedure removeWordlist .deletedWordlistName$
1308 if fileReadable("'sgc2wordlists$'/'.deletedWordlistName$'") or fileReadable("'sgc2wordlists$'/'.deletedWordlistName$'/wordlist.txt") or fileReadable("'sgc2wordlists$'/'.deletedWordlistName$'/wordlist.Table")
1309 .targetDir$ = "'sgc2wordlists$'/'.deletedWordlistName$'"
1311 if .targetDir$ <> ""
1312 Create Strings as file list... DeleteList '.targetDir$'
1313 .numdeleteFiles = Get number of strings
1314 for .i to .numdeleteFiles
1315 .file$ = Get string... '.i'
1316 deleteFile("'.targetDir$'/'.file$'")
1318 filedelete '.targetDir$'
1319 # Check whether the directory was actually deleted. Make sure this is a valid directory name!
1320 # That is, it does not contain funny characters, nor funny names
1321 if index_regex(.deletedWordlistName$, "[^a-zA-Z0-9_ .\-]") <= 0 and index(.deletedWordlistName$, "..") <= 0 and index_regex(.deletedWordlistName$, "[a-zA-Z]") > 0
1323 nocheck system rmdir "'.targetDir$'" /s /q
1324 elsif fileReadable(.targetDir$)
1325 system bash -rc -- 'rm -r -- "'.targetDir$'"'
1328 # Remove deleted word list
1329 select Strings DeleteList
1330 plus Table 'wordlist$'
1336 # Install word lists
1337 procedure sgc2wordlist .sourceDir$
1338 if startsWith(.sourceDir$, "preferencesDirectory$")
1339 .sourceDir$ = replace$(.sourceDir$, "preferencesDirectory$", preferencesDirectory$)
1342 .targetDirectory$ = "'sgc2wordlists$'"
1343 if fileReadable(.sourceDir$) or fileReadable("'.sourceDir$'/directory.txt")
1344 Create Strings as file list... PackageList '.sourceDir$'/*.sgc
1345 .numFiles = Get number of strings
1347 select Strings PackageList
1348 .file$ = Get string... '.i'
1349 call readWordlist '.sourceDir$' '.file$'
1352 select Strings PackageList
1357 # Debuggin remarks!!!
1358 # fileReadable(<directory>) does not work in Windows
1359 # The file paths / -> \\ must be performed on the filenames in Windows before the system_nocheck is given
1360 # And yet only the 7z decompression has been implemented
1361 windowsUnzipCommand$ = ""
1362 if fileReadable("C:\Program Files\7-Zip\7z.exe")
1363 windowsUnzipCommand$ = """C:\Program Files\7-Zip\7z.exe"" e"
1364 elsif fileReadable("C:\Program Files\WinZip\winzip32.exe")
1365 # !!! Find a way to include the output folder !!!
1366 windowsUnzipCommand$ = "C:\Program Files\WinZip\winzip32.exe"" -min -e "
1368 procedure readWordlist .sourceDir$ .file$
1369 # No use doing anything if the source does not exist
1370 if fileReadable("'.sourceDir$'/'.file$'") or fileReadable("'.sourceDir$'/'.file$'/wordlist.txt") or fileReadable("'.sourceDir$'/'.file$'/wordlist.Table")
1371 # What will be the target wordlist directory?
1372 .targetDirectory$ = "'sgc2wordlists$'"
1373 .dirname$ = left$(.file$, rindex(.file$, ".")-1)
1377 .wordlistDirectory$ = .targetDirectory$+"/"+.dirname$
1378 # Wordlist directory does not exist, neither locally nor in the preferences
1380 .tmpDirs = nocheck Create Strings as directory list... TMPWORDLISTS '.targetDirectory$'/
1381 if .tmpDirs != undefined and .tmpDirs > 0
1382 .numDirs = Get number of strings
1385 .currentString$ = Get string... '.d'
1386 if .currentString$ = .dirname$
1392 if not (.wordListExists or fileReadable(.dirname$) or fileReadable("'.dirname$'/directory.txt") or fileReadable(.wordlistDirectory$) or fileReadable("'.wordlistDirectory$'/directory.txt"))
1394 # Move source to destination
1395 if index(.file$, ".sgc") or index(.file$, ".zip")
1396 if index_regex(.wordlistDirectory$, "[^a-zA-Z0-9_\.\- /~\:]") <= 0 and index_regex(.dirname$, "[^a-zA-Z0-9_\.\- ]") <= 0 and not (windows and windowsUnzipCommand$ = "")
1397 # Create wordlist directory
1398 createDirectory(.wordlistDirectory$)
1400 if macintosh or unix
1401 system bash -rc -- 'cp "'.sourceDir$'/'.file$'" "'.wordlistDirectory$'/"'
1402 system cd ''.wordlistDirectory$'';bash -rc -- 'unzip "'.file$'"'
1403 elsif windows and windowsUnzipCommand$ <> ""
1404 .winWordListDirectory$ = replace_regex$(.wordlistDirectory$, "/", "\\", 0)
1405 .winSourceDirectory$ = replace_regex$("'.sourceDir$'\'.file$'", "/", "\\", 0)
1406 system copy "'.winSourceDirectory$'" "'.winWordListDirectory$'" /Y
1407 system chdir /d "'.winWordListDirectory$'" && 'windowsUnzipCommand$' "'.file$'"
1410 deleteFile("'.wordlistDirectory$'/'.file$'")
1411 # Remove if not valid!
1412 if fileReadable("'.wordlistDirectory$'/wordlist.Table") or fileReadable("'.wordlistDirectory$'/wordlist.txt") or fileReadable("'.wordlistDirectory$'/LICENSE.txt")
1413 if fileReadable("'.wordlistDirectory$'/wordlist.Table")
1414 call readTable '.sourceDir$'/'.file$'
1415 if readTable.tableID > 0
1416 select readTable.tableID
1417 # Hack around odd behavior of column index
1419 .firstColumn$ = Get column label: 1
1420 .firstColumn$ = replace_regex$(.firstColumn$, "^[^!-~]", "", 0)
1421 if .firstColumn$ = "Pinyin"
1424 .pinyinCol = Get column index... Pinyin
1427 # No Pinyin in table
1436 # None of wordlist.Table, wordlist.txt, nor LICENSE.txt
1439 ### REALLY DANGEROUS STUFF, SHOULD BE HANDLED BETTER
1441 # Remove newly created directory
1442 if index_regex(.wordlistDirectory$, "[^a-zA-Z0-9_\.\- /~\:]") <= 0 and index_regex(.dirname$, "[^a-zA-Z0-9_\.\- ]") <= 0 and index(.dirname$, "..") <= 0
1443 if macintosh or unix
1444 system bash -rc -- 'rm -r "'.wordlistDirectory$'/"'
1446 system rmdir /Q /S "'.winWordListDirectory$'/"
1450 elsif index_regex(.file$, "\.(Table|txt|tsv)")
1451 # Check whether this is a valid table
1452 call readTable '.sourceDir$'/'.file$'
1453 if readTable.tableID > 0
1454 select readTable.tableID
1455 # Hack around odd behavior of column index
1457 .firstColumn$ = Get column label: 1
1458 .firstColumn$ = replace_regex$(.firstColumn$, "^[^!-~]", "", 0)
1459 if .firstColumn$ = "Pinyin"
1462 .pinyinCol = Get column index... Pinyin
1467 # Create wordlist directory
1468 createDirectory(.wordlistDirectory$)
1470 .extension$ = replace_regex$(.file$, "^.+\.(Table|txt|tsv)$", "\1", 0)
1471 if .extension$ = "tsv"
1472 .extension$ = "Table"
1474 if macintosh or unix
1475 system bash -rc -- 'cp "'.sourceDir$'/'.file$'" "'.wordlistDirectory$'/wordlist.'.extension$'"'
1477 .winWordListDirectory$ = replace_regex$(.wordlistDirectory$, "/", "\\", 0)
1478 .winSourceDirectory$ = replace_regex$("'.sourceDir$'\'.file$'", "/", "\\", 0)
1479 system copy "'.winSourceDirectory$'" "'.winWordListDirectory$'\wordlist.'.extension$'" /q
1483 elsif fileReadable("'.sourceDir$'/'.file$'/wordlist.Table") or fileReadable("'.sourceDir$'/'.file$'/wordlist.txt") or fileReadable("'.sourceDir$'/'.file$'/LICENSE.txt")
1484 # Copy wordlist directory
1485 if index_regex(.file$, "[^a-zA-Z0-9_\.\- ]") <= 0
1487 if macintosh or unix
1488 system bash -rc -- 'cp -r "'.sourceDir$'/'.file$'" "'.wordlistDirectory$'"'
1490 createDirectory(.wordlistDirectory$)
1491 .winWordListDirectory$ = replace_regex$(.wordlistDirectory$, "/", "\\", 0)
1492 .winSourceDirectory$ = replace_regex$("'.sourceDir$'\'.file$'", "/", "\\", 0)
1493 system xcopy "'.winSourceDirectory$'" "'.winWordListDirectory$'" /s /e /q
1498 # Set current word list to read list
1500 wordlistName$ = .dirname$
1503 .label$ = "!NotAWordlist"
1506 call findLabel '.table$' '.label$'
1507 .row = findLabel.row
1508 select Table '.table$'
1509 .helpText$ = Get value... '.row' Helptext
1510 .filetext$ = replace_regex$("'.sourceDir$'/'.file$'", "_", "\\_ ", 0)
1511 call write_text_popup 'defaultFont$' 14 '.helpText$' "'.filetext$'"
1512 # Wait for confirmation