1 <!DOCTYPE html PUBLIC
"-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
4 <meta http-equiv=
"Content-Type" content=
"text/html; charset=UTF-8">
5 <meta http-equiv=
"Content-Style-Type" content=
"text/css">
7 <meta name=
"Generator" content=
"Cocoa HTML Writer">
8 <meta name=
"CocoaVersion" content=
"824.48">
9 <style type=
"text/css">
10 p
.p1
{margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Helvetica
}
11 p
.p2
{margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Helvetica
; min-height: 11.0px}
12 p
.p3
{margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica
}
13 p
.p4
{margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica
; min-height: 14.0px}
14 p
.p5
{margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Helvetica
}
15 p
.p6
{margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco
; min-height: 12.0px}
16 p
.p7
{margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco
}
17 p
.p8
{margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco
; color: #606060}
18 p
.p9
{margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Helvetica
; min-height: 17.0px}
19 p
.p10
{margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco
; color: #a42113}
20 p
.p11
{margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco
; color: #a42113; min-height: 12.0px}
21 span
.s1
{font: 9.0px Helvetica
}
22 span
.s2
{color: #001db6}
23 span
.s3
{color: #000000}
24 span
.s4
{font: 9.0px Monaco
}
25 span
.s5
{color: #606060}
26 span
.s6
{color: #0000ff}
27 span
.s7
{color: #0000bf}
28 span
.Apple-tab-span
{white-space:pre
}
32 <p class=
"p1"><b>PathName
<span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>file and directory path utilities
</b><span class=
"s1"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></span></p>
33 <p class=
"p2"><br></p>
34 <p class=
"p3"><b>superclass: Object
</b></p>
35 <p class=
"p4"><br></p>
36 <p class=
"p3">PathName is a utility Class for manipulating file names and paths.
<span class=
"Apple-converted-space"> </span></p>
37 <p class=
"p3">It expects a path to a file, and lets you access parts of that file path.
</p>
38 <p class=
"p4"><br></p>
39 <p class=
"p5"><b>Creation
</b></p>
40 <p class=
"p6"><br></p>
41 <p class=
"p7">*new(path)
</p>
42 <p class=
"p6"><br></p>
43 <p class=
"p3">path is a String which likely contains one or more /
<span class=
"Apple-converted-space"> </span>as typical for folder separation.
<span class=
"Apple-converted-space"> </span></p>
44 <p class=
"p6"><br></p>
45 <p class=
"p8"><span class=
"s2">PathName
</span><span class=
"s3">.new(
</span>"MyDisk/SC 2.2.8 f/Sounds/FunkyChicken"<span class=
"s3">);
<span class=
"Apple-converted-space"> </span></span></p>
46 <p class=
"p6"><br></p>
47 <p class=
"p3">~ will be converted to your fully addressed home directory.
<span class=
"Apple-converted-space"> </span>Symbolic Links will be expanded, as per String-standardizePath.
</p>
48 <p class=
"p9"><br></p>
49 <p class=
"p5"><b>Class Methods
</b></p>
50 <p class=
"p6"><br></p>
51 <p class=
"p3"><b>tmp
</b></p>
52 <p class=
"p3"><b>tmp_(aPath)
</b></p>
53 <p class=
"p4"><br></p>
54 <p class=
"p3">Get or set the global temp directory as a
<b>String
</b>. This is used by
<b>Buffer
</b>, etc. By default this is
"/tmp/" for Linux and OSX, and
"/WINDOWS/TEMP/" for Windows.
</p>
55 <p class=
"p9"><br></p>
56 <p class=
"p5"><b>Instance Methods
</b></p>
57 <p class=
"p6"><br></p>
58 <p class=
"p3"><b>fileName
</b><span class=
"s4"><span class=
"Apple-converted-space"> </span></span></p>
59 <p class=
"p6"><br></p>
60 <p class=
"p3">returns just the name of the file itself; i.e.
<span class=
"Apple-converted-space"> </span></p>
61 <p class=
"p3">everything after the last slash in the full path.
</p>
62 <p class=
"p6"><br></p>
64 <p class=
"p7">var myPath;
</p>
65 <p class=
"p7">myPath = PathName.new(
"MyDisk/SC 2.2.8 f/Sounds/FunkyChicken");
<span class=
"Apple-converted-space"> </span></p>
66 <p class=
"p7">myPath.fileName.postln;
<span class=
"Apple-converted-space"> </span></p>
68 <p class=
"p6"><br></p>
69 <p class=
"p3">(There is also
<b>fileNameWithoutExtension
</b> if you don't want the file extension.)
</p>
70 <p class=
"p6"><br></p>
71 <p class=
"p3"><b>extension
</b><span class=
"s4"><span class=
"Apple-converted-space"> </span></span></p>
72 <p class=
"p6"><br></p>
73 <p class=
"p3">returns the file extension, i.e. everything after the last full-stop in the fileName.
</p>
74 <p class=
"p4"><br></p>
75 <p class=
"p3"><b>pathOnly
</b><span class=
"s4"><span class=
"Apple-converted-space"> </span></span></p>
76 <p class=
"p6"><br></p>
77 <p class=
"p3">returns the full path up to the file name itself; i.e.
<span class=
"Apple-converted-space"> </span></p>
78 <p class=
"p3">everything up to and including
<span class=
"Apple-converted-space"> </span>the last slash.
<span class=
"Apple-converted-space"> </span></p>
79 <p class=
"p3">This is handy e.g. for storing several files in the same folder.
</p>
80 <p class=
"p6"><br></p>
82 <p class=
"p7">var myPath;
</p>
83 <p class=
"p7">myPath = PathName.new(
"MyDisk/SC 2.2.8 f/Sounds/FunkyChicken");
<span class=
"Apple-converted-space"> </span></p>
84 <p class=
"p7">myPath.pathOnly.postln;
<span class=
"Apple-converted-space"> </span></p>
86 <p class=
"p6"><br></p>
87 <p class=
"p3"><b>isAbsolutePath
</b></p>
88 <p class=
"p3"><b>asAbsolutePath
</b></p>
89 <p class=
"p3"><b>isRelativePath
</b></p>
90 <p class=
"p3"><b>asRelativePath
</b></p>
91 <p class=
"p3"><span class=
"Apple-tab-span"> </span>you MUST have correctly initialized the scroot classvar for this
</p>
92 <p class=
"p3"><span class=
"Apple-tab-span"> </span>to know what it is relative to !
</p>
93 <p class=
"p6"><br></p>
94 <p class=
"p6"><br></p>
95 <p class=
"p3"><b>folderName
</b><span class=
"s4"><span class=
"Apple-converted-space"> </span></span></p>
96 <p class=
"p6"><br></p>
97 <p class=
"p3">returns only the name of the folder that the file is in;
<span class=
"Apple-converted-space"> </span></p>
98 <p class=
"p3">i.e. everything in between the last but one and the last slash.
<span class=
"Apple-converted-space"> </span></p>
99 <p class=
"p6"><br></p>
101 <p class=
"p7"><span class=
"s2">var
</span> myPath;
</p>
102 <p class=
"p8"><span class=
"s3">myPath =
</span><span class=
"s2">PathName
</span><span class=
"s3">.new(
</span>"MyDisk/SC 2.2.8 f/Sounds/FunkyChicken"<span class=
"s3">);
<span class=
"Apple-converted-space"> </span></span></p>
103 <p class=
"p7">myPath.folderName.postln;
<span class=
"Apple-converted-space"> </span></p>
105 <p class=
"p6"><br></p>
106 <p class=
"p6"><br></p>
107 <p class=
"p3"><b>fullPath
</b></p>
108 <p class=
"p3">returns the full path name that PathName contains.
</p>
109 <p class=
"p6"><br></p>
111 <p class=
"p7"><span class=
"s2">var
</span> myPath;
</p>
112 <p class=
"p8"><span class=
"s3">myPath =
</span><span class=
"s2">PathName
</span><span class=
"s3">.new(
</span>"MyDisk/SC 2.2.8 f/Sounds/FunkyChicken"<span class=
"s3">);
<span class=
"Apple-converted-space"> </span></span></p>
113 <p class=
"p7">myPath.fullPath.postln;
<span class=
"Apple-converted-space"> </span></p>
115 <p class=
"p6"><br></p>
116 <p class=
"p3"><b>entries
</b></p>
117 <p class=
"p6"><br></p>
118 <p class=
"p3">returns a list of all the files+folders inside the folder represented by this path.
</p>
119 <p class=
"p6"><br></p>
121 <p class=
"p7"><span class=
"s2">var
</span> myPath;
</p>
122 <p class=
"p7">myPath =
<span class=
"s2">PathName
</span>.new(
<span class=
"s5">"./"</span>);
<span class=
"Apple-converted-space"> </span></p>
123 <p class=
"p7">myPath.entries.postln;
<span class=
"Apple-converted-space"> </span></p>
125 <p class=
"p6"><br></p>
126 <p class=
"p3"><b>files
</b></p>
127 <p class=
"p6"><br></p>
128 <p class=
"p3">returns a list of all the files in the folder represented by this path.
</p>
129 <p class=
"p6"><br></p>
131 <p class=
"p7"><span class=
"s2">var
</span> myPath;
</p>
132 <p class=
"p7">myPath =
<span class=
"s2">PathName
</span>.new(
<span class=
"s5">"./"</span>);
<span class=
"Apple-converted-space"> </span></p>
133 <p class=
"p7">myPath.files.postln;
<span class=
"Apple-converted-space"> </span></p>
135 <p class=
"p6"><br></p>
136 <p class=
"p3"><b>folders
</b></p>
137 <p class=
"p6"><br></p>
138 <p class=
"p3">returns a list of all the subfolders of the folder represented by this path.
</p>
139 <p class=
"p6"><br></p>
141 <p class=
"p7"><span class=
"s2">var
</span> myPath;
</p>
142 <p class=
"p7">myPath =
<span class=
"s2">PathName
</span>.new(
<span class=
"s5">"./"</span>);
<span class=
"Apple-converted-space"> </span></p>
143 <p class=
"p7">myPath.folders.postln;
<span class=
"Apple-converted-space"> </span></p>
145 <p class=
"p6"><br></p>
146 <p class=
"p3"><b>isFile
</b></p>
147 <p class=
"p6"><br></p>
148 <p class=
"p3">returns a
<a href=
"../Core/Boolean.html"><span class=
"s6">Boolean
</span></a> indicating whether or not the path represents a file (not a folder).
</p>
149 <p class=
"p6"><br></p>
151 <p class=
"p7"><span class=
"s2">var
</span> myPath;
</p>
152 <p class=
"p7">myPath =
<span class=
"s2">PathName
</span>.new(
<span class=
"s5">"./"</span>);
<span class=
"Apple-converted-space"> </span></p>
153 <p class=
"p7">myPath.isFile.postln;
<span class=
"Apple-converted-space"> </span></p>
155 <p class=
"p6"><br></p>
156 <p class=
"p3"><b>isFolder
</b></p>
157 <p class=
"p6"><br></p>
158 <p class=
"p3">returns a
<a href=
"../Core/Boolean.html"><span class=
"s6">Boolean
</span></a> indicating whether or not the path represents a folder (not a file).
</p>
159 <p class=
"p6"><br></p>
161 <p class=
"p7"><span class=
"s2">var
</span> myPath;
</p>
162 <p class=
"p7">myPath =
<span class=
"s2">PathName
</span>.new(
<span class=
"s5">"./"</span>);
<span class=
"Apple-converted-space"> </span></p>
163 <p class=
"p7">myPath.isFolder.postln;
<span class=
"Apple-converted-space"> </span></p>
165 <p class=
"p6"><br></p>
166 <p class=
"p3"><b>filesDo(func)
</b></p>
167 <p class=
"p6"><br></p>
168 <p class=
"p3">Iterates over all files found in the pathname, including ones in subfolders.
</p>
169 <p class=
"p6"><br></p>
171 <p class=
"p7"><span class=
"s2">var
</span> myPath;
</p>
172 <p class=
"p7">myPath =
<span class=
"s2">PathName
</span>.new(
<span class=
"s5">"./"</span>);
<span class=
"Apple-converted-space"> </span></p>
173 <p class=
"p7">myPath.filesDo{|afile| afile.postln};
<span class=
"Apple-converted-space"> </span></p>
175 <p class=
"p6"><br></p>
176 <p class=
"p3"><b>helpFilesDo(func)
</b></p>
177 <p class=
"p6"><br></p>
178 <p class=
"p3">Just like
<b>filesDo
</b>, but ignores paths which don't match the paths expected for SC help files. This excludes certain folders (e.g.
".svn",
"ignore") and only includes files with certain extensions.
</p>
179 <p class=
"p3">Please note that this is
<i>not
</i> the same as iterating a list of the Help files cached (e.g. in the Help browser). You can use
<b>Help.do(func)
</b> if you want that.
</p>
180 <p class=
"p6"><br></p>
182 <p class=
"p7"><span class=
"s7">var
</span> myPath;
</p>
183 <p class=
"p7">myPath =
<span class=
"s7">PathName
</span>.new(
<span class=
"s5">"./"</span>);
<span class=
"Apple-converted-space"> </span></p>
184 <p class=
"p7">myPath.helpFilesDo{
<span class=
"s7">|afile|
</span> afile.postln};
<span class=
"Apple-converted-space"> </span></p>
186 <p class=
"p6"><br></p>
187 <p class=
"p3"><b>allFolders
</b></p>
188 <p class=
"p6"><br></p>
189 <p class=
"p3">returns a list of all the folder names contained in the pathname itself.
</p>
190 <p class=
"p6"><br></p>
192 <p class=
"p7"><span class=
"s2">var
</span> myPath;
</p>
193 <p class=
"p8"><span class=
"s3">myPath =
</span><span class=
"s2">PathName
</span><span class=
"s3">.new(
</span>"MyDisk/SC 2.2.8 f/Sounds/FunkyChicken"<span class=
"s3">);
<span class=
"Apple-converted-space"> </span></span></p>
194 <p class=
"p7">myPath.allFolders.postln;
<span class=
"Apple-converted-space"> </span></p>
196 <p class=
"p6"><br></p>
197 <p class=
"p3"><b>diskName
</b></p>
198 <p class=
"p3">if path is an absolute path, returns the disk name; else a blank string.
</p>
199 <p class=
"p6"><br></p>
201 <p class=
"p7"><span class=
"s2">var
</span> myPath;
</p>
202 <p class=
"p8"><span class=
"s3">myPath =
</span><span class=
"s2">PathName
</span><span class=
"s3">.new(
</span>"MyDisk/SC 2.2.8 f/Sounds/FunkyChicken"<span class=
"s3">);
<span class=
"Apple-converted-space"> </span></span></p>
203 <p class=
"p7">myPath.diskName.postln;
<span class=
"Apple-converted-space"> </span></p>
205 <p class=
"p6"><br></p>
206 <p class=
"p10"><span class=
"s3">(
</span>// note the / at the start
</p>
207 <p class=
"p7"><span class=
"s2">var
</span> myPath;
</p>
208 <p class=
"p8"><span class=
"s3">myPath =
</span><span class=
"s2">PathName
</span><span class=
"s3">.new(
</span>"/MyDisk/SC 2.2.8 f/Sounds/FunkyChicken"<span class=
"s3">);
<span class=
"Apple-converted-space"> </span></span></p>
209 <p class=
"p7">myPath.diskName.postln;
<span class=
"Apple-converted-space"> </span></p>
211 <p class=
"p6"><br></p>
212 <p class=
"p3"><b>+/+
</b></p>
213 <p class=
"p3">Path concatenation operator - useful for avoiding doubling-up slashes unnecessarily.
</p>
214 <p class=
"p6"><br></p>
215 <p class=
"p8"><span class=
"s2">(PathName
</span><span class=
"s3">(
</span>"/somewhere"<span class=
"s3">) +/+
</span><span class=
"s2">PathName
</span><span class=
"s3">(
</span>"over/the/rainbow"<span class=
"s3">)).postln;
<span class=
"Apple-converted-space"> </span></span></p>
216 <p class=
"p8"><span class=
"s2">(PathName
</span><span class=
"s3">(
</span>"/somewhere"<span class=
"s3">) +/+
</span><span class=
"s2">PathName
</span><span class=
"s3">(
</span>"/over/the/rainbow"<span class=
"s3">)).postln;
<span class=
"Apple-converted-space"> </span></span></p>
217 <p class=
"p6"><br></p>
218 <p class=
"p6"><br></p>
219 <p class=
"p3"><b>endNumber
</b><span class=
"s4"><span class=
"Apple-converted-space"> </span></span></p>
220 <p class=
"p3">returns a number at the end of PathName.
</p>
221 <p class=
"p3">Returns zero if there is no number.
</p>
222 <p class=
"p6"><br></p>
223 <p class=
"p7"><span class=
"s2">PathName
</span>(
<span class=
"s5">"floating1"</span>).endNumber.postln;
<span class=
"Apple-converted-space"> </span></p>
224 <p class=
"p6"><br></p>
225 <p class=
"p7"><span class=
"s2">PathName
</span>(
<span class=
"s5">"floating"</span>).endNumber.postln;
<span class=
"Apple-converted-space"> </span></p>
226 <p class=
"p6"><br></p>
227 <p class=
"p3"><b>noEndNumbers
</b></p>
228 <p class=
"p3">returns fullPath without any numbers at the end.
</p>
229 <p class=
"p6"><br></p>
230 <p class=
"p7"><span class=
"s2">PathName
</span>(
<span class=
"s5">"floating1"</span>).noEndNumbers.postln;
<span class=
"Apple-converted-space"> </span></p>
231 <p class=
"p6"><br></p>
232 <p class=
"p7"><span class=
"s2">PathName
</span>(
<span class=
"s5">"floating"</span>).noEndNumbers.postln;
<span class=
"Apple-converted-space"> </span></p>
233 <p class=
"p6"><br></p>
234 <p class=
"p6"><br></p>
235 <p class=
"p3"><b>nextName
</b></p>
236 <p class=
"p3">generates a sensible next name for a file
</p>
237 <p class=
"p3">by incrementing a number at the end of PathName,
<span class=
"Apple-converted-space"> </span></p>
238 <p class=
"p3">or by adding one if there is none.
</p>
239 <p class=
"p6"><br></p>
240 <p class=
"p6"><br></p>
241 <p class=
"p7"><span class=
"s2">PathName
</span>(
<span class=
"s5">"floating34"</span>).nextName.postln;
<span class=
"Apple-converted-space"> </span></p>
242 <p class=
"p6"><br></p>
243 <p class=
"p7"><span class=
"s2">PathName
</span>(
<span class=
"s5">"floating"</span>).nextName.postln;
<span class=
"Apple-converted-space"> </span></p>
244 <p class=
"p6"><br></p>
245 <p class=
"p8"><span class=
"s2">PathName
</span><span class=
"s3">(
</span>"floating12_3A4X_56.7"<span class=
"s3">).nextName.postln;
<span class=
"Apple-converted-space"> </span></span></p>
246 <p class=
"p6"><br></p>
247 <p class=
"p3">This is useful for recording files with consecutive names,
<span class=
"Apple-converted-space"> </span></p>
248 <p class=
"p3">and e.g. to generate a new filename when you don't want to
<span class=
"Apple-converted-space"> </span></p>
249 <p class=
"p3">overwrite an existing file with the current name.
</p>
250 <p class=
"p6"><br></p>
251 <p class=
"p6"><br></p>
252 <p class=
"p3">Here is an example that uses many instance methods.
<span class=
"Apple-converted-space"> </span></p>
253 <p class=
"p3">Just pick any file to see all the parts of its path.
</p>
254 <p class=
"p6"><br></p>
255 <p class=
"p10">/*
</p>
257 <p class=
"p10">GetFileDialog.new(
</p>
258 <p class=
"p10"><span class=
"Apple-tab-span"> </span>{ arg ok, path;
<span class=
"Apple-converted-space"> </span></p>
259 <p class=
"p10"><span class=
"Apple-tab-span"> </span>var myPathName;
<span class=
"Apple-converted-space"> </span></p>
260 <p class=
"p10"><span class=
"Apple-tab-span"> </span>if (ok,
<span class=
"Apple-converted-space"> </span></p>
261 <p class=
"p10"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>{
<span class=
"Apple-converted-space"> </span></p>
262 <p class=
"p10"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span> myPathName = PathName.new(path);
<span class=
"Apple-converted-space"> </span></p>
263 <p class=
"p11"><span class=
"Apple-tab-span"> </span><span class=
"Apple-converted-space"> </span></p>
264 <p class=
"p10"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span> "New PathName object/ <span class="Apple-converted-space
"> </span>".postc;
</p>
265 <p class=
"p10"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span> myPathName.postln;
<span class=
"Apple-converted-space"> </span></p>
266 <p class=
"p11"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-converted-space"> </span></p>
267 <p class=
"p10"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span> "fileName only/ <span class="Apple-converted-space
"> </span>".postc;
</p>
268 <p class=
"p10"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span> myPathName.fileName.postln;
<span class=
"Apple-converted-space"> </span></p>
269 <p class=
"p11"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-converted-space"> </span></p>
270 <p class=
"p10"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span> "path up to file only/ <span class="Apple-converted-space
"> </span>".postc;
</p>
271 <p class=
"p10"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span> myPathName.pathOnly.postln;
<span class=
"Apple-converted-space"> </span></p>
272 <p class=
"p11"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></p>
273 <p class=
"p10"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span> "folder Name/ <span class="Apple-converted-space
"> </span>".postc;
</p>
274 <p class=
"p10"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span> myPathName.folderName.postln;
<span class=
"Apple-converted-space"> </span></p>
275 <p class=
"p10"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>}
</p>
276 <p class=
"p10"><span class=
"Apple-tab-span"> </span>)
</p>
277 <p class=
"p10"><span class=
"Apple-tab-span"> </span>}
</p>
280 <p class=
"p11"><br></p>
281 <p class=
"p11"><br></p>
282 <p class=
"p10">Choose a soundfile to put into the library,
<span class=
"Apple-converted-space"> </span></p>
283 <p class=
"p10">using its foldername and filename/
</p>
284 <p class=
"p11"><br></p>
286 <p class=
"p10">GetFileDialog.new(
</p>
287 <p class=
"p10"><span class=
"Apple-tab-span"> </span>{ arg ok, path;
<span class=
"Apple-converted-space"> </span></p>
288 <p class=
"p10"><span class=
"Apple-tab-span"> </span>var myPathName, myFile;
<span class=
"Apple-converted-space"> </span></p>
289 <p class=
"p10"><span class=
"Apple-tab-span"> </span>if (ok,
<span class=
"Apple-converted-space"> </span></p>
290 <p class=
"p10"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>{
<span class=
"Apple-converted-space"> </span></p>
291 <p class=
"p10"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>myPathName = PathName.new(path);
<span class=
"Apple-converted-space"> </span></p>
292 <p class=
"p11"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></p>
293 <p class=
"p10"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>// read your file from disk, e.g. a soundFile/
<span class=
"Apple-converted-space"> </span></p>
294 <p class=
"p11"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></p>
295 <p class=
"p10"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>myFile = SoundFile.new;
<span class=
"Apple-converted-space"> <span class=
"Apple-tab-span"> </span></span></p>
296 <p class=
"p10"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>if (myFile.readHeader(path),
<span class=
"Apple-converted-space"> </span></p>
297 <p class=
"p10"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>{
<span class=
"Apple-converted-space"> <span class=
"Apple-tab-span"> </span></span></p>
298 <p class=
"p10"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>Library.put(
</p>
299 <p class=
"p10"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>[ myPathName.folderName.asSymbol, myPathName.fileName.asSymbol ],
</p>
300 <p class=
"p10"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>myFile);
<span class=
"Apple-converted-space"> </span></p>
301 <p class=
"p10"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>(
"Check LibMenu/ " ++ myPathName.folderName ++
" please.").postln;
</p>
302 <p class=
"p10"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>},
<span class=
"Apple-converted-space"> </span></p>
303 <p class=
"p10"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>{ (
"Could not read soundfile " ++ path ++
".").postln; }
</p>
304 <p class=
"p10"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>);
</p>
305 <p class=
"p10"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>}
</p>
306 <p class=
"p10"><span class=
"Apple-tab-span"> </span>)
</p>
307 <p class=
"p10"><span class=
"Apple-tab-span"> </span>}
</p>
310 <p class=
"p11"><br></p>
311 <p class=
"p11"><br></p>
312 <p class=
"p10">Save three tables in the same folder:
</p>
313 <p class=
"p10"><span class=
"Apple-converted-space"> </span>Note: The file name chosen in the dialog is ignored!
</p>
314 <p class=
"p10"><span class=
"Apple-converted-space"> </span>The files are always named table1, table2, table3.
<span class=
"Apple-converted-space"> </span></p>
316 <p class=
"p10">var table1, table2, table3;
<span class=
"Apple-converted-space"> </span></p>
317 <p class=
"p11"><br></p>
318 <p class=
"p10">table1 = Wavetable.sineFill(
1024, [
1,
2,
3]);
</p>
319 <p class=
"p10">table2 = Signal.newClear.asWavetable;
</p>
320 <p class=
"p10">table3 = Wavetable.sineFill(
1024, Array.rand(
64,
0.0,
1.0));
</p>
321 <p class=
"p11"><br></p>
322 <p class=
"p10">PutFileDialog.new(
</p>
323 <p class=
"p10"><span class=
"Apple-tab-span"> </span>"Pick a folder for tables1-3/",
"table1",
</p>
324 <p class=
"p10"><span class=
"Apple-tab-span"> </span>{ arg ok, path;
<span class=
"Apple-converted-space"> </span></p>
325 <p class=
"p10"><span class=
"Apple-tab-span"> </span>var myPathName, myPathOnly;
<span class=
"Apple-converted-space"> </span></p>
326 <p class=
"p10"><span class=
"Apple-tab-span"> </span>if (ok,
<span class=
"Apple-converted-space"> </span></p>
327 <p class=
"p10"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>{
<span class=
"Apple-converted-space"> </span></p>
328 <p class=
"p10"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>myPathName = PathName.new(path);
<span class=
"Apple-converted-space"> </span></p>
329 <p class=
"p11"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></p>
330 <p class=
"p10"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>myPathOnly = myPathName.pathOnly;
<span class=
"Apple-converted-space"> </span></p>
331 <p class=
"p11"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></p>
332 <p class=
"p10"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>table1.write(myPathOnly ++
"table1");
</p>
333 <p class=
"p10"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>table2.write(myPathOnly ++
"table2");
</p>
334 <p class=
"p10"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>table3.write(myPathOnly ++
"table3");
</p>
335 <p class=
"p10"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>}
</p>
336 <p class=
"p10"><span class=
"Apple-tab-span"> </span>)
</p>
337 <p class=
"p10"><span class=
"Apple-tab-span"> </span>}
</p>
340 <p class=
"p11"><br></p>
341 <p class=
"p11"><br></p>
342 <p class=
"p10">*/
</p>
343 <p class=
"p6"><br></p>