| 1 |
form Highlighter test |
| 2 |
sentence My_sentence This should all be a string |
| 3 |
text My_text This should also all be a string |
| 4 |
word My_word Only the first word is a string, the rest is invalid |
| 5 |
boolean Binary 1 |
| 6 |
boolean Text no |
| 7 |
boolean Quoted "yes" |
| 8 |
comment This should be a string |
| 9 |
real left_Range -123.6 |
| 10 |
positive right_Range_max 3.3 |
| 11 |
integer Int 4 |
| 12 |
natural Nat 4 |
| 13 |
endform |
| 14 |
|
| 15 |
# External scripts |
| 16 |
include /path/to/file |
| 17 |
runScript: "/path/to/file" |
| 18 |
execute /path/to/file |
| 19 |
|
| 20 |
stopwatch |
| 21 |
|
| 22 |
# old-style procedure call |
| 23 |
call oldStyle "quoted" 2 unquoted string |
| 24 |
assert oldStyle.local = 1 |
| 25 |
|
| 26 |
# New-style procedure call with parens |
| 27 |
@newStyle("quoted", 2, "quoted string") |
| 28 |
if praatVersion >= 5364 |
| 29 |
# New-style procedure call with colon |
| 30 |
@newStyle: "quoted", 2, "quoted string" |
| 31 |
endif |
| 32 |
|
| 33 |
# if-block with built-in variables |
| 34 |
if windows |
| 35 |
# We are on Windows |
| 36 |
elsif unix = 1 or !macintosh |
| 37 |
exitScript: "We are on Linux" |
| 38 |
else macintosh == 1 |
| 39 |
exit We are on Mac |
| 40 |
endif |
| 41 |
|
| 42 |
# inline if with inline comment |
| 43 |
var = if macintosh = 1 then 0 else 1 fi ; This is an inline comment |
| 44 |
|
| 45 |
# for-loop with explicit from using local variable |
| 46 |
# and paren-style function calls and variable interpolation |
| 47 |
n = numberOfSelected("Sound") |
| 48 |
for i from newStyle.local to n |
| 49 |
sound'i' = selected("Sound", i) |
| 50 |
sound[i] = sound'i' |
| 51 |
endfor |
| 52 |
|
| 53 |
for i from 1 to n |
| 54 |
# Different styles of object selection |
| 55 |
select sound'i' |
| 56 |
sound = selected() |
| 57 |
sound$ = selected$("Sound") |
| 58 |
select Sound 'sound$' |
| 59 |
selectObject(sound[i]) |
| 60 |
selectObject: sound |
| 61 |
|
| 62 |
# Pause commands |
| 63 |
beginPause("Viewing " + sound$) |
| 64 |
if i > 1 |
| 65 |
button = endPause("Stop", "Previous", |
| 66 |
...if i = total_sounds then "Finish" else "Next" fi, |
| 67 |
...3, 1) |
| 68 |
else |
| 69 |
button = endPause("Stop", |
| 70 |
...if i = total_sounds then "Finish" else "Next" fi, |
| 71 |
...2, 1) |
| 72 |
endif |
| 73 |
editor_name$ = if total_textgrids then "TextGrid " else "Sound " fi + name$ |
| 74 |
nocheck editor 'editor_name$' |
| 75 |
nocheck Close |
| 76 |
nocheck endeditor |
| 77 |
|
| 78 |
# New-style standalone command call |
| 79 |
Rename: "SomeName" |
| 80 |
|
| 81 |
# Command call with assignment |
| 82 |
duration = Get total duration |
| 83 |
|
| 84 |
# Multi-line command with modifier |
| 85 |
pitch = noprogress To Pitch (ac): 0, 75, 15, "no", |
| 86 |
...0.03, 0.45, 0.01, 0.35, 0.14, 600 |
| 87 |
|
| 88 |
# do-style command with assignment |
| 89 |
minimum = do("Get minimum...", 0, 0, "Hertz", "Parabolic") |
| 90 |
|
| 91 |
# New-style multi-line command call with broken strings |
| 92 |
table = Create Table with column names: "table", 0, |
| 93 |
..."file subject speaker |
| 94 |
...f0 f1 f2 f3 " + |
| 95 |
..."duration response" |
| 96 |
|
| 97 |
removeObject: pitch, table |
| 98 |
|
| 99 |
# Picture window commands |
| 100 |
selectObject: sound |
| 101 |
# do-style command |
| 102 |
do("Select inner viewport...", 1, 6, 0.5, 1.5) |
| 103 |
Black |
| 104 |
Draw... 0 0 0 0 "no" Curve |
| 105 |
Draw inner box |
| 106 |
Text bottom: "yes", sound$ |
| 107 |
Erase all |
| 108 |
|
| 109 |
# Demo window commands |
| 110 |
demo Erase all |
| 111 |
demo Select inner viewport... 0 100 0 100 |
| 112 |
demo Axes... 0 100 0 100 |
| 113 |
demo Paint rectangle... white 0 100 0 100 |
| 114 |
demo Text... 50 centre 50 half Click to finish |
| 115 |
demoWaitForInput ( ) |
| 116 |
demo Erase all |
| 117 |
demo Text: 50, "centre", 50, "half", "Finished" |
| 118 |
endfor |
| 119 |
|
| 120 |
# An old-style sendpraat block |
| 121 |
sendpraat Praat |
| 122 |
...'newline$' Create Sound as pure tone... "tone" 1 0 0.4 44100 440 0.2 0.01 0.01 |
| 123 |
...'newline$' Play |
| 124 |
...'newline$' Remove |
| 125 |
|
| 126 |
# A new-style sendpraat block |
| 127 |
beginSendPraat: "Praat" |
| 128 |
Create Sound as pure tone: "tone", 1, 0, 0.4, 44100, 440, 0.2, 0.01, 0.01 |
| 129 |
duration = Get total duration |
| 130 |
Remove |
| 131 |
endSendPraat: "duration" |
| 132 |
appendInfoLine: "The generated sound lasted for ", duration, "seconds" |
| 133 |
|
| 134 |
time = stopwatch |
| 135 |
clearinfo |
| 136 |
echo This script took |
| 137 |
print 'time' seconds to |
| 138 |
printline execute. |
| 139 |
|
| 140 |
# Old-style procedure declaration |
| 141 |
procedure oldStyle .str1$ .num .str2$ |
| 142 |
.local = 1 |
| 143 |
endproc |
| 144 |
|
| 145 |
# New-style procedure declaration with parentheses |
| 146 |
procedure newStyle (.str1$, .num, .str2$) |
| 147 |
# Command with "local" variable |
| 148 |
.local = Get total duration |
| 149 |
endproc |
| 150 |
|
| 151 |
# New-style procedure declaration with colon |
| 152 |
procedure newStyle: .str1$, .num, .str2$ |
| 153 |
# Command with "local" variable |
| 154 |
newStyle.local = Get total duration |
| 155 |
endproc |