6 # SpeakGoodChinese: sgc2.praat is the master GUI of SpeakGoodChinese
7 # It is written in Praat script for the Demo window
9 # Copyright (C) 2007-2010 R.J.J.H. van Son
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
28 include ToneProt/ToneRecognition.praat
30 demo Select outer viewport... 0 100 0 100
31 demo Axes... 0 100 0 100
33 # Initialize parameters
43 wordlistDir$ = "wordlists"
52 logDir$ = "'preferencesDirectory$'/log"
53 sgc2wordlists$ = "'preferencesDirectory$'/sgc2/wordlists"
56 defaultFont$ = "Helvetica"
59 call set_up_directories
60 call read_preferences ""
63 call set_language 'language$'
65 call load_word_list "'wordlistDir$'" "'preferencesDirectory$'/sgc2/wordlists" 0
69 while demoWaitForInput()
74 call buttonClicked 'buttons$' '.clickX' '.clickY'
75 .label$ = buttonClicked.label$
76 elsif demoKeyPressed()
77 .pressed$ = demoKey$()
78 call keyPressed 'buttons$' '.pressed$'
79 .label$ = keyPressed.label$
85 call Draw_button 'buttons$' '.label$' 1
86 call process_label '.label$'
88 call Draw_button 'buttons$' '.label$' 0
95 ########################################################
97 # Definitions of procedures
99 ########################################################
102 procedure process_label .label$
105 elsif .label$ = "Config"
107 elsif .label$ = "Refresh"
109 elsif .label$ = "Record"
112 call write_feedback Feedback
113 elsif .label$ = "Play"
114 call play_sound 'sampleSound$'
115 elsif .label$ = "Example"
116 call generate_example
117 elsif .label$ = "Previous"
118 call display_text Grey
120 call display_text Black
122 call draw_tone_contour
123 elsif .label$ = "Next"
124 call display_text Grey
126 call display_text Black
128 call draw_tone_contour
129 elsif .label$ = "Wordlist"
130 call load_word_list "'wordlistDir$'" "'preferencesDirectory$'/sgc2/wordlists" 1
137 # Initialize Demo Window
138 procedure init_window
140 demoWindowTitle("Speak Good Chinese: Practice your tones")
141 demo Line width... 'defaultLineWidth'
143 demo 'defaultFontSize'
145 demo Select outer viewport... 0 100 0 100
146 demo Axes... 0 100 0 100
147 # Define buttons in a table
149 # Display the word-list
154 procedure init_buttons
155 call Draw_all_buttons 'buttons$'
159 procedure Draw_all_buttons .table$
160 select Table '.table$'
161 .numRows = Get number of rows
164 .label$ = Get value... '.row' Label
165 call Draw_button '.table$' '.label$' 0
169 # Draw a button from a predefined button table
170 procedure Draw_button .table$ .label$ .push
171 select Table '.table$'
172 .row = Search column... Label '.label$'
174 exit Button Table '.table$' does not have a row with label '.label$'
176 .buttonBackGround$ = "{0.97,0.97,0.97}"
177 .buttonShift$ = "Black"
179 .leftX = Get value... '.row' LeftX
180 .rightX = Get value... '.row' RightX
181 .lowY = Get value... '.row' LowY
182 .highY = Get value... '.row' HighY
183 # Reset and erase button area
184 demo Select outer viewport... 0 100 0 100
185 demo Axes... 0 100 0 100
186 demo Line width... 'defaultLineWidth'
187 demo Paint rectangle... White .leftX .rightX .lowY .highY
189 # Give some depth to button: Draw outline
192 .shiftLeftX = .leftX + .shiftX
193 .shiftRightX = .rightX + .shiftX
194 .shiftLowY = .lowY + .shiftY
195 .shiftHighY = .highY + .shiftY
197 demo Draw rounded rectangle... .shiftLeftX .shiftRightX .shiftLowY .shiftHighY 3
199 .buttonText$ = Get value... '.row' Text
200 .buttonColor$ = Get value... '.row' Color
201 .buttonDraw$ = Get value... '.row' Draw
202 .buttonKey$ = Get value... '.row' Key
203 .newText$ = replace_regex$(.buttonText$, "['.buttonKey$']", "#%&", 1)
205 .newText$ = .buttonText$
208 .buttonBackGround$ = "{0.92,0.92,0.92}"
209 .buttonShift$ = "{0.98,0.98,0.98}"
213 if .buttonColor$ = "Red"
214 .buttonColor$ = "Pink"
216 .buttonColor$ = "Grey"
219 .buttonColor$ = "Maroon"
224 # Give some depth to button
225 demo Paint rounded rectangle... '.buttonShift$' .shiftLeftX .shiftRightX .shiftLowY .shiftHighY 3
226 demo Paint rounded rectangle... '.buttonBackGround$' .leftX .rightX .lowY .highY 3
229 demo Draw rounded rectangle... .leftX .rightX .lowY .highY 3
230 .centerX = (.leftX + .rightX)/2
231 .centerY = (.lowY + .highY)/2
232 .radius = (.highY - .lowY )/4
234 demo Text... '.centerX' Centre '.lowY' Bottom '.newText$'
236 call '.buttonDraw$' '.buttonColor$' '.centerX' '.centerY' '.radius'
242 procedure display_text .color$
243 select Table 'wordlist$'
244 if currentWord < 0 or currentWord > numberOfWords+1
249 currentWord = numberOfWords
255 if currentWord > 0 and currentWord <= numberOfWords
257 .displayPinyin$ = Get value... 'currentWord' Pinyin
258 .displayChar$ = Get value... 'currentWord' Character
259 if .displayPinyin$ <> "-" and displayPinyin
260 .displayText$ = .displayText$ + .displayPinyin$
262 if .displayChar$ <> "-" and displayChar
263 .displayText$ = .displayText$ + " "+ .displayChar$
265 elsif currentWord = 0 or currentWord = numberOfWords+1
266 .displayText$ = "---"
268 demo Paint rectangle... White 20 80 25 40
269 demo Paint rectangle... White 10 90 19 30
272 demo Text... 50 Centre 25 Bottom '.displayText$'
275 demo 'defaultFontSize'
280 procedure generate_example
281 select Table 'wordlist$'
282 if currentWord > 0 and currentWord <= numberOfWords
283 select Table 'wordlist$'
284 .sound$ = Get value... 'currentWord' Sound
285 .pinyin$ = Get value... 'currentWord' Pinyin
286 .soundFilePath$ = wordlistDir$+"/"+wordlistName$+"/"+.sound$
287 if fileReadable("'sgc2wordlists$'/'wordlistName$'/'.sound$'")
288 .soundFilePath$ = "'sgc2wordlists$'/'wordlistName$'/'.sound$'"
290 if fileReadable(.soundFilePath$) and useSoundExample
291 Read from file... '.soundFilePath$'
295 execute "ToneProt/HumToneContour.praat" '.pinyin$' 'register'
302 ###############################################################
304 # Button Drawing Routines
306 ###############################################################
308 # A stub for buttons that do not have a drawing routine (yet)
309 procedure DrawNull .color$ .x .y .size
312 procedure DrawRecord .color$ .x .y .size
314 demo Paint circle... '.color$' '.x' '.y' '.size'
317 procedure DrawPlay .color$ .x .y .size
319 call drawTriangle 1 .x .y .size
322 procedure DrawPrevious .color$ .x .y .size
325 call drawTriangle -1 .x .y .size
326 .currentX = drawTriangle.currentX
327 .endX = .currentX - 0.5
330 demo Paint rectangle... '.color$' '.currentX' '.endX' '.lowY' '.highY'
333 procedure DrawNext .color$ .x .y .size
336 call drawTriangle 1 .x .y .size
337 .currentX = drawTriangle.currentX
338 .endX = .currentX + 0.5
341 demo Paint rectangle... '.color$' '.currentX' '.endX' '.lowY' '.highY'
344 procedure DrawQuit .color$ .x .y .size
345 demo Line width... 4.0
350 demo Draw line... .xstart .ystart .xend .yend
355 demo Draw line... .xstart .ystart .xend .yend
356 demo Line width... 'defaultLineWidth'
359 procedure DrawConfig .color$ .x .y .size
361 demo Line width... 3.0
364 demo Draw arrow... .xstart .y .xend .y
365 demo Line width... 'defaultLineWidth'
368 procedure DrawRefresh .color$ .x .y .size
370 demo Line width... 4.0
371 demo Draw arc... '.x' '.y' '.size' 0 270
372 demo Line width... 'defaultLineWidth'
375 procedure DrawWordList .color$ .x .y .size
379 .xmidright = .x - 0.1
384 demo Draw line... .xleft .yhigh .xmidleft .y
385 demo Draw line... .xright .yhigh .xmidright .y
386 demo Line width... 'defaultLineWidth'
390 procedure drawTriangle .direction .x .y .size
391 # Make sure direction = +/- 1
395 .direction /= abs(.direction)
398 .currentHeight = .size
399 .currentX = .x - .direction*.size
401 demo Line width... 2.0
403 while .currentHeight> 0
404 .ystart = .y + .currentHeight
405 .yend = .y - .currentHeight
406 demo Draw line... .currentX .ystart .currentX .yend
407 .currentHeight -= .offset *3/4
408 .currentX += .direction*.offset * 1.5
410 demo Line width... 'defaultLineWidth'
413 ###############################################################
415 # Button Processing Routines
417 ###############################################################
419 # Search row in table on label
420 procedure findLabel .table$ .label$
422 select Table '.table$'
423 .to$ = selected$("Table")
425 .numRows = Get number of rows
427 .currentKey$ = '.to$'$[.i, "Key"]
428 if .label$ = .currentKey$
437 procedure buttonClicked table$ .x .y
439 select Table 'table$'
440 .bo$ = selected$("Table")
442 .numRows = Get number of rows
445 .leftX = '.bo$'[.i, "LeftX"]
446 .rightX = '.bo$'[.i, "RightX"]
447 .lowY = '.bo$'[.i, "LowY"]
448 .highY = '.bo$'[.i, "HighY"]
449 if .x > .leftX and .x < .rightX and .y > .lowY and .y < .highY
450 .label$ = '.bo$'$[.i, "Label"]
456 procedure keyPressed table$ .pressed$
458 .lowerPressed$ = replace_regex$(.pressed$, ".", "\L&", 0)
459 .upperPressed$ = replace_regex$(.pressed$, ".", "\U&", 0)
460 select Table 'table$'
461 .bo$ = selected$("Table")
463 .numRows = Get number of rows
466 .key$ = '.bo$'$[.i, "Key"]
467 if .key$ = .lowerPressed$ or .key$ = .upperPressed$
468 .label$ = '.bo$'$[.i, "Label"]
474 procedure record_sound
475 if sampleSound$ != ""
476 select Sound 'sampleSound$'
481 demo Paint rectangle... White 10 90 15 25
482 demo Paint circle... Red 5 85 2.5
484 nowarn Record Sound (fixed time)... Microphone 0.99 1 44100 4
485 demo Paint circle... White 5 85 3
490 sampleSound$ = selected$("Sound")
493 select Sound 'sampleSound$'
496 # Draw a tone contour
497 procedure draw_tone_contour
499 demo Select inner viewport... 0 100 0 100
500 demo Paint rectangle... White 20 80 40 100
501 demo Select outer viewport... 0 100 0 100
502 demo Paint rectangle... White 20 80 40 100
503 demo Paint rectangle... White 0 100 16 26
504 select Table 'wordlist$'
505 if currentWord > 0 and currentWord <= numberOfWords
506 .sound$ = Get value... 'currentWord' Sound
507 .pinyin$ = Get value... 'currentWord' Pinyin
508 execute "ToneProt/DrawToneContour.praat" '.pinyin$' 'register'
512 procedure recognizeTone
513 select Table 'wordlist$'
514 if currentWord > 0 and currentWord <= numberOfWords
515 .sound$ = Get value... 'currentWord' Sound
516 .pinyin$ = Get value... 'currentWord' Pinyin
517 execute "ToneProt/SGC_ToneProt.praat" 'sampleSound$' '.pinyin$' 'register' 'precision' Pictures 'language$'
521 procedure write_feedback .table$
522 select Table '.table$'
523 .line1$ = Get value... 1 Text
524 .line2$ = Get value... 2 Text
525 .label$ = Get value... 3 Text
528 if index(.line1$, "???") > 0
530 elsif .label$ = "Correct"
536 demo Paint rectangle... White 0 100 16 26
537 demo Text... 50 Centre 21 Bottom '.line1$'
538 demo Text... 50 Centre 17 Bottom '.line2$'
540 demo 'defaultFontSize'
544 .splitIndex = index(.line1$, ": ")
545 .pinyin$ = left$(.line1$, (.splitIndex - 1))
546 .choice$ = right$(.line1$, (length(.line1$) - .splitIndex - 1))
547 call log_performance 'sampleSound$' 'register' 'precision' '.pinyin$' '.choice$'
550 procedure play_sound .sound$
552 select Sound '.sound$'
557 procedure end_program
558 call write_preferences ""
565 ######################################################
569 ######################################################
570 procedure config_page
572 demoWindowTitle("Speak Good Chinese: Change settings")
574 call Draw_config_page
576 while (.label$ <> "Return") and demoWaitForInput()
581 call buttonClicked 'config$' '.clickX' '.clickY'
582 .label$ = buttonClicked.label$
583 elsif demoKeyPressed()
584 .pressed$ = demoKey$()
585 call keyPressed 'config$' '.pressed$'
586 .label$ = keyPressed.label$
591 # Handle push button in process_config
592 call process_config '.label$'
595 if .label$ = "Return"
605 procedure Draw_config_page
606 call Draw_all_buttons 'config$'
607 # Set correct buttons (alert)
608 call Draw_button 'config$' Lang'language$' 2
609 call Draw_button 'config$' Register_'register' 2
611 call Draw_button 'config$' DisplayPinyin 2
614 call Draw_button 'config$' DisplayChar 2
617 call Draw_button 'config$' Shuffle 2
620 call Draw_button 'config$' SndExample 2
625 procedure DrawReturn .color$ .x .y .size
628 demo Line width... 4.0
629 demo Draw arrow... '.xleft' '.y' '.xright' '.y'
630 demo Line width... 'defaultLineWidth'
636 procedure process_config .label$
637 if .label$ = "Return"
638 call Draw_button 'config$' '.label$' 1
639 call write_preferences ""
640 elsif .label$ = "Shuffle"
641 shuffleLists = not shuffleLists
642 .displayButton = 2*shuffleLists
643 call Draw_button 'config$' '.label$' '.displayButton'
644 elsif .label$ = "SndExample"
645 useSoundExample = not useSoundExample
646 .displayButton = 2*useSoundExample
647 call Draw_button 'config$' '.label$' '.displayButton'
648 elsif startsWith(.label$, "Lang")
649 call Draw_button 'config$' Lang'language$' 0
650 call Draw_button 'config$' '.label$' 2
651 # Someone might have to use more than 2 chars for the language code
652 .numChars = length(.label$) - length("Lang")
653 .lang$ = right$(.label$, .numChars)
655 call set_language '.lang$'
656 elsif startsWith(.label$, "Register_")
657 call Draw_button 'config$' Register_'register' 0
658 call Draw_button 'config$' '.label$' 2
659 # Someone might have to use more than 3 chars for the register code
660 .numChars = length(.label$) - length("Register_")
661 .registerText$ = right$(.label$, .numChars)
662 register = '.registerText$'
663 elsif startsWith(.label$, "Display")
665 if .label$ = "DisplayPinyin"
666 displayPinyin = not displayPinyin
667 .displayButton = 2*displayPinyin
669 if .label$ = "DisplayChar"
670 displayChar = not displayChar
671 .displayButton = 2*displayChar
673 call Draw_button 'config$' '.label$' '.displayButton'
677 procedure set_language .lang$
681 select Table 'buttons$'
686 select Table 'config$'
694 # Load buttons tables
695 Read from file... Data/Buttons.Table
696 buttons$ = selected$("Table")
697 Append column... Text
699 .numLabels = Get number of rows
700 Read from file... Data/Buttons_'language$'.Table
701 .buttonsLang$ = selected$("Table")
702 for .row to .numLabels
703 select Table '.buttonsLang$'
704 .valueText$ = Get value... '.row' Text
705 .valueKey$ = Get value... '.row' Key
706 select Table 'buttons$'
707 Set string value... '.row' Text '.valueText$'
708 Set string value... '.row' Key '.valueKey$'
710 select Table '.buttonsLang$'
713 # Load configuration table
714 Read from file... Data/Config.Table
715 config$ = selected$("Table")
716 Append column... Text
718 .numLabels = Get number of rows
719 Read from file... Data/Config_'language$'.Table
720 .configLang$ = selected$("Table")
721 for .row to .numLabels
722 select Table '.configLang$'
723 .valueText$ = Get value... '.row' Text
724 .valueKey$ = Get value... '.row' Key
725 select Table 'config$'
726 Set string value... '.row' Text '.valueText$'
727 Set string value... '.row' Key '.valueKey$'
729 select Table '.configLang$'
732 # Make language change visible
734 call Draw_config_page
739 procedure load_word_list .dir1$ .dir2$ .relnumber
740 # Remove old word list
742 select Table 'wordlist$'
746 Create Strings as directory list... WordList1 '.dir1$'
748 .numLists = Get number of strings
750 select Strings WordList1
751 .currentName$ = Get string... '.i'
752 .currentName$ = .dir1$+"/"+.currentName$
753 select Strings DirWordList1
754 Set string... '.i' '.currentName$'
757 Create Strings as directory list... WordList2 '.dir2$'
758 .numLists = Get number of strings
762 select Strings WordList2
763 .currentName$ = Get string... '.i'
764 .currentName$ = .dir2$+"/"+.currentName$
765 select Strings DirWordList2
766 Set string... '.i' '.currentName$'
769 select Strings WordList1
770 plus Strings WordList2
773 select Strings WordList1
774 plus Strings WordList2
777 select Strings DirWordList1
778 plus Strings DirWordList2
780 Rename... DirWordList
781 select Strings DirWordList1
782 plus Strings DirWordList2
785 select Strings WordList2
787 select Strings WordList1
789 select Strings DirWordList1
790 Rename... DirWordList
793 # Get the position of the current word list
794 select Strings WordList
796 .numLists = Get number of strings
797 if wordlistName$ <> ""
799 select Strings WordList
800 .currentName$ = Get string... '.i'
801 if .currentName$ = wordlistName$
806 wordlistNum = .currentNumber + .relnumber
807 if wordlistNum > .numLists
810 select Strings WordList
811 wordlistName$ = Get string... 'wordlistNum'
812 select Strings DirWordList
813 .dirWordlistName$ = Get string... 'wordlistNum'
814 .dirString$ = replace_regex$(.dirWordlistName$, "[ ]", "&", 0)
816 # Read in full tables
817 if fileReadable("'.dirString$'/wordlist.Table")
818 Read from file... '.dirString$'/wordlist.Table
819 Rename... 'wordlistName$'
820 # Praat wil change the name if it feels like it
821 wordlist$ = selected$("Table")
822 # Handle (legacy) simple word lists
823 elsif fileReadable("'.dirString$'/wordlist.txt")
824 Create Table with column names... 'wordlistName$' 0 Pinyin Character Sound
825 wordlist$ = selected$("Table")
826 Read Strings from raw text file... '.dirString$'/wordlist.txt
827 Rename... RawWordList
828 .numWordStrings = Get number of strings
829 for .i to .numWordStrings
830 select Strings RawWordList
831 .currentLine$ = Get string... '.i'
832 .currentPinyin$ = extractWord$(.currentLine$, "")
833 if length(.currentLine$) > length(.currentPinyin$)+1
834 .currentFile$ = right$(.currentLine$, length(.currentPinyin$)+1)
835 elsif fileReadable("'.dirString$'/'.currentPinyin$'.spx")
836 .currentFile$ = .currentPinyin$+".spx"
837 elsif fileReadable("'.dirString$'/'.currentPinyin$'.flac")
838 .currentFile$ = .currentPinyin$+".flac"
839 elsif fileReadable("'.dirString$'/'.currentPinyin$'.wav")
840 .currentFile$ = .currentPinyin$+".wav"
841 elsif fileReadable("'.dirString$'/'.currentPinyin$'.mp3")
842 .currentFile$ = .currentPinyin$+".mp3"
846 select Table 'wordlist$'
848 Set string value... '.i' Pinyin '.currentPinyin$'
849 Set string value... '.i' Character -
850 Set string value... '.i' Sound '.currentFile$'
852 select Strings RawWordList
855 select Table 'wordlistName$'
857 Create Table with column names... 'wordlistName$' 0 Pinyin Character Sound
858 wordlist$ = selected$("Table")
859 Create Strings as file list... RawWordList '.dirString$'/*
860 .numWordStrings = Get number of strings
862 for .j to .numWordStrings
863 select Strings RawWordList
864 .currentLine$ = Get string... '.j'
865 .currentFile$ = extractWord$(.currentLine$, "")
866 if index_regex(.currentFile$, "\.(spx|flac|wav|mp3)")
867 .currentPinyin$ = left$(.currentFile$, index(.currentFile$, ".")-1)
868 select Table 'wordlist$'
871 Set string value... '.i' Pinyin '.currentPinyin$'
872 Set string value... '.i' Character -
873 Set string value... '.i' Sound '.currentFile$'
876 select Strings RawWordList
879 select Table 'wordlistName$'
881 numberOfWords = Get number of rows
887 select Strings WordList
888 plus Strings DirWordList
892 procedure write_word_list
895 .ytextTop = .ytext + 5
896 .displayWordList$ = replace_regex$(wordlistName$, "[_]", " ", 0)
898 demo Paint rectangle... White 20 80 '.ytext' '.ytextTop'
900 demo Text... '.xtext' Centre '.ytext' Bottom '.displayWordList$'
904 # Write current Pinyin text
905 call display_text Black
908 call draw_tone_contour
912 procedure log_performance .sampleSound$ .register .precision .pinyin$ .choice$
913 if not logPerformance
914 logPerformance = fileReadable(logDir$+"/logPerformance.txt")
917 .currentDate$ = date$()
918 .timeStamp$ = replace_regex$(.currentDate$, "[^a-zA-Z0-9\-_]", "-", 0)
919 .choiceText$ = replace_regex$(.choice$, "[^a-zA-Z0-9\-_]", "-", 0)
922 .outfilename$ = .pinyin$+"_"+.choice$+"_'.register'_"+.timeStamp$+".wav"
923 .logtext$ = .pinyin$+tab$+.choice$+tab$+"'.register'Hz"+tab$+.currentDate$+tab$+.outfilename$+newline$
924 fileappend 'logDir$'/logFile.txt '.logtext$'
925 select Sound 'sampleSound$'
926 Write to WAV file... 'logDir$'/'.outfilename$'
930 # Make sure all Preferences directories are available
931 procedure set_up_directories
932 .dirPath$ = replace_regex$("'preferencesDirectory$'/sgc2", "[ ]", "\\&", 0);
934 system mkdir -p '.dirPath$'/wordlists
935 system mkdir -p '.dirPath$'/log
941 # Retrieve and store setting between sessions
943 procedure read_preferences .preferencesFile$
944 if not fileReadable(.preferencesFile$)
945 .preferencesFile$ = preferencesDirectory$+"/sgc2/sgc2rc.txt"
947 if fileReadable(.preferencesFile$)
948 Read from file... 'preferencesDirectory$'/sgc2/sgc2rc.txt
949 .preferenceTable$ = selected$("Table")
950 .numPefKeys = Get number of rows
952 call findLabel '.preferenceTable$' language
954 select Table '.preferenceTable$'
955 language$ = Get value... 'findLabel.row' Value
958 call findLabel '.preferenceTable$' register
960 select Table '.preferenceTable$'
961 register = Get value... 'findLabel.row' Value
964 call findLabel '.preferenceTable$' precision
966 select Table '.preferenceTable$'
967 precision = Get value... 'findLabel.row' Value
970 call findLabel '.preferenceTable$' shuffleLists
972 select Table '.preferenceTable$'
973 shuffleLists = Get value... 'findLabel.row' Value
976 call findLabel '.preferenceTable$' useSoundExample
978 select Table '.preferenceTable$'
979 useSoundExample = Get value... 'findLabel.row' Value
982 call findLabel '.preferenceTable$' displayPinyin
984 select Table '.preferenceTable$'
985 displayPinyin = Get value... 'findLabel.row' Value
988 call findLabel '.preferenceTable$' displayChar
990 select Table '.preferenceTable$'
991 displayChar = Get value... 'findLabel.row' Value
994 call findLabel '.preferenceTable$' wordlistDir
996 select Table '.preferenceTable$'
997 wordlistDir$ = Get value... 'findLabel.row' Value
1000 call findLabel '.preferenceTable$' wordlistName
1001 if findLabel.row > 0
1002 select Table '.preferenceTable$'
1003 wordlistName$ = Get value... 'findLabel.row' Value
1006 call findLabel '.preferenceTable$' logdir
1007 if findLabel.row > 0
1008 select Table '.preferenceTable$'
1009 logDir$ = Get value... 'findLabel.row' Value
1012 select Table '.preferenceTable$'
1017 procedure write_preferences .preferencesFile$
1018 Create Table with column names... Preferences 0 Key Value
1019 if index_regex(.preferencesFile$, "[a-zA-Z0-9]") <= 0
1020 .preferencesFile$ = preferencesDirectory$ + "/sgc2/sgc2rc.txt"
1023 select Table Preferences
1026 Set string value... '.row' Key language
1027 Set string value... '.row' Value 'language$'
1030 select Table Preferences
1033 Set string value... '.row' Key register
1034 Set numeric value... '.row' Value 'register'
1037 select Table Preferences
1040 Set string value... '.row' Key precision
1041 Set numeric value... '.row' Value 'precision'
1043 select Table Preferences
1046 Set string value... '.row' Key shuffleLists
1047 Set numeric value... '.row' Value 'shuffleLists'
1049 select Table Preferences
1052 Set string value... '.row' Key useSoundExample
1053 Set numeric value... '.row' Value 'useSoundExample'
1055 select Table Preferences
1058 Set string value... '.row' Key displayPinyin
1059 Set numeric value... '.row' Value 'displayPinyin'
1061 select Table Preferences
1064 Set string value... '.row' Key displayChar
1065 Set numeric value... '.row' Value 'displayChar'
1067 select Table Preferences
1070 Set string value... '.row' Key wordlistDir
1071 Set string value... '.row' Value 'wordlistDir$'
1073 select Table Preferences
1076 Set string value... '.row' Key wordlistName
1077 Set string value... '.row' Value 'wordlistName$'
1079 select Table Preferences
1082 Set string value... '.row' Key logdir
1083 Set string value... '.row' Value 'logDir$'
1085 select Table Preferences
1086 Write to table file... '.preferencesFile$'