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 DrawSaveAudio .color$ .x .y .size
94 elsif .color$ = "Blue"
95 .color$ = "{0.5,0.5,1}"
99 demo Paint circle... '.color$' '.x' '.y' '.size'
102 ###############################################################
104 # Obligatory button Drawing Routines
106 # These MUST be defined
108 ###############################################################
110 procedure DrawReturn .color$ .x .y .size
111 call DrawConfig '.color$' '.x' '.y' '.size'
114 # Set the correct button states after redrawing the window
115 procedure setConfigMainPage
116 call Draw_button 'config$' +SaveAudio 'sgc.saveAudioOn'
117 # call Draw_button 'config$' SavePerf 'sgc.saveAudioOn'
118 # call Draw_button 'config$' OpenPerf 'sgc.saveAudioOn'
119 # call Draw_button 'config$' ClearSummary 'sgc.saveAudioOn'
122 ###############################################################
124 # Button Processing Routines
126 ###############################################################
128 procedure processConfigShuffleLists .clickX .clickY .pressed$
130 .label$ = "ShuffleLists"
131 config.shuffleLists = not config.shuffleLists
132 .displayButton = 2*config.shuffleLists
133 call Draw_button '.table$' '.label$' '.displayButton'
136 procedure processConfigUseSoundExample .clickX .clickY .pressed$
138 .label$ = "UseSoundExample"
139 config.useSoundExample = not config.useSoundExample
140 .displayButton = 2*config.useSoundExample
141 call Draw_button '.table$' '.label$' '.displayButton'
144 procedure processConfigSynthesis .tts$ .clickX .clickY .pressed$
146 .label$ = "Synthesis_'.tts$'"
147 if sgc2.synthesizer > 0 or (speakCommandFile$ <> "" and fileReadable(speakCommandFile$))
148 if config.synthesis$ = ""
149 config.synthesis$ = .tts$
152 config.synthesis$ = ""
156 config.synthesis$ = "_DISABLED_"
159 call Draw_button '.table$' '.label$' '.displayButton'
162 procedure processConfigStrict .clickX .clickY .pressed$
165 config.strict = not config.strict
171 # Change TTS for Strict!
173 call Draw_button '.table$' '.label$' '.displayButton'
176 procedure processConfigDisplayPinyin .clickX .clickY .pressed$
178 .label$ = "DisplayPinyin"
179 config.displayPinyin = not config.displayPinyin
180 .displayButton = 2*config.displayPinyin
181 call Draw_button '.table$' '.label$' '.displayButton'
184 procedure processConfigDisplayChar .clickX .clickY .pressed$
186 .label$ = "DisplayChar"
187 config.displayChar = not config.displayChar
188 .displayButton = 2*config.displayChar
189 call Draw_button 'table$' '.label$' '.displayButton'
192 procedure processConfigDisplayTrans .clickX .clickY .pressed$
194 .label$ = "DisplayTrans"
195 config.displayTrans = not config.displayTrans
196 .displayButton = 2*config.displayTrans
197 call Draw_button 'table$' '.label$' '.displayButton'
200 procedure processConfigDisplayNumbers .clickX .clickY .pressed$
202 .label$ = "DisplayNumbers"
203 config.displayNumbers = not config.displayNumbers
204 .displayButton = 2*config.displayNumbers
205 call Draw_button 'table$' '.label$' '.displayButton'
208 procedure processConfigLanguage .language$ .clickX .clickY .pressed$
210 .label$ = "Language_'.language$'"
211 call processLanguageCodes '.table$' '.label$'
214 procedure processConfigShowBackground .clickX .clickY .pressed$
216 .label$ = "ShowBackground"
217 config.showBackground = not config.showBackground
218 .displayButton = 2*config.showBackground
219 call Draw_button 'table$' '.label$' '.displayButton'
222 procedure processConfigInput .input$ .clickX .clickY .pressed$
224 .label$ = "Input_'.input$'"
225 call Draw_button '.table$' Input_'config.input$' 0
226 config.input$ = .input$
227 call Draw_button '.table$' Input_'config.input$' 2
230 procedure processConfigRegister .register .clickX .clickY .pressed$
232 .label$ = "Register_'.register'"
233 call setRegisterFromLabel '.table$' '.label$'
236 procedure setRegisterFromLabel .table$ .label$
237 call Draw_button '.table$' Register_'config.register' 0
238 call Draw_button '.table$' '.label$' 2
239 # Someone might have to use more than 3 chars for the config.register code
240 .numChars = length(.label$) - length("Register_")
241 .registerText$ = right$(.label$, .numChars)
242 config.register = '.registerText$'
245 procedure processConfigDeleteWordlist .clickX .clickY .pressed$
247 .label$ = "DeleteWordlist"
249 # Do not process undeletable word lists, only those stored in the
250 # preferencesDirectory$ can be deleted
251 if fileReadable("'sgc2wordlists$'/'wordlistName$'") or fileReadable("'sgc2wordlists$'/'wordlistName$'/wordlist.txt") or fileReadable("'sgc2wordlists$'/'wordlistName$'/wordlist.Table")
252 call findLabel '.table$' !'.label$'
254 select Table '.table$'
255 .alertText$ = Get value... 'findLabel.row' Text
256 .confirmKey$ = Get value... 'findLabel.row' Key
257 .popupText$ = Get value... 'findLabel.row' Helptext
259 exit Cannot find delete directive: '.table$' !'.label$'
261 call write_text_popup 'defaultFont$' 14 '.popupText$'
262 call Draw_button '.table$' '.label$' 2
263 alertText$ = .alertText$
264 call Draw_button '.table$' '.label$' 3
267 # Wait for confirmation
269 if demoInput(.confirmKey$)
270 .deleteWordListDir$ = wordlistName$
271 call load_word_list "'localWordlistDir$'" 1
272 call removeWordlist '.deleteWordListDir$'
273 call load_word_list "'localWordlistDir$'" 0
275 call Draw_button '.table$' '.label$' 0
276 call Draw_config_page
280 wordlistTag$ = "Wordlist name"
281 procedure processConfigInstallWordlist .clickX .clickY .pressed$
283 .label$ = "InstallWordlist"
284 call Draw_button '.table$' '.label$' 1
286 # Do not use the automatic sgc list option, ask for a wordlist NAME
288 call findLabel '.table$' '.label$'
290 select Table '.table$'
291 .openDialogue$ = Get value... '.row' Helptext
292 call convert_praat_to_latin1 '.openDialogue$'
293 .openDialogue$ = convert_praat_to_latin1.text$
294 .wordlistButton$ = replace$(wordlistTag$, " ", "_", 0)
295 .wordlistButton$ = replace_regex$(.wordlistButton$, "^.", "\l&", 0)
296 beginPause(.openDialogue$)
297 sentence (wordlistTag$, "")
298 clicked = endPause ("Cancel", "Open", 2, 1)
301 .wordlist_Name$ = '.wordlistButton$'$
303 call install_wordlists_by_name '.wordlist_Name$'
305 call sgc2wordlist 'homeDirectory$'
306 call sgc2wordlist 'homeDirectory$'/Downloads
307 call sgc2wordlist 'homeDirectory$'/Documents
308 call sgc2wordlist 'homeDirectory$'/My Documents
309 call sgc2wordlist 'homeDirectory$'/My Documents/Downloads
310 call sgc2wordlist 'homeDirectory$'/Desktop
311 call sgc2wordlist 'preferencesAppDir$'
313 call load_word_list "'localWordlistDir$'" 0
314 call Draw_button '.table$' '.label$' 0
315 call Draw_config_page
318 procedure processConfigOpenWordlist .clickX .clickY .pressed$
320 .label$ = "OpenWordlist"
321 call Draw_button '.table$' '.label$' 1
324 call findLabel '.table$' '.label$'
326 select Table '.table$'
327 .openDialogue$ = Get value... '.row' Helptext
328 call convert_praat_to_latin1 '.openDialogue$'
329 .openDialogue$ = convert_praat_to_latin1.text$
331 .wordlist_Name$ = chooseReadFile$ (.openDialogue$)
332 call install_wordlists_by_name '.wordlist_Name$'
333 call load_word_list "'localWordlistDir$'" 0
334 call Draw_button '.table$' '.label$' 0
335 call Draw_config_page
338 # Select the words to practise. This is quite a complex piece of code
339 procedure processConfigSelectWords .clickX .clickY .pressed$
341 .label$ = "SelectWords"
342 call Draw_button '.table$' '.label$' 1
345 call findLabel '.table$' '.label$'
347 select Table '.table$'
348 .helpText$ = Get value... '.row' Helptext
349 call convert_praat_to_latin1 '.helpText$'
350 .helpText$ = convert_praat_to_latin1.text$
353 select Table 'wordlist$'
354 .tmpOriginalWordlist = Copy: "Original_'wordlist$'"
358 select Table 'wordlist$'
359 te.numberOfWords = Get number of rows
360 .currentWord = te.currentWord
361 if .currentWord <= 0 or .currentWord > te.numberOfWords or config.shuffleLists
366 call get_feedback_text 'config.language$' Part
367 call convert_praat_to_latin1 'get_feedback_text.text$'
368 .partText$ = convert_praat_to_latin1.text$
369 call get_feedback_text 'config.language$' Tones
370 call convert_praat_to_latin1 'get_feedback_text.text$'
371 .toneText$ = convert_praat_to_latin1.text$
372 call get_feedback_text 'config.language$' Cancel
373 call convert_praat_to_latin1 'get_feedback_text.text$'
374 .cancelText$ = convert_praat_to_latin1.text$
375 call get_feedback_text 'config.language$' Clear
376 call convert_praat_to_latin1 'get_feedback_text.text$'
377 .clearText$ = convert_praat_to_latin1.text$
378 call get_feedback_text 'config.language$' All
379 call convert_praat_to_latin1 'get_feedback_text.text$'
380 .allText$ = convert_praat_to_latin1.text$
381 call get_feedback_text 'config.language$' Previous
382 call convert_praat_to_latin1 'get_feedback_text.text$'
383 .prevWord$ = convert_praat_to_latin1.text$
384 call get_feedback_text 'config.language$' Next
385 call convert_praat_to_latin1 'get_feedback_text.text$'
386 .nextWord$ = convert_praat_to_latin1.text$
387 call get_feedback_text 'config.language$' Continue
388 call convert_praat_to_latin1 'get_feedback_text.text$'
389 .continueText$ = convert_praat_to_latin1.text$
390 call get_feedback_text 'config.language$' Show
391 call convert_praat_to_latin1 'get_feedback_text.text$'
392 .showText$ = convert_praat_to_latin1.text$
394 .pinyinText$ = "Pinyin"
395 .characterText$ = "Character"
398 select Table 'wordlist$'
399 .lessonCol = Get column index: "Lesson"
402 # All shown keeps track whether all words are shown
403 # If so, selecting a lesson is preceded by a Clear All
405 # Sort words for consistent selection interface
406 if config.shuffleLists
407 # Allow subdivision in lessons
409 Sort rows... Lesson Pinyin
415 for .i to te.numberOfWords
416 .currentLesson$ = Get value: .i, "Lesson"
417 if .currentLesson$ <> "" and .currentLesson$ <> "-" and index_regex(.lessonList$, "\t'.currentLesson$'\t") <= 0
418 .lessonList$ = .lessonList$ + .currentLesson$ + tab$
420 .lessonName$['.numLessons'] = .currentLesson$
422 .shown$ = Get value: .i, "Show"
430 .numWordsPerScreen = 15
431 while clicked <> 6 and clicked <> 1
436 select Table 'wordlist$'
437 .lessonCol = Get column index: "Lesson"
438 # Sort words for consistent selection interface
439 if config.shuffleLists
440 # Allow subdivision in lessons
442 Sort rows... Lesson Pinyin
447 .max = .numWordsPerScreen - 1
448 if .currentWord + .max > te.numberOfWords
449 .max = te.numberOfWords - .currentWord
451 for .i from 0 to .numWordsPerScreen - 1
453 .pinyin$[.i] = Get value: .currentWord+.i, "Pinyin"
454 .character$[.i] = Get value: .currentWord+.i, "Character"
457 .lessonNum$[.i] = Get value: .currentWord+.i, "Lesson"
458 .lessonNum$[.i] = " : " + .lessonNum$[.i]
460 .showText$[.i] = .pinyin$['.i']
461 if .character$['.i'] <> "-"
462 .showText$[.i] = .pinyin$['.i']+" ("+.character$['.i']+.lessonNum$['.i']+")"
463 elsif .lessonNum$['.i'] <> ""
464 .showText$[.i] = .pinyin$['.i']+" ( -"+.lessonNum$['.i']+")"
466 .showValueText$[.i] = Get value: .currentWord+.i, "Show"
467 if .showValueText$[.i] = "-"
472 .showVariable$[.i] = replace_regex$(.pinyin$[.i], ".+", "\l&", 0)
473 .showVariable$[.i] = replace_regex$(.showVariable$[.i], " ", "_", 0)
474 .tmp$ = .showVariable$['.i']
475 '.tmp$' = .showValue[.i]
482 # The user text input window (beginPause .... endPause)
483 beginPause(.helpText$)
484 boolean (.showText$[0], .showValue[0])
485 boolean (.showText$[1], .showValue[1])
486 boolean (.showText$[2], .showValue[2])
487 boolean (.showText$[3], .showValue[3])
488 boolean (.showText$[4], .showValue[4])
489 boolean (.showText$[5], .showValue[5])
490 boolean (.showText$[6], .showValue[6])
491 boolean (.showText$[7], .showValue[7])
492 boolean (.showText$[8], .showValue[8])
493 boolean (.showText$[9], .showValue[9])
494 boolean (.showText$[10], .showValue[10])
495 boolean (.showText$[11], .showValue[11])
496 boolean (.showText$[12], .showValue[12])
497 boolean (.showText$[13], .showValue[13])
498 boolean (.showText$[14], .showValue[14])
500 optionMenu: .partText$, 1
503 for .j to .numLessons
504 option: .lessonName$['.j']
507 optionMenu: .toneText$, 1
514 clicked = endPause ("'.cancelText$'", "'.clearText$'", "'.allText$'", "'.prevWord$'", "'.nextWord$'", "'.continueText$'", 6, 1)
517 for .i to te.numberOfWords
518 Set string value: .i, "Show", "-"
522 for .i to te.numberOfWords
523 Set string value: .i, "Show", "+"
527 # Get selected Part BEFORE we do anything else
529 .tmp$ = replace_regex$(.partText$, "^(.)", "\l\1", 0)
530 .lessonSelected = '.tmp$' - 1
532 if .lessonSelected > 0
535 select Table 'wordlist$'
536 for .i to te.numberOfWords
537 # Keep track of whether all are shown
538 .shown$ = Get value: .i, "Show"
543 for .i to te.numberOfWords
545 .currentLesson$ = Get value: .i, "Lesson"
546 if .currentLesson$ = .lessonName$['.lessonSelected']
547 Set string value: .i, "Show", "+"
549 Set string value: .i, "Show", "-"
552 for .i to te.numberOfWords
553 # Keep track of whether all are shown
554 .shown$ = Get value: .i, "Show"
555 if .firstShown <=0 and .shown$ <> "-"
560 for .i from 0 to .max
561 .tmp$ = .showVariable$['.i']
562 .showValue['.i'] = '.tmp$'
563 .showWord$['.i'] = "-"
564 if .showValue['.i'] <> 0
565 .showWord$['.i'] = "+"
567 Set string value: .currentWord+.i, "Show", .showWord$['.i']
570 .tmp$ = replace_regex$(.toneText$, "^(.)", "\l\1", 0)
571 .toneSelected = '.tmp$' - 2
572 if .toneSelected >= 0
573 select Table 'wordlist$'
574 for .i to te.numberOfWords
575 .currentPinyin$ = Get value: .i, "Pinyin"
576 .tmp$ = Get value: .i, "Show"
577 if .tmp$ <> "-" and index(.currentPinyin$, "'.toneSelected'") > 0
578 Set string value: .i, "Show", "+"
580 Set string value: .i, "Show", "-"
588 .currentWord = (.firstShown div .numWordsPerScreen) * .numWordsPerScreen + 1
589 elsif .toneSelected < 0
590 .currentWord -= .numWordsPerScreen
593 .currentWord = (te.numberOfWords div .numWordsPerScreen) * .numWordsPerScreen + 1
597 .currentWord = (.firstShown div .numWordsPerScreen) * .numWordsPerScreen + 1
598 elsif .toneSelected < 0
599 .currentWord += .numWordsPerScreen
601 if .currentWord > te.numberOfWords
606 # Reset and go to the first selected word (can shuffle list)
615 select Table 'wordlist$'
617 select .tmpOriginalWordlist
620 select .tmpOriginalWordlist
622 call Draw_button '.table$' '.label$' 0
625 procedure processConfigPerfSummary .clickX .clickY .pressed$
627 .label$ = "PerfSummary"
629 call testLoadTable SummaryToneEvaluation
630 if testLoadTable.table > 0
631 call Draw_button '.table$' '.label$' 1
632 call loadTable SummaryToneEvaluation
633 call write_tabbed_table SummaryToneEvaluation Evaluation_'config.language$'
635 select Table SummaryToneEvaluation
638 call Draw_button '.table$' '.label$' 0
639 call Draw_config_page
643 # Wipe current performance table and initialize a new one
644 procedure processConfigClearSummary .clickX .clickY .pressed$
646 .label$ = "ClearSummary"
648 call Draw_button '.table$' '.label$' 1
650 if not sgc.saveAudioOn
651 select Table '.table$'
652 call findLabel '.table$' !'.label$'
654 .alertText$ = Get value... 'findLabel.row' Text
655 .confirmKey$ = Get value... 'findLabel.row' Key
656 .popupText$ = Get value... 'findLabel.row' Helptext
658 call write_text_popup 'defaultFont$' 14 '.popupText$'
659 call Draw_button '.table$' '.label$' 2
660 alertText$ = .alertText$
661 call Draw_button '.table$' '.label$' 3
664 # Wait for confirmation
666 if demoInput(.confirmKey$)
668 call initialize_toneevaluation_tables
673 call Draw_button '.table$' '.label$' 'sgc.saveAudioOn'
674 call Draw_config_page
678 procedure processConfigListPerf .clickX .clickY .pressed$
681 call Draw_button '.table$' '.label$' 1
683 select Table 'initialiseSGC2.toneevaluation_table$'
687 call Draw_button '.table$' '.label$' 0
688 call Draw_config_page
691 procedure processConfigOpenPerf .clickX .clickY .pressed$
694 call Draw_button '.table$' '.label$' 1
696 if not sgc.saveAudioOn
698 call findLabel '.table$' !'.label$'
700 select Table '.table$'
701 .openDialogue$ = Get value... '.row' Helptext
702 call convert_praat_to_latin1 '.openDialogue$'
703 .openDialogue$ = convert_praat_to_latin1.text$
704 .defaultName$= "Performance.tsv"
705 if sgc.savePerf$ <> ""
706 .defaultName$= sgc.savePerf$
708 .performance_Name$ = chooseReadFile$ (.openDialogue$)
709 if .performance_Name$ <> "" and fileReadable(.performance_Name$)
710 sgc.savePerf$ = .performance_Name$
711 call initialize_toneevaluation_tables
713 # Set SaveAudio directory if it is not currently "in use"
714 if not sgc.saveAudioOn
715 sgc.saveAudio$ = replace_regex$(sgc.savePerf$, "/[^/]+$", "", 0)
716 # We are not sure yet that this is actually an audio directory
717 config.audioName$ = ""
722 call Draw_button '.table$' '.label$' 'sgc.saveAudioOn'
723 call Draw_config_page
726 procedure processConfigSavePerf .clickX .clickY .pressed$
729 call Draw_button '.table$' '.label$' 1
731 if not sgc.saveAudioOn
733 call findLabel '.table$' '.label$'
735 select Table '.table$'
736 .openDialogue$ = Get value... '.row' Helptext
737 call convert_praat_to_latin1 '.openDialogue$'
738 .openDialogue$ = convert_praat_to_latin1.text$
739 .defaultName$= "Performance.tsv"
740 if sgc.savePerf$ <> ""
741 .defaultName$= sgc.savePerf$
743 .performance_Name$ = chooseWriteFile$ (.openDialogue$, .defaultName$)
744 if .performance_Name$ <> ""
745 select Table 'initialiseSGC2.toneevaluation_table$'
746 Write to table file... '.performance_Name$'
747 sgc.savePerf$ = .performance_Name$
751 call Draw_button '.table$' '.label$' 'sgc.saveAudioOn'
752 call Draw_config_page
755 procedure processConfigManual .clickX .clickY .pressed$
758 call Draw_button '.table$' '.label$' 1
759 if fileReadable("ManPages/SpeakGoodChinese_2.man")
760 Read from file... ManPages/SpeakGoodChinese_2.man
762 Go to manual page... SpeakGoodChinese 2
764 # Wait until the manual is put to the background
766 call Draw_button '.table$' '.label$' 0
768 call Draw_config_page
771 procedure processConfigSaveAudio .clickX .clickY .pressed$
773 .label$ = "SaveAudio"
774 call Draw_button '.table$' '.label$' 1
776 if sgc.saveAudioOn = 0
778 call findLabel '.table$' '.label$'
780 select Table '.table$'
781 .openDialogue$ = Get value... '.row' Helptext
782 call convert_praat_to_latin1 '.openDialogue$'
783 .openDialogue$ = convert_praat_to_latin1.text$
785 sgc.saveAudio$ = chooseDirectory$ (.openDialogue$)
786 if sgc.saveAudio$ <> ""
788 .currentPathName$ = replace_regex$(sgc.saveAudio$, "[^/]*/?$", "", 0)
789 .currentDirName$ = replace$(sgc.saveAudio$, .currentPathName$, "", 0)
792 config.clearSummary = -1
793 config.audioName$ = .currentDirName$
795 # Clear performance table and open/create sgc.savePerf$
796 sgc.savePerf$ = "'sgc.saveAudio$'/'.currentDirName$'.tsv"
797 call initialize_toneevaluation_tables
799 if sgc.savePerf$ <> "" and initialiseSGC2.toneevaluation_table$ <> ""
800 select Table 'initialiseSGC2.toneevaluation_table$'
801 Write to table file: sgc.savePerf$
804 config.audioName$ = ""
810 config.clearSummary = 0
811 # Store current performance table
812 if sgc.savePerf$ <> "" and fileReadable(sgc.savePerf$)
813 select Table 'initialiseSGC2.toneevaluation_table$'
814 Write to table file... 'sgc.savePerf$'
818 call Draw_button '.table$' '.label$' 'sgc.saveAudioOn'
819 call Draw_config_page
822 ###############################################################
824 # Obligatory button Processing Routines
826 # These MUST be defined
828 ###############################################################
830 procedure processConfigReturn .clickX .clickY .pressed$
833 call Draw_button '.table$' '.label$' 1
834 call write_preferences ""
837 procedure processConfigRefresh .clickX .clickY .pressed$
840 call Draw_config_page
843 procedure processConfigCredits .clickX .clickY .pressed$
846 call Draw_button '.table$' '.label$' 1
847 call write_text_table Credits_'config.language$'
849 call Draw_button '.table$' '.label$' 0
851 call Draw_config_page
854 procedure processConfigHelp .clickX .clickY .pressed$
857 call help_loop '.table$' Draw_config_page
860 ###############################################################
862 # Miscelaneous supporting code
864 ###############################################################
865 procedure install_wordlists_by_name .wordlist_Name$
866 if .wordlist_Name$ <> ""
867 if index(.wordlist_Name$, "wordlist.")
868 .wordlist_Name$ = replace_regex$(.wordlist_Name$, "[/\\]wordlist\.([^/\\]+)$", "", 0)
869 elsif index_regex(.wordlist_Name$, "(?i\.(wav|flac|iaf[fc]|mp3))")
870 .wordlist_Name$ = replace_regex$(.wordlist_Name$, "[/\\][^/\\]+$", "", 0)
872 if index_regex(.wordlist_Name$, "[/\\]")
873 .sourceDir$ = left$(.wordlist_Name$, rindex_regex(.wordlist_Name$, "[/\\]") -1)
874 .file$ = right$(.wordlist_Name$, length(.wordlist_Name$) - rindex_regex(.wordlist_Name$, "[/\\]"))
875 call readWordlist "'.sourceDir$'" '.file$'
878 if index(.wordlist_Name$, ".")
881 .extension1$ = ".sgc"
882 .extension2$ = ".Table"
883 .extension3$ = ".txt"
884 .extension4$ = ".tsv"
886 for .e from .start to 5
887 .currentExtension$ = .extension'.e'$
888 call readWordlist "'homeDirectory$'" '.wordlist_Name$''.currentExtension$'
889 call readWordlist "'homeDirectory$'/Downloads" '.wordlist_Name$''.currentExtension$'
890 call readWordlist "'homeDirectory$'/Documents" '.wordlist_Name$''.currentExtension$'
891 call readWordlist "'homeDirectory$'/My Documents/Downloads" '.wordlist_Name$''.currentExtension$'
892 call readWordlist "'homeDirectory$'/My Documents" '.wordlist_Name$''.currentExtension$'
893 call readWordlist "'homeDirectory$'/Desktop" '.wordlist_Name$''.currentExtension$'
894 call readWordlist "'preferencesAppDir$'" '.wordlist_Name$''.currentExtension$'
900 # Word lists: It is a VERY good idea to make sure that word-lists
902 procedure load_word_list .localdir$ .relnumber
905 # Remove old word list
907 select Table 'wordlist$'
909 call wipeArea 'wipeWordlistArea$'
913 # Create Table that will recieve the wordlists and directories
914 Create Table with column names... AllWordLists 0 Name Directory
915 .te.currentWordlistRow = 0
917 # First the global word lists
918 if fileReadable(globalwordlists$) or fileReadable("'globalwordlists$'/directory.txt")
919 Create Strings as directory list... WordList 'globalwordlists$'
920 .numLists = Get number of strings
922 select Strings WordList
923 .currentName$ = Get string... '.i'
924 if .currentName$ <> "directory.txt"
925 select Table AllWordLists
926 .listExist = Search column: "Name", .currentName$
929 .te.currentWordlistRow = Get number of rows
930 Set string value... '.te.currentWordlistRow' Name '.currentName$'
931 .currentDirectory$ = globalwordlists$+"/"+.currentName$
932 Set string value... '.te.currentWordlistRow' Directory '.currentDirectory$'
936 select Strings WordList
940 # Now the preferences word lists
941 if fileReadable(sgc2wordlists$) or fileReadable("'sgc2wordlists$'/directory.txt")
942 Create Strings as directory list... WordList 'sgc2wordlists$'
943 .numLists = Get number of strings
945 select Strings WordList
946 .currentName$ = Get string... '.i'
947 if .currentName$ <> "directory.txt"
948 select Table AllWordLists
949 .listExist = Search column: "Name", .currentName$
952 .te.currentWordlistRow = Get number of rows
953 Set string value... '.te.currentWordlistRow' Name '.currentName$'
954 .currentDirectory$ = sgc2wordlists$+"/"+.currentName$
955 Set string value... '.te.currentWordlistRow' Directory '.currentDirectory$'
959 select Strings WordList
963 # End with the word lists in the distribution
964 call CreateCreateWordlists
965 select Table CreateWordlists
966 .numLists = Get number of rows
968 select Table CreateWordlists
969 .currentName$ = Get value... '.i' Name
970 if .currentName$ <> "directory.txt"
971 select Table AllWordLists
972 .listExist = Search column: "Name", .currentName$
974 .procedureName$ = replace_regex$(.currentName$, "[^\w\-\.]", "_", 0)
975 select Table AllWordLists
977 .te.currentWordlistRow = Get number of rows
978 Set string value... '.te.currentWordlistRow' Name '.currentName$'
979 .currentDirectory$ = "*call Create'.procedureName$'"
980 Set string value... '.te.currentWordlistRow' Directory '.currentDirectory$'
984 select Table CreateWordlists
987 # Finally, the local word lists
988 if fileReadable(.localdir$) or fileReadable("'.localdir$'/directory.txt")
989 Create Strings as directory list... WordList '.localdir$'
990 .numLists = Get number of strings
992 select Strings WordList
993 .currentName$ = Get string... '.i'
994 if .currentName$ <> "directory.txt"
995 select Table AllWordLists
996 .listExist = Search column: "Name", .currentName$
999 .te.currentWordlistRow = Get number of rows
1000 Set string value... '.te.currentWordlistRow' Name '.currentName$'
1001 .currentDirectory$ = .localdir$+"/"+.currentName$
1002 Set string value... '.te.currentWordlistRow' Directory '.currentDirectory$'
1006 select Strings WordList
1010 # Get the position of the current word list
1011 select Table AllWordLists
1013 .numLists = Get number of rows
1015 if wordlistName$ <> ""
1016 select Table AllWordLists
1017 .currentNumber = Search column... Name 'wordlistName$'
1020 wordlistNum = .currentNumber + .relnumber
1021 if wordlistNum > .numLists
1023 elsif wordlistNum < 1 and .numLists > 0
1024 wordlistNum = .numLists
1026 select Table AllWordLists
1027 wordlistName$ = Get value... 'wordlistNum' Name
1028 .dirWordlistName$ = Get value... 'wordlistNum' Directory
1029 .dirString$ = replace_regex$(.dirWordlistName$, "[ ]", "&", 0)
1031 # Read in full tables
1032 if fileReadable("'.dirString$'/wordlist.Table")
1033 call readTable '.dirString$'/wordlist.Table
1034 if readTable.tableID > 0
1035 Rename... 'wordlistName$'
1036 # Praat wil change the name if it feels like it
1037 wordlist$ = selected$("Table")
1038 # Add a Sound column if it is not present
1039 .soundIndex = Get column index: "Sound"
1041 Append column: "Sound"
1047 # Handle (legacy) simple word lists
1048 elsif fileReadable("'.dirString$'/wordlist.txt")
1049 Create Table with column names... "'wordlistName$'" 0 Pinyin Character Sound Translation
1050 wordlist$ = selected$("Table")
1051 Read Strings from raw text file... '.dirString$'/wordlist.txt
1052 Rename... RawWordList
1053 .numWordStrings = Get number of strings
1054 for .i to .numWordStrings
1055 select Strings RawWordList
1058 .currentTrans$ = "-"
1059 .currentLine$ = Get string... '.i'
1060 # Remove leading whitespace
1061 .currentLine$ = replace_regex$(.currentLine$, "^[ \t]+", "", 0)
1062 .separatorIndex = index_regex(.currentLine$, "[ \t;\-]")
1063 if .separatorIndex <= 0
1064 .separatorIndex = length(.currentLine$) + 1
1066 .currentPinyin$ = left$(.currentLine$, .separatorIndex-1)
1067 .currentLine$ = right$(.currentLine$, length(.currentLine$) - .separatorIndex)
1068 # There is more on the line, but we do not know what
1069 if length(.currentLine$) > 0
1070 while length(.currentLine$) > 0
1071 .separatorIndex = index_regex(.currentLine$, "[\t;]")
1072 if .separatorIndex <= 0
1073 .separatorIndex = length(.currentLine$)+1
1075 .currentItem$ = left$(.currentLine$, .separatorIndex-1)
1076 .currentLine$ = right$(.currentLine$, length(.currentLine$) - .separatorIndex )
1077 if index_regex(.currentItem$, ".(spx|flac|wav|mp3)")
1079 .currentFile$ = .currentItem$
1080 elsif index_regex(.currentItem$, "[a-zA-Z0-9]") > 0
1082 .currentTrans$ = .currentItem$
1083 elsif index_regex(.currentItem$, "[^ \t\r\l]") > 0 && index_regex(.currentItem$, "[a-zA-Z0-9\-]") <= 0
1085 .currentChar$ = .currentItem$
1089 if .currentFile$ = "-"
1090 if fileReadable("'.dirString$'/'.currentPinyin$'.spx")
1091 .currentFile$ = .currentPinyin$+".spx"
1092 elsif fileReadable("'.dirString$'/'.currentPinyin$'.flac")
1093 .currentFile$ = .currentPinyin$+".flac"
1094 elsif fileReadable("'.dirString$'/'.currentPinyin$'.wav")
1095 .currentFile$ = .currentPinyin$+".wav"
1096 elsif fileReadable("'.dirString$'/'.currentPinyin$'.mp3")
1097 .currentFile$ = .currentPinyin$+".mp3"
1100 select Table 'wordlist$'
1102 Set string value... '.i' Pinyin '.currentPinyin$'
1103 Set string value... '.i' Sound '.currentFile$'
1104 Set string value... '.i' Character '.currentChar$'
1105 Set string value... '.i' Translation '.currentTrans$'
1107 select Strings RawWordList
1110 select Table 'wordlist$'
1111 elsif fileReadable(.dirString$) or fileReadable("'.dirString$'/directory.txt")
1112 Create Table with column names... "'wordlistName$'" 0 Pinyin Sound
1113 wordlist$ = selected$("Table")
1114 Create Strings as file list... RawWordList '.dirString$'/*
1115 .numWordStrings = Get number of strings
1117 for .j to .numWordStrings
1118 select Strings RawWordList
1119 .currentLine$ = Get string... '.j'
1120 .currentFile$ = extractWord$(.currentLine$, "")
1121 if index_regex(.currentFile$, "\.(spx|flac|wav|mp3)")
1122 .currentPinyin$ = left$(.currentFile$, index(.currentFile$, ".")-1)
1123 select Table 'wordlist$'
1126 Set string value... '.i' Pinyin '.currentPinyin$'
1127 Set string value... '.i' Sound '.currentFile$'
1130 select Strings RawWordList
1133 select Table 'wordlist$'
1134 elsif startsWith(.dirString$, "*call ")
1135 .callProcedure$ = right$(.dirString$, length(.dirString$)-1)
1137 wordlist$ = selected$("Table")
1144 # Can this wordlist be deleted?
1145 if fileReadable("'sgc2wordlists$'/'wordlistName$'") or fileReadable("'sgc2wordlists$'/'wordlistName$'/wordlist.txt") or fileReadable("'sgc2wordlists$'/'wordlistName$'/wordlist.Table")
1146 config.deleteWordlist = 0
1148 config.deleteWordlist = -1
1151 # Check first column name and add Character, Translation and Show columns if missing
1153 select Table 'wordlist$'
1154 # HAck to correct odd behavior of tables with unicode characters
1155 .firstColumn$ = Get column label: 1
1156 if index_regex(.firstColumn$, "^[^!-~]") > 0
1157 .firstColumn$ = replace_regex$(.firstColumn$, "^[^!-~]", "", 0)
1158 Set column label (index): 1, .firstColumn$
1161 te.numberOfWords = Get number of rows
1162 .characterColumn = Get column index... Character
1163 if not .characterColumn
1164 Append column... Character
1165 for .i to te.numberOfWords
1166 Set string value... '.i' Character -
1169 .translationColumn = Get column index... Translation
1170 if not .translationColumn
1171 Append column... Translation
1172 for .i to te.numberOfWords
1173 Set string value... '.i' Translation -
1176 .showColumn = Get column index... Show
1178 Append column... Show
1179 for .i to te.numberOfWords
1180 Set string value... '.i' Show +
1185 # Remove all rows without Pinyin
1186 .numRows = Get number of rows
1188 .rowNum = .numRows - i + 1
1189 .pinyinValue$ = Get value... '.rowNum' Pinyin
1190 if not index_regex(.pinyinValue$, "[a-zA-Z0-9]")
1191 Remove row... '.rowNum'
1194 te.numberOfWords = Get number of rows
1196 # Shuffle words if requested
1197 if config.shuffleLists
1203 select Table AllWordLists
1206 # There were no Word Lists
1209 wordlistName$ = wordlistName$+" No Word Lists available"
1211 Create Table with column names... "'wordlistName$'" 0 Pinyin Character Translation Sound
1212 wordlist$ = selected$("Table")
1216 Set string value... '.i' Pinyin ni3hao3
1217 Set string value... '.i' Character 你好
1218 Set string value... '.i' Translation hello
1219 Set string value... '.i' Sound -
1222 Set string value... '.i' Pinyin xie4xie0
1223 Set string value... '.i' Character 谢谢
1224 Set string value... '.i' Translation thanks
1225 Set string value... '.i' Sound -
1228 Set string value... '.i' Pinyin zai4jian4
1229 Set string value... '.i' Character 再见
1230 Set string value... '.i' Translation goodbye
1231 Set string value... '.i' Sound -
1232 te.numberOfWords = Get number of rows
1235 call set_window_title 'buttons$' 'wordlistName$'
1240 select Table 'wordlist$'
1242 if te.currentWord < 0 or te.currentWord > te.numberOfWords
1243 if config.shuffleLists
1248 while .showCurrent$ = "-" and te.currentWord <= te.numberOfWords
1250 if te.currentWord <= te.numberOfWords
1251 .showCurrent$ = Get value... 'te.currentWord' Show
1257 procedure previous_word
1259 select Table 'wordlist$'
1261 if te.currentWord <= 0
1262 if config.shuffleLists
1265 te.currentWord = te.numberOfWords + 1
1267 while .showCurrent$ = "-" and te.currentWord > 0
1269 if te.currentWord > 0
1270 .showCurrent$ = Get value... 'te.currentWord' Show
1276 procedure display_word_list_name
1280 .displayWordList$ = replace_regex$(wordlistName$, "[_]", " ", 0)
1281 call wipeArea 'wipeWordlistArea$'
1282 call adjustFontSizeOnHeight 'defaultFont$' 'defaultFontSize' 5
1283 .currentFontSize = adjustFontSizeOnHeight.newFontSize
1286 demo Text special... '.xtext' Centre '.ytext' Bottom 'defaultFont$' '.currentFontSize' 0 '.displayWordList$'
1289 call set_font_size 'defaultFontSize'
1292 procedure write_word_list
1293 # Write current Pinyin text
1294 call display_text Black
1296 # Write the current word list name
1297 call display_word_list_name
1300 procedure paint_saveAudio_light
1301 select Table 'config$'
1302 .row = Search column... Label SaveAudio
1304 exit Button Table Config does not have a row with label SaveAudio
1307 .leftX = Get value... '.row' LeftX
1308 .rightX = Get value... '.row' RightX
1309 .lowY = Get value... '.row' LowY
1310 .highY = Get value... '.row' HighY
1311 .buttonColor$ = Get value... '.row' Color
1312 # The button text and symbol
1313 .horWC = demo Horizontal mm to wc... 10.0
1314 .verWC = demo Vertical mm to wc... 10.0
1316 .verCoeff = .horWC / .verWC
1321 .centerX = (.leftX + .rightX)/2
1322 .centerY = .lowY + 0.6*(.highY-.lowY)
1323 .radius = min(.verCoeff * (.highY - .lowY ), (.rightX - .leftX))/3
1324 .wipeRadius = 1.1*.radius
1325 call DrawSaveAudio White '.centerX' '.centerY' '.wipeRadius'
1327 if sgc.saveAudioOn and sgc.saveAudio$ <> ""
1328 call DrawSaveAudio "DarkBlue" '.centerX' '.centerY' '.radius'
1333 # Uninstall word lists
1334 procedure removeWordlist .deletedWordlistName$
1336 if fileReadable("'sgc2wordlists$'/'.deletedWordlistName$'") or fileReadable("'sgc2wordlists$'/'.deletedWordlistName$'/wordlist.txt") or fileReadable("'sgc2wordlists$'/'.deletedWordlistName$'/wordlist.Table")
1337 .targetDir$ = "'sgc2wordlists$'/'.deletedWordlistName$'"
1339 if .targetDir$ <> ""
1340 Create Strings as file list... DeleteList '.targetDir$'
1341 .numdeleteFiles = Get number of strings
1342 for .i to .numdeleteFiles
1343 .file$ = Get string... '.i'
1344 deleteFile("'.targetDir$'/'.file$'")
1346 filedelete '.targetDir$'
1347 # Check whether the directory was actually deleted. Make sure this is a valid directory name!
1348 # That is, it does not contain funny characters, nor funny names
1349 if index_regex(.deletedWordlistName$, "[^a-zA-Z0-9_ .\-]") <= 0 and index(.deletedWordlistName$, "..") <= 0 and index_regex(.deletedWordlistName$, "[a-zA-Z]") > 0
1351 nocheck system rmdir "'.targetDir$'" /s /q
1352 elsif fileReadable(.targetDir$)
1353 system bash -rc -- 'rm -r -- "'.targetDir$'"'
1356 # Remove deleted word list
1357 select Strings DeleteList
1358 plus Table 'wordlist$'
1364 # Install word lists
1365 procedure sgc2wordlist .sourceDir$
1366 if startsWith(.sourceDir$, "preferencesDirectory$")
1367 .sourceDir$ = replace$(.sourceDir$, "preferencesDirectory$", preferencesDirectory$)
1370 .targetDirectory$ = "'sgc2wordlists$'"
1371 if fileReadable(.sourceDir$) or fileReadable("'.sourceDir$'/directory.txt")
1372 Create Strings as file list... PackageList '.sourceDir$'/*.sgc
1373 .numFiles = Get number of strings
1375 select Strings PackageList
1376 .file$ = Get string... '.i'
1377 call readWordlist '.sourceDir$' '.file$'
1380 select Strings PackageList
1385 # Debuggin remarks!!!
1386 # fileReadable(<directory>) does not work in Windows
1387 # The file paths / -> \\ must be performed on the filenames in Windows before the system_nocheck is given
1388 # And yet only the 7z decompression has been implemented
1389 windowsUnzipCommand$ = ""
1390 if fileReadable("C:\Program Files\7-Zip\7z.exe")
1391 windowsUnzipCommand$ = """C:\Program Files\7-Zip\7z.exe"" e"
1392 windowsUnzipDestDir$ = " -o"
1393 elsif fileReadable("C:\Program Files\WinZip\winzip32.exe")
1394 # !!! Find a way to include the output folder !!!
1395 windowsUnzipCommand$ = "C:\Program Files\WinZip\winzip32.exe"" -min -e "
1396 windowsUnzipDestDir$ = ""
1398 procedure readWordlist .sourceDir$ .file$
1399 # No use doing anything if the source does not exist
1400 if fileReadable("'.sourceDir$'/'.file$'") or fileReadable("'.sourceDir$'/'.file$'/wordlist.txt") or fileReadable("'.sourceDir$'/'.file$'/wordlist.Table")
1401 # What will be the target wordlist directory?
1402 .targetDirectory$ = "'sgc2wordlists$'"
1403 .dirname$ = left$(.file$, rindex(.file$, ".")-1)
1407 .wordlistDirectory$ = .targetDirectory$+"/"+.dirname$
1408 # Wordlist directory does not exist, neither locally nor in the preferences
1410 .tmpDirs = nocheck Create Strings as directory list... TMPWORDLISTS '.targetDirectory$'/
1411 if .tmpDirs != undefined and .tmpDirs > 0
1412 .numDirs = Get number of strings
1415 .currentString$ = Get string... '.d'
1416 if .currentString$ = .dirname$
1422 if not (.wordListExists or fileReadable(.dirname$) or fileReadable("'.dirname$'/directory.txt") or fileReadable(.wordlistDirectory$) or fileReadable("'.wordlistDirectory$'/directory.txt"))
1424 # Move source to destination
1425 if index(.file$, ".sgc") or index(.file$, ".zip")
1426 if index_regex(.wordlistDirectory$, "[^a-zA-Z0-9_\.\- /~\:]") <= 0 and index_regex(.dirname$, "[^a-zA-Z0-9_\.\- ]") <= 0 and not (windows and windowsUnzipCommand$ = "")
1427 # Create wordlist directory
1428 createDirectory(.wordlistDirectory$)
1430 if macintosh or unix
1431 system cd ''.wordlistDirectory$'';bash -rc -- 'unzip "'.file$'"' -d ''.wordlistDirectory$''
1432 elsif windows and windowsUnzipCommand$ <> ""
1433 .winWordListDirectory$ = replace_regex$(.wordlistDirectory$, "/", "\\", 0)
1434 .winSourceDirectory$ = replace_regex$("'.sourceDir$'\'.file$'", "/", "\\", 0)
1435 system mkdir "'.winWordListDirectory$'" & 'windowsUnzipCommand$' "'.winSourceDirectory$'" 'windowsUnzipDestDir$'"'.winWordListDirectory$'"
1438 # Remove if not valid!
1439 if fileReadable("'.wordlistDirectory$'/wordlist.Table") or fileReadable("'.wordlistDirectory$'/wordlist.txt") or fileReadable("'.wordlistDirectory$'/LICENSE.txt")
1440 if fileReadable("'.wordlistDirectory$'/wordlist.Table")
1441 call readTable '.sourceDir$'/'.file$'
1442 if readTable.tableID > 0
1443 select readTable.tableID
1444 # Hack around odd behavior of column index
1446 .firstColumn$ = Get column label: 1
1447 .firstColumn$ = replace_regex$(.firstColumn$, "^[^!-~]", "", 0)
1448 if .firstColumn$ = "Pinyin"
1451 .pinyinCol = Get column index... Pinyin
1454 # No Pinyin in table
1463 # None of wordlist.Table, wordlist.txt, nor LICENSE.txt
1466 ### REALLY DANGEROUS STUFF, SHOULD BE HANDLED BETTER
1468 # Remove newly created directory
1469 if index_regex(.wordlistDirectory$, "[^a-zA-Z0-9_\.\- /~\:]") <= 0 and index_regex(.dirname$, "[^a-zA-Z0-9_\.\- ]") <= 0 and index(.dirname$, "..") <= 0
1470 if macintosh or unix
1471 system bash -rc -- 'rm -r "'.wordlistDirectory$'/"'
1473 system rmdir /Q /S "'.winWordListDirectory$'/"
1477 elsif index_regex(.file$, "\.(Table|txt|tsv)")
1478 # Check whether this is a valid table
1479 call readTable '.sourceDir$'/'.file$'
1480 if readTable.tableID > 0
1481 select readTable.tableID
1482 # Hack around odd behavior of column index
1484 .firstColumn$ = Get column label: 1
1485 .firstColumn$ = replace_regex$(.firstColumn$, "^[^!-~]", "", 0)
1486 if .firstColumn$ = "Pinyin"
1489 .pinyinCol = Get column index... Pinyin
1494 # Create wordlist directory
1495 createDirectory(.wordlistDirectory$)
1497 .extension$ = replace_regex$(.file$, "^.+\.(Table|txt|tsv)$", "\1", 0)
1498 if .extension$ = "tsv"
1499 .extension$ = "Table"
1501 if macintosh or unix
1502 system bash -rc -- 'cp "'.sourceDir$'/'.file$'" "'.wordlistDirectory$'/wordlist.'.extension$'"'
1504 .winWordListDirectory$ = replace_regex$(.wordlistDirectory$, "/", "\\", 0)
1505 .winSourceDirectory$ = replace_regex$("'.sourceDir$'\'.file$'", "/", "\\", 0)
1506 system copy "'.winSourceDirectory$'" "'.winWordListDirectory$'\wordlist.'.extension$'" /q
1510 elsif fileReadable("'.sourceDir$'/'.file$'/wordlist.Table") or fileReadable("'.sourceDir$'/'.file$'/wordlist.txt") or fileReadable("'.sourceDir$'/'.file$'/LICENSE.txt")
1511 # Copy wordlist directory
1512 if index_regex(.file$, "[^a-zA-Z0-9_\.\- ]") <= 0
1514 if macintosh or unix
1515 system bash -rc -- 'cp -r "'.sourceDir$'/'.file$'" "'.wordlistDirectory$'"'
1517 createDirectory(.wordlistDirectory$)
1518 .winWordListDirectory$ = replace_regex$(.wordlistDirectory$, "/", "\\", 0)
1519 .winSourceDirectory$ = replace_regex$("'.sourceDir$'\'.file$'", "/", "\\", 0)
1520 system xcopy "'.winSourceDirectory$'" "'.winWordListDirectory$'" /s /e /q
1525 # Set current word list to read list
1527 wordlistName$ = .dirname$
1530 .label$ = "!NotAWordlist"
1533 call findLabel '.table$' '.label$'
1534 .row = findLabel.row
1535 select Table '.table$'
1536 .helpText$ = Get value... '.row' Helptext
1537 .filetext$ = replace_regex$("'.sourceDir$'/'.file$'", "_", "\\_ ", 0)
1538 call write_text_popup 'defaultFont$' 14 '.helpText$' "'.filetext$'"
1539 # Wait for confirmation