Update of ManPages
[sgc2.git] / InitialiseSGC2.praat
blob15b6dbd8bdbac3bfef7a22b630be82d5d510b4bd
2 # SpeakGoodChinese 2.0
3
4 # Intializing Praat script
6 #     SpeakGoodChinese: InitializeSGC2.praat defines and sets the global variables
7 #     and loads general SGC2 code 
8 #     
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
13
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.
18
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.
23
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
27
29 # Do not store these variables as preferences
30 sgc.nonPreferences$ = " config.savePerf config.openPerf config.clearSummary config.audioName "
32 # Information for logging
33 currentDate$ = date$()
34 dateYear$ = right$(currentDate$, length(currentDate$) - rindex(currentDate$, " "))
35 logtimeStamp$ = replace_regex$(currentDate$, "[^a-zA-Z0-9\-_]", "-", 0)
36 currentLogDirectory$ = ""
37 feedbackTablePrefix$ = "Feedback"
38 feedbackTableName$ = ""
40 # Define canvas
41 viewportMargin = 5
42 yWordlist = 11
43 yFeedback = yWordlist + 5
44 yPinyin = yFeedback + 10
45 yContour = yPinyin + 15
46 wipeContourArea$ = "demo Paint rectangle... White 20 80 'yContour' 100"
47 wipePinyinArea$ = "demo Paint rectangle... White 20 80 'yPinyin' 'yContour'"
48 wipeFeedbackArea$ = "demo Paint rectangle... White 0 100 'yFeedback' 'yPinyin'"
49 wipeWordlistArea$ = "demo Paint rectangle... White 20 80 'yWordlist' 'yFeedback'"
51 # Pop-Up window colors
52 sgc2.popUp_bordercolor$ = "{0.5,0.5,1}"
53 sgc2.popUp_backgroundcolor$ = "{0.9,0.9,1}"
55 # Initialize parameters
56 alertText$ = ""
57 te.currentWord = 1
58 te.numberOfWords = 0
59 te.recordedSound = 0
60 sgc.saveAudioOn = 0
61 pinyin$ = ""
62 sgc.pinyin$ = ""
63 character$ = ""
64 buttons$ = ""
65 config$ = ""
66 wordlistNum = 1
67 wordlistName$ = ""
68 wordlist$ = ""
69 mainPage.play = -1
70 config.deleteWordlist = -1
71 config.displayNumbers = 1
72 config.displayPinyin = 1
73 config.displayChar = 0
74 config.displayTrans = 1
75 config.useSoundExample = 1
76 config.synthesis$ = "_DISABLED_"
77 config.input$ = "Microphone"
78 config.showBackground = 1
79 sgc2.noiseThresshold = -30
80 config.strict = 0
81 config.savePerf = 0
82 config.openPerf = 0
83 config.clearSummary = 0
84 config.audioName$ = ""
85 sgc.savePerf$ = ""
86 sgc.saveAudio$ = ""
88 sgc_ToneProt.minimumPitch = 40
89 sgc_ToneProt.maximumPitch = 600
91 # Platform dependent settings
92 if macintosh or windows
93         config.displayChar = 1
94         config.displayNumbers = 0
95 endif
96 if windows and endsWith(build_SHA$, " XP")
97         config.displayChar = 0
98         config.displayNumbers = 0
99 endif
100 if unix
101         config.displayChar = 0
102         config.displayNumbers = 1
103 endif
105 if unix
106         samplingFrequency = 44100
107 elsif macintosh
108         samplingFrequency = 44100
109 elsif windows
110         samplingFrequency = 44100
111 endif
112 recordingTime = 2
114 logging = 0
115 config.language$ = "EN"
116 config.register = 249
117 preferencesAppFile$ = preferencesAppDir$+"/sgc2rc.txt"
118 preferencesLogDir$ = "'preferencesAppDir$'/log"
119 preferencesTableDir$ = "'preferencesAppDir$'/Data"
120 sgc2wordlists$ = "'preferencesAppDir$'/wordlists"
121 localWordlistDir$ = sgc2wordlists$
123 # Global word lists must be installed BY THE ADMINISTRATOR
124 # This means, create the directory 'globalwordlists$' and
125 # fill it with wordlist directories containing wordlist.Table
126 # and audio files. They can be copied from a local directory.
127 globalwordlists$ = ""
128 globaltablelists$ = ""
129 globalTTSdir$ = ""
130 if unix
131         globalwordlists$ = "/etc/'sgc2.demoAppName$'/wordlists"
132         globaltablelists$ = "/etc/'sgc2.demoAppName$'/Data"     
133         globalTTSdir$ = "/etc/'sgc2.demoAppName$'/TTS"  
134 elsif macintosh
135         globalwordlists$ = "/Library/Preferences/'sgc2.demoAppName$'/wordlists"
136         globaltablelists$ = "/Library/Preferences/'sgc2.demoAppName$'/Data"
137         globalTTSdir$ = "/Library/Preferences/'sgc2.demoAppName$'/TTS"  
138 elsif windows
139         globalwordlists$ = "C:/Documents and Settings/All Users/Application Data/'sgc2.demoAppName$'/wordlists"
140         globaltablelists$ = "C:/Documents and Settings/All Users/Application Data/'sgc2.demoAppName$'/Data"
141         globalTTSdir$ = "C:/Documents and Settings/All Users/Application Data/'sgc2.demoAppName$'/TTS"
142 endif
143 sgc2.synthesizer = -1
144 # Define a Praat TTS command that will set sgc2.synthesizer
145 sgc2.normalTTScommand$ = "call create_default_TTS Mandarin f4 10000 0.01 50 100 95 no IPA"
146 sgc2.advancedTTScommand$ = "call create_default_TTS Mandarin f4 10000 0.01 50 70 125 no IPA"
147 sgc2.alignedTextGrid = -1
149 ##############################################################
151 config.shuffleLists = 1
152 defaultFontSize = 12
153 defaultFont$ = "Helvetica"
154 defaultLineWidth = 1
156 # Set up directories if they do not exist already
157 call set_up_directories
159 # Get saved preferences
160 call read_preferences ""
162 # Set up TTS system
163 speakCommandDir$ = "'preferencesAppDir$'/TTS"
164 speakCommandFile$ = ""
165 call set_up_TTS
167 # Set inital language
168 call set_language 'config.language$'
170 # Get the word-list
171 call load_word_list "'localWordlistDir$'" 0
173 # Set up evaluation table
174 initialiseSGC2.toneevaluation_table$ = ""
175 call initialize_toneevaluation_tables
177 # Draw inital window
178 call init_window
180 ###############################################################
182 # Obligatory procedures
184 ###############################################################
185 # Initialize Demo Window
186 procedure init_window
187     demo Erase all
188         demo Line width... 'defaultLineWidth'
189         demo 'defaultFont$'
190         call set_font_size 'defaultFontSize'
191         demo Black
192         
193         # If there is no recorded sound, try to read stored recording
194         if recordedSound$ = "" and sgc.saveAudio$ <> ""
195                 .pinyin$ = ""
196                 select Table 'wordlist$'
197                 if te.currentWord > 0 and te.currentWord <= te.numberOfWords
198                         .pinyin$ = Get value... 'te.currentWord' Pinyin
199                         .outputName$ = "'sgc.saveAudio$'/'.pinyin$'.wav"
200                         if fileReadable(.outputName$)
201                                 te.recordedSound = Read from file: .outputName$
202                                 recordedSound$ = selected$("Sound")
203                                 call recognizeTone
204                                 
205                                 # Set config.audioName
206                                 .tmp$ = replace_regex$(sgc.saveAudio$, "[^/]+/?$", "", 0)
207                                 config.audioName$ = replace$(sgc.saveAudio$, .tmp$, "", 0)
208                         endif
209                 endif
210         endif
211         
212         # Update screen
213         call reset_viewport
214         .windowTitle$ = replace$(wordlistName$, "_", " ", 0)
215         call set_window_title 'buttons$' '.windowTitle$'
216         # Display the word-list
217         call write_word_list
218     # Wipe screen and draw background
219     call wipeArea 'wipeContourArea$'
220         if config.showBackground
221                 call draw_background Background
222         endif
223     # Define buttons in a table
224     call init_buttons
225     # Set Play button
226         call Set_Play_Button
227     
228         # Draw the contour
229         call draw_tone_contour
230         # SaveAudio light
231         call paint_saveAudio_light
232         # Set play button
233         
234 endproc
236 # Make sure all Preferences directories are available
237 procedure set_up_directories
238         .dirPath$ = "'preferencesAppDir$'"
239         createDirectory(.dirPath$)
240         .dirPath$ > '.dirPath$'/directory.txt
241         createDirectory("'.dirPath$'/wordlists")
242         .dirPath$ > '.dirPath$'/wordlists/directory.txt
243         createDirectory("'.dirPath$'/pitchmodels")
244         .dirPath$ > '.dirPath$'/pitchmodels/directory.txt
245         createDirectory("'.dirPath$'/log")
246         .dirPath$ > '.dirPath$'/log/directory.txt
247         createDirectory("'.dirPath$'/TTS")
248         .dirPath$ > '.dirPath$'/TTS/directory.txt
249 endproc
252 # Retrieve and store setting between sessions
254 procedure read_preferences .preferencesFile$
255         if not fileReadable(.preferencesFile$)
256                 .preferencesFile$ = preferencesAppFile$
257         endif
258         if fileReadable(.preferencesFile$)
259                 Read from file... 'preferencesAppFile$'
260                 .preferenceTable$ = selected$("Table")
261                 .numPrefKeys = Get number of rows
262                 for .row to .numPrefKeys
263                         .variableName$ = Get value... '.row' Key
264                         if variableExists(.variableName$)
265                                 .variableValue = Get value... '.row' Value
266                                 if .variableValue <> undefined
267                                         '.variableName$' = '.variableValue'
268                                 endif
269                         elsif variableExists(.variableName$+"$")
270                                 .variableValue$ = Get value... '.row' Value
271                                 .variableName$ = .variableName$+"$"
272                                 '.variableName$' = "'.variableValue$'"
273                         endif
274                 endfor
275                 
276                 select Table '.preferenceTable$'
277                 Remove
278         endif
279 endproc
281 procedure write_preferences .preferencesFile$
282         Create Table with column names... Preferences 0 Key Value
283         if index_regex(.preferencesFile$, "[a-zA-Z0-9]") <= 0
284                 .preferencesFile$ = preferencesAppFile$
285         endif
286         .row = 0
287         
288         for .tableNum from 1 to 2
289                 if .tableNum = 1
290                         .table$ = "Config"
291                 elsif .tableNum = 2
292                         .table$ = "MainPage"
293                 endif
294                 .varPrefix$ = replace_regex$(.table$, "^(.)", "\l\1", 0)
296                 select Table '.table$'
297                 .numTableRows = Get number of rows
298                 for .tablerow to .numTableRows
299                         select Table '.table$'
300                         .label$ = Get value... '.tablerow' Label
301                         .variableName$ = .varPrefix$+"."+(replace_regex$(.label$, "^(.)", "\l\1", 0))
302                         .keyName$ = .variableName$
303                         .value$ = ""
304                         if sgc.nonPreferences$ <> "" and index(sgc.nonPreferences$, " '.variableName$' ")
305                                 .value$ = ""
306                         elsif variableExists(.variableName$)
307                                 .value = '.variableName$'
308                                 .value$ = "'.value'"
309                         elsif variableExists(.variableName$ + "$")
310                                 .variableName$ = .variableName$ + "$"
311                                 .value$ = '.variableName$'
312                         elsif index(.variableName$, "_") > 0
313                                 .variableName$ = left$(.variableName$, rindex(.variableName$, "_") - 1) 
314                                 .keyName$ = .variableName$
315                                 select Table Preferences
316                                 .prefRow = Search column... Key '.keyName$'
317                                 if .prefRow <= 0
318                                         if variableExists(.variableName$)
319                                            .value = '.variableName$'
320                                            .value$ = "'.value'"
321                                         elsif variableExists(.variableName$ + "$")
322                                            .variableName$ = .variableName$ + "$"
323                                            .value$ = '.variableName$'
324                                         endif
325                                 endif
326                         endif
328                         if .value$ <> ""
329                                 select Table Preferences
330                                 Append row
331                                 .row += 1
332                                 Set string value... '.row' Key '.keyName$'
333                                 Set string value... '.row' Value '.value$'
334                         endif
335                 endfor
336         endfor
337         
338         # Some extra settings
339         select Table Preferences
340         Append row
341         .row += 1
342         Set string value... '.row' Key wordlistDir
343         Set string value... '.row' Value 'localWordlistDir$'
345         select Table Preferences
346         Append row
347         .row += 1
348         Set string value... '.row' Key wordlistName
349         Set string value... '.row' Value 'wordlistName$'
351         select Table Preferences
352         Write to table file... '.preferencesFile$'
353         Remove
355 endproc
357 ###############################################################
359 # TTS (speech synthesis). Place commands in user info
361 # Prerequisites
362 # speakCommandDir$ = "'preferencesAppDir$'/TTS"
363 # speakCommandFile$ = ""
365 # Make sure sgc2.synthesizer is set!
366 procedure create_default_TTS .language$ .voice$ .samplefreq .gap .pitch_adj .pitch_range .words_per_minute .use_data$ .espeak_phones$
367         sgc2.synthesizer = Create SpeechSynthesizer... '.language$' '.voice$'
368         Set speech output settings... .samplefreq .gap .pitch_adj .pitch_range .words_per_minute '.use_data$' '.espeak_phones$'
369 endproc
371 procedure set_up_TTS
372         if sgc2.synthesizer > 0
373                 select sgc2.synthesizer
374                 Remove
375                 sgc2.synthesizer = -1
376         endif
377         # Note, the TTScommand must set sgc2.synthesizer!
378         if config.strict
379                 'sgc2.advancedTTScommand$'
380         else
381                 'sgc2.normalTTScommand$'
382         endif
384         if macintosh
385                 .ttscommand$ = "speak"
386                 .osName$ = "OSX"
387                 .quote$ = ""
388         elsif unix
389                 .ttscommand$ = "espeak"
390                 .osName$ = "UNIX"
391                 .quote$ = ""
392         elsif windows
393                 .ttscommand$ = "C:/Program Files/eSpeak/command_line/espeak.exe"
394                 .osName$ = "WIN"
395                 .quote$ = """"
396         endif
397         # Global TTS command has precedence
398         if fileReadable("'globalTTSdir$'/TTS_'.osName$'_command.txt")
399                 speakCommandFile$ = "'globalTTSdir$'/TTS_'.osName$'_command.txt"
400                 if config.synthesis$ = "_DISABLED_"
401                         # Default is ON
402                         config.synthesis$ = "eSpeak"
403                 endif
404         endif
406         # Local TTS command, if there is no global one
407         # Command does not exist yet, create it if eSpeak is installed
408         # Make sure to quote the path!
409         if speakCommandFile$ = ""
410                 # Autodetect synthesizer command
411 #               if not fileReadable("'speakCommandDir$'/TTS_'.osName$'_eSpeak_command.txt")
412 #                       .command_path$ = ""
413 #                       if macintosh
414 #                               system_nocheck  PATH=${PATH}:/opt/local/bin; bash -c -- 'which '.ttscommand$' > "'speakCommandDir$'/command_path.txt"'
415 #                               .command_path$ < 'speakCommandDir$'/command_path.txt
416 #                       elsif unix
417 #                               system_nocheck  PATH=${PATH};bash -c -- 'which '.ttscommand$' > "'speakCommandDir$'/command_path.txt"'
418 #                               .command_path$ < 'speakCommandDir$'/command_path.txt
419 #                       elsif windows
420 #                               if fileReadable(.ttscommand$)
421 #                                       .command_path$ = .ttscommand$
422 #                               endif
423 #                       endif
424 #                       # Remove any newlines
425 #                       .command_path$ = replace$(.command_path$, "'newline$'", "", 0)
427 #                       # Command path found
428 #                       if sgc2.synthesizer <= 0 and .command_path$ <> "" and fileReadable(.command_path$)
429 #                               deleteFile("'speakCommandDir$'/TTS_'.osName$'_eSpeak_command.txt")
430 #                               fileappend "'speakCommandDir$'/TTS_'.osName$'_eSpeak_command.txt"  
431 #                               ...'.quote$''.ttscommand$''.quote$' -v zh+f4 -s 100 'newline$'
432 #                               speakCommandFile$ = "'speakCommandDir$'/TTS_'.osName$'_eSpeak_command.txt"
433 #                       endif
434 #               endif
435 #               if fileReadable("'speakCommandDir$'/TTS_'.osName$'_eSpeak_command.txt")
436                         speakCommandFile$ = "'speakCommandDir$'/TTS_'.osName$'_eSpeak_command.txt"
437                 endif
438                 deleteFile("'speakCommandDir$'/command_path.txt")
439         endif
440         
441         # Close off (other TTS maybe a later option)
442         if sgc2.synthesizer > 0 or (speakCommandFile$ <> "" and fileReadable(speakCommandFile$))
443                 config.synthesis$ = "eSpeak"
444         endif
445 endproc
447 ###############################################################
449 # Evaluation tables
451 # Prerequisites
452 # initialiseSGC2.toneevaluation_table$ = ""
453 procedure initialize_toneevaluation_tables
454         # Remove old table
455         if initialiseSGC2.toneevaluation_table$ != ""
456                 select Table 'initialiseSGC2.toneevaluation_table$'
457                 Remove
458         endif
459         initialiseSGC2.toneevaluation_table$ = ""
460         
461         if sgc.savePerf$ <> "" and fileReadable(sgc.savePerf$)
462                 sgc2.performanceTable = Read from file: sgc.savePerf$
463                 Rename: "Performance"
464         else
465                 # Create new table
466                 sgc2.performanceTable = Create Table with column names... Performance 0 Pinyin Correct Wrong Total High Low Wide Narrow Unknown Commented Time
467         endif
468         initialiseSGC2.toneevaluation_table$ = "Performance"
469         call get_toneevaluation_row Total
470 endproc
472 procedure get_toneevaluation_row .pinyin$
473         select Table 'initialiseSGC2.toneevaluation_table$'
474     .row = Search column... Pinyin '.pinyin$'
475         if .row < 1
476                 Append row
477                 .row = Get number of rows
478                 Set string value... '.row' Pinyin '.pinyin$'
479                 Set numeric value... '.row' Correct 0
480                 Set numeric value... '.row' Wrong 0
481                 Set numeric value... '.row' Total 0
482                 Set numeric value... '.row' High 0
483                 Set numeric value... '.row' Low 0
484                 Set numeric value... '.row' Wide 0
485                 Set numeric value... '.row' Narrow 0
486                 Set numeric value... '.row' Unknown 0
487                 Set numeric value... '.row' Commented 0
488                 Set numeric value... '.row' Time 0
489                 Sort rows... Pinyin
490         .row = Search column... Pinyin '.pinyin$'
491         endif
492 endproc
494 procedure increment_toneevaluation_in_row .row .column$
495         select Table 'initialiseSGC2.toneevaluation_table$'
496         .tmp = Get value... '.row' '.column$'
497         .tmp += 1
498         Set numeric value... '.row' '.column$' '.tmp'
499         
500         # Set time stamp
501         .dateTime$ = date$()
502         Set string value: .row, "Time", .dateTime$
503         
504 endproc
506 procedure increment_toneevaluation_value .pinyin$ .column$
507         call get_toneevaluation_row '.pinyin$'
508         .row = get_toneevaluation_row.row
509         call increment_toneevaluation_in_row '.row' '.column$'
510         
511         call get_toneevaluation_row Total
512         .row = get_toneevaluation_row.row
513         call increment_toneevaluation_in_row '.row' '.column$'
514 endproc
516 procedure add_feedback_to_toneevaluation .table$
517     select Table '.table$'
518     .line1$ = Get value... 1 Text
519     .line2$ = Get value... 2 Text
520     .label$ = Get value... 3 Text
521         if .label$ = "6"
522                 .label$ = "Unknown"
523         endif
524         
525         .tones$ = replace_regex$(left$(.line1$, rindex(.line1$, ":")), "[^0-9]", "", 0)
526         .recognized$ = replace_regex$(right$(.line1$, length(.line1$)-rindex(.line1$, ":")), "[^0-9]", "", 0)
527         
528         # Set evaluation
529         call increment_toneevaluation_value 'sgc.pinyin$' Total
530         if .tones$ = .recognized$
531                 call increment_toneevaluation_value 'sgc.pinyin$' Correct
532         else
533                 call increment_toneevaluation_value 'sgc.pinyin$' Wrong
534         endif
535         if index_regex(.label$, "(Correct|Wrong)") <= 0
536                 call increment_toneevaluation_value 'sgc.pinyin$' '.label$'
537                 call increment_toneevaluation_value 'sgc.pinyin$' Commented
538         endif
539         
540         # Update performance table when SaveAudio is on
541         if sgc.saveAudioOn and sgc.savePerf$ <> "" and fileReadable(sgc.savePerf$)
542                 select Table 'initialiseSGC2.toneevaluation_table$'
543                 Write to table file... 'sgc.savePerf$'
544         endif
545 endproc
547 procedure setGrade .grade$
548         select Table 'wordlist$'
549         if recordedSound$ <> "" and sgc.pinyin$ <> ""           
550                 call get_toneevaluation_row 'sgc.pinyin$'
551                 .row = get_toneevaluation_row.row
552                 select Table 'initialiseSGC2.toneevaluation_table$'
553                 .col = Get column index... Grade
554                 if .col <= 0
555                         Insert column... 2 Grade
556                 endif
557                         
558                 Set numeric value: .row, "Grade", '.grade$'
559                 .numRows = Get number of rows
560                 .sumGrade = 0
561                 .sumN = 0
562                 for .r from 2 to .numRows
563                         .tmp = Get value: .r, "Grade"
564                         if .tmp <> undefined
565                                 .sumGrade += .tmp
566                                 .sumN += 1
567                         endif
568                 endfor
569                 .meanGrade = -1
570                 if .sumN > 0
571                         .meanGrade = .sumGrade / .sumN
572                 endif
573                 Set numeric value: 1, "Grade", .meanGrade
574                 
575                 # Store current performance table
576                 if sgc.savePerf$ <> "" and fileReadable(sgc.savePerf$)
577                         select Table 'initialiseSGC2.toneevaluation_table$'
578                         Write to table file... 'sgc.savePerf$'
579                 endif
580                 
581         endif
582 endproc
584 ###############################################################
586 # Miscelaneous procedures
588 ###############################################################
590 # TTS synthesis
591 procedure synthesize_sound .pinyin$
592         .command$ = ""
593         if speakCommandFile$ <> "" and fileReadable(speakCommandFile$)
594                 .command$ < 'speakCommandFile$'
595                 .command$ = replace$(.command$, "'newline$'", " ", 0)
596                 if macintosh
597                         system_nocheck PATH=${PATH}:/usr/local/bin:/opt/local/bin; bash -rc -- ''.command$' "'.pinyin$'"'
598                 elsif unix
599                         system_nocheck bash -rc -- ''.command$' "'.pinyin$'"'
600                 elsif windows
601                         system_nocheck call '.command$' "'.pinyin$'"'
602                 endif
603         elsif sgc2.synthesizer > 0
604                 select sgc2.synthesizer
605                 Play text... '.pinyin$'
606         endif
607 endproc
609 procedure align_recordedSound .pinyin$
610         if 0 and sgc2.synthesizer > 0 and recordedSound$ <> ""
611                 select Sound 'recordedSound$'
612                 .recordedTextGrid = To TextGrid... pinyin
613                 Set interval text... 1 1 '.pinyin$'
614                 select sgc2.synthesizer
615                 plus Sound 'recordedSound$'
616                 plus .recordedTextGrid
617                 sgc2.alignedTextGrid = nowarn noprogress To TextGrid (align,trim)... 1 1 1 -35 0.1 0.1 0.08
618                 Rename... AlignedTextGrid
619                 select .recordedTextGrid
620                 Remove
621         endif
622 endproc