From cycling at editions-ihs.com Sat Jan 5 02:57:44 2008 From: cycling at editions-ihs.com (Salvator) Date: Sat Jan 5 02:57:50 2008 Subject: [javascript-dev] Re: jsui border color In-Reply-To: <1e796.4774dbe1@www.cycling74.com> Message-ID: <1ea18.477f5497@www.cycling74.com> HI Joshua, Thanks, I finally got something working. function draw() { var width = box.rect[2] - box.rect[0]; var height = box.rect[3] - box.rect[1]; var aspect = width/height; with (sketch) { glclearcolor(myfrgb);// bg (color) glclear(); // kind of background glcolor(0,0,0); // FILL COLOR plane(aspect*0.98,0.90); // "FILL PLANE } } Though I'm a bit lost with those coordinate (+/-aspect & +/-1) and doing a plane by using percentage of the aspect and +/-1 value only work for certain resize (the horizontal and vertical border sometimes is not the same, depending of the sizebox). So I would prefer to have a value in pixel that is constant for both horizontal and vertical. Should I plunge into learning "sceentoworkld" and the like ? Should I use line drawing instad of plane ? Thanks, Salvator From apalomba at austin.rr.com Tue Jan 8 13:26:05 2008 From: apalomba at austin.rr.com (Anthony Palomba) Date: Tue Jan 8 13:26:07 2008 Subject: [javascript-dev] Declaring classes in javascript? Message-ID: <1eb65.4783dc5d@www.cycling74.com> I was wondering if there is a way to declare classes in javascript and instantiate them? Does anyone have an example that demonstrates this? Sorry for the cross post. Thanks, Anthony From jkc at musork.com Tue Jan 8 13:32:01 2008 From: jkc at musork.com (Joshua Kit Clayton) Date: Tue Jan 8 13:32:15 2008 Subject: [javascript-dev] Declaring classes in javascript? In-Reply-To: <1eb65.4783dc5d@www.cycling74.com> References: <1eb65.4783dc5d@www.cycling74.com> Message-ID: <1D27A296-1DAF-410D-B614-1C1371199A26@musork.com> On Jan 8, 2008, at 12:26 PM, Anthony Palomba wrote: > > I was wondering if there is a way to declare classes in javascript > and instantiate them? Does anyone have an example that demonstrates > this? Sorry for the cross post. http://www.webreference.com/js/column79/ found with a google on "object oriented programming in javascript" As for using classes or functions in other files, see the jitter utilities in C74:/jsextensions -Joshua From keithmanlove at gmail.com Tue Jan 8 20:52:51 2008 From: keithmanlove at gmail.com (keith manlove) Date: Tue Jan 8 20:52:54 2008 Subject: [javascript-dev] Declaring classes in javascript? In-Reply-To: <1eb65.4783dc5d@www.cycling74.com> References: <1eb65.4783dc5d@www.cycling74.com> Message-ID: <64ab801a0801081952q3c6175a5gc50ea519f1a807d1@mail.gmail.com> > I was wondering if there is a way to declare classes in javascript > and instantiate them? Does anyone have an example that demonstrates this? Sorry for the cross post. Dan Flanagan talks about this in depth in "Javascript: The Definitive Guide"; I really liked his explanation of it. Also, I noticed your austin.rr.com address... let me know if you need me to return UT's copy of it. I've had it checked out for a while. Keith From JLubow at alumnae.mills.edu Tue Jan 8 23:38:55 2008 From: JLubow at alumnae.mills.edu (jLubow) Date: Tue Jan 8 23:38:58 2008 Subject: [javascript-dev] gl orientation and "moving forward" Message-ID: <1eb8c.47846bfe@www.cycling74.com> hello, i'm sure this is obvious... apologies if so. i'm testing something out for a project (after a while from jsui) and just trying to rotate + 'move forward', but can't figure out what's going wrong... do i have to use jitter-js and import the jitter-utils? so far, i've got: _______________________________________ _______________________________________ sketch.default3d(); var origin = [0,0,0]; var length = 0.5; with(sketch){ glclearcolor(0,0,0); glclear(); glcolor(1,1,1); moveto(origin); line(0,length,0); //draw a line up w/ reg orient moveto(0,length,0); //move to line's end loc glrotate(90,0,0,1); //rotate 90 cw line(0,length,0); //draw another line w/ new orient??? } refresh(); _______________________________________ _______________________________________ thanks so much, jl From JLubow at alumnae.mills.edu Tue Jan 8 23:56:48 2008 From: JLubow at alumnae.mills.edu (jLubow) Date: Tue Jan 8 23:56:50 2008 Subject: [javascript-dev] Re: gl orientation and "moving forward" In-Reply-To: <1eb8c.47846bfe@www.cycling74.com> Message-ID: <1eb8d.47847030@www.cycling74.com> erps- what i meant to write rather than glrotate was shapeorient(0,0,90); anyway; the point is that i'm trying to change the orientation of the 'sketch perspective' could this be accomplished with gl command? thanks, jl From adamjmurray at gmail.com Wed Jan 9 00:08:28 2008 From: adamjmurray at gmail.com (Adam Murray) Date: Wed Jan 9 00:08:30 2008 Subject: [javascript-dev] Re: Classes/inheritance in javascript? In-Reply-To: <1eb57.4783bd38@www.cycling74.com> Message-ID: <1eb90.478472ea@www.cycling74.com> Hi Anthony, You can do this in javascript but it is pretty strange. Here's an example: ----- function Class() { this.member = "a member variable"; } Class.prototype.method = function() { post(this.member + " "); } instance = new Class(); instance.method(); ---- Javascript is a prototype-based langauge rather than a standard OO language. This means you define a constructor as a function, and attach methods to the class by assigning them to the constructor function's prototype property. Many attempts have been made to simulate standard OO inheritance in javascript. If that is something you are interested take a look at this: http://www.sitepoint.com/blogs/2006/01/17/javascript-inheritance/ I am not recommending this person's approach, but the blog post is good because it provides lots of links and discussions to alternate approaches. One of them may suit you. If you want to learn JavaScript better, I highly recommend the book "JavaScript The Definitive Guide" published by O'Reilly. It is by far the best javascript reference I have encountered. No online resources come close. -Adam Quote: Anthony Palomba wrote on Tue, 08 January 2008 10:13 ---------------------------------------------------- > I was wondering if there is a way to declare classes in javascript > and instantiate them? Does anyone have an example that demonstrates this? > > > Thanks, > Anthony ---------------------------------------------------- From jkc at musork.com Wed Jan 9 14:08:11 2008 From: jkc at musork.com (Joshua Kit Clayton) Date: Wed Jan 9 14:08:18 2008 Subject: [javascript-dev] Re: gl orientation and "moving forward" In-Reply-To: <1eb8d.47847030@www.cycling74.com> References: <1eb8d.47847030@www.cycling74.com> Message-ID: <7DD1F5A9-212A-4B50-B8EA-491ECB3C7478@musork.com> On Jan 8, 2008, at 10:56 PM, jLubow wrote: > erps- > what i meant to write rather than glrotate was > shapeorient(0,0,90); > > anyway; the point is that i'm trying to change the orientation of > the 'sketch perspective' > > could this be accomplished with gl command? Yes with gltranslate()/glrotate(). You won't accomplish it with moveto/shapeorient as these just affect the specific drawing primitives rather than the OpenGL state. Please see the Jitter sketch tutorial (40), and even better, the OpenGL RedBook for more information on how to transform the modelview matrix. Changes are you'll want to use glmatrixpush/glmatrixpop. Search jitter mailing list archives for more details. The commands in the JS Sketch class and jit.gl.sketch are essentially the same. -Joshua From JLubow at alumnae.mills.edu Wed Jan 9 15:24:52 2008 From: JLubow at alumnae.mills.edu (jLubow) Date: Wed Jan 9 15:24:54 2008 Subject: [javascript-dev] Re: Re: gl orientation and "moving forward" In-Reply-To: <7DD1F5A9-212A-4B50-B8EA-491ECB3C7478@musork.com> Message-ID: <1ec02.478549b4@www.cycling74.com> great. thank you joshua. jl From apalomba at austin.rr.com Wed Jan 16 16:12:14 2008 From: apalomba at austin.rr.com (Anthony Palomba) Date: Wed Jan 16 16:12:18 2008 Subject: [javascript-dev] creating jit.matrix in javascript... Message-ID: <1ee7f.478e8f4d@www.cycling74.com> I am trying to create a jit.matrix in javascript and then connect it to a jit.gl.render. It looks like I am creating everything but my matrix does not show up in my jit.window. I think the problem is that I am not connecting my matrix to my jit.gl.render. How exactly do I do this from javascript? my javascript, plasma.js... // create our window var window = new JitterObject("jit.window","testwindow"); window.depthbuffer = 1; window.idlemouse = 1; // create our render object for our window var render = new JitterObject("jit.gl.render","testwindow"); //render.ortho = 2; //2d mode // create our matrix var draw_matrix = new JitterObject("jit.matrix", 4, "float32", 256, 256); draw_matrix.exprfill("hypot(norm[0]-0.5\,norm[1]-0.5)"); var mousedown = 0; // create our listener object for our window var mylistener = new JitterListener("testwindow",callbackfun); function callbackfun(event) { var x,y,button; if (event.eventname=="mouse") { // arguments are (x,y,button,cmd,shift,capslock,option,ctrl) x = event.args[0]; y = event.args[1]; button = event.args[2]; mousedown = button; } else if (event.eventname=="mouseidle") { x = event.args[0]; y = event.args[1]; } //post("callback: " + event.subjectname + " sent "+ event.eventname + " with (" + event.args + ") "); } callbackfun.local = 1; function bang() { if (mousedown) render.depth_clear(); // note that else render.erase(); draw_matrix.bang; render.drawclients(); render.swap(); } my patch... #P window setfont "Sans Serif" 9.; #P window linecount 1; #P message 102 133 40 9109513 compile; #P number 87 82 35 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0; #P toggle 42 81 15 0; #P newex 42 106 55 9109513 qmetro 20; #P newex 42 161 58 9109513 js plasma.js; #P comment 156 166 234 9109513 example of listening to a window for window events; #P connect 4 0 2 1; #P connect 2 0 1 0; #P connect 5 0 1 0; #P connect 3 0 2 0; #P window clipboard copycount 6; From jackwphillips at gmail.com Wed Jan 16 21:50:10 2008 From: jackwphillips at gmail.com (Jack Phillips) Date: Wed Jan 16 21:50:20 2008 Subject: [javascript-dev] creating jit.matrix in javascript... In-Reply-To: <1ee7f.478e8f4d@www.cycling74.com> References: <1ee7f.478e8f4d@www.cycling74.com> Message-ID: If I understand you correctly, you're trying to display the contents of matrix in a window. I think there are (at least) two ways to do this. 1) Using jit.render.draw_pixels method //jit.window var windowTitle = "Window Title"; var window = new JitterObject("jit.window", windowTitle); //jit.gl.render var renderer = new JitterObject("jit.gl.render", windowTitle); //create a matrix var matrix1 = new JitterMatrix(4, "char", 10, 10); //for draw_pixels, must be 4-plane char (I think) //create noise to fill matrix var noise = new JitterObject("jit.noise"); noise.dim = [10, 10]; noise.planecount = 4; noise.type = "char"; //fill matrix with random values noise.matrixcalc(matrix1, matrix1); function bang() { //drawing call renderer.erase(); renderer.draw_pixels(matrix1.name); renderer.swap(); } 2) Use jit.gl.videoplane //jit.window var windowTitle = "Window Title"; var window = new JitterObject("jit.window", windowTitle); //jit.gl.render var renderer = new JitterObject("jit.gl.render", windowTitle); //create a matrix var matrix1 = new JitterMatrix(1, "float32", 10, 10); //for videoplane, can be any kind //create noise to fill matrix var noise = new JitterObject("jit.noise"); noise.dim = [10, 10]; noise.planecount = 1; noise.type = "float32"; //fill matrix with random values noise.matrixcalc(matrix1, matrix1); //create jit.gl.videoplane var videoplane = JitterObject("jit.gl.videoplane", windowTitle); videoplane.interp = 0; //or else you get interp, default = 1 function bang() { videoplane.jit_matrix(matrix1.name); //drawing call renderer.erase(); renderer.drawclients(); renderer.swap(); } Hope this helps. jp On Jan 16, 2008, at 4:12 PM, Anthony Palomba wrote: > > I am trying to create a jit.matrix in javascript and > then connect it to a jit.gl.render. It looks like I > am creating everything but my matrix does not show up > in my jit.window. I think the problem is that I am not > connecting my matrix to my jit.gl.render. How exactly > do I do this from javascript? > > > my javascript, plasma.js... > > // create our window > var window = new JitterObject("jit.window","testwindow"); > window.depthbuffer = 1; > window.idlemouse = 1; > > // create our render object for our window > var render = new JitterObject("jit.gl.render","testwindow"); > //render.ortho = 2; //2d mode > > // create our matrix > var draw_matrix = new JitterObject("jit.matrix", 4, "float32", 256, > 256); > draw_matrix.exprfill("hypot(norm[0]-0.5\,norm[1]-0.5)"); > > > var mousedown = 0; > > // create our listener object for our window > var mylistener = new JitterListener("testwindow",callbackfun); > > function callbackfun(event) > { > var x,y,button; > > if (event.eventname=="mouse") > { > // arguments are (x,y,button,cmd,shift,capslock,option,ctrl) > x = event.args[0]; > y = event.args[1]; > button = event.args[2]; > mousedown = button; > } > else if (event.eventname=="mouseidle") > { > x = event.args[0]; > y = event.args[1]; > } > //post("callback: " + event.subjectname + " sent "+ event.eventname > + " with (" + event.args + ") > "); > } > callbackfun.local = 1; > > function bang() > { > if (mousedown) > render.depth_clear(); // note that > else > render.erase(); > > draw_matrix.bang; > render.drawclients(); > render.swap(); > } > > > > > my patch... > > #P window setfont "Sans Serif" 9.; > #P window linecount 1; > #P message 102 133 40 9109513 compile; > #P number 87 82 35 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0; > #P toggle 42 81 15 0; > #P newex 42 106 55 9109513 qmetro 20; > #P newex 42 161 58 9109513 js plasma.js; > #P comment 156 166 234 9109513 example of listening to a window for > window events; > #P connect 4 0 2 1; > #P connect 2 0 1 0; > #P connect 5 0 1 0; > #P connect 3 0 2 0; > #P window clipboard copycount 6; > > > > > _______________________________________________ > javascript-dev mailing list > javascript-dev@cycling74.com > http://www.cycling74.com/mailman/listinfo/javascript-dev From pplato at gmail.com Thu Jan 17 11:31:26 2008 From: pplato at gmail.com (Jean-Baptiste Thiebaut) Date: Thu Jan 17 11:31:33 2008 Subject: [javascript-dev] creating a buffer~ object in javascript Message-ID: <1eec8.478f9efe@www.cycling74.com> Hi, I created a buffer in a patcher, called buf, which I'd like to manipulate in a jsui. I am not sure of the syntax I should use. Can anyone point me what I'm doing wrong in what follows? var _buf= new Maxobj("buffer~", "buf"); _buf.message("clear"); // here I'd like to clear the buffer. I assumed that doing _buf.clear() would work but I had an error _buf.channel = 1; for (var i = 0 ; i < 100 ; i++) _buf[i] = -1; // my buffer has 4 channels, I want to write data in the first channel from my jsui file Thanks jean-Baptiste From apalomba at austin.rr.com Fri Jan 18 09:32:17 2008 From: apalomba at austin.rr.com (Anthony Palomba) Date: Fri Jan 18 09:32:18 2008 Subject: [javascript-dev] Re: creating jit.matrix in javascript... In-Reply-To: Message-ID: <1ef41.4790d491@www.cycling74.com> That worked! Thanks. From bthrew at gmail.com Mon Jan 21 08:48:17 2008 From: bthrew at gmail.com (barry threw) Date: Mon Jan 21 08:48:23 2008 Subject: [javascript-dev] creating a buffer~ object in javascript In-Reply-To: <1eec8.478f9efe@www.cycling74.com> References: <1eec8.478f9efe@www.cycling74.com> Message-ID: <5AD7D1CD-0B03-49BA-8E05-DCB6329D09AB@gmail.com> Can't create a buffer~ in JS. :( No MSP. b On Jan 17, 2008, at 10:31 AM, Jean-Baptiste Thiebaut wrote: > > Hi, > > I created a buffer in a patcher, called buf, which I'd like to > manipulate in a jsui. I am not sure of the syntax I should use. Can > anyone point me what I'm doing wrong in what follows? > > var _buf= new Maxobj("buffer~", "buf"); > > > _buf.message("clear"); // here I'd like to clear the buffer. I > assumed that doing _buf.clear() would work but I had an error > > _buf.channel = 1; > > for (var i = 0 ; i < 100 ; i++) > _buf[i] = -1; // my buffer has 4 channels, I want to write data in > the first channel from my jsui file > > Thanks > > jean-Baptiste > _______________________________________________ > javascript-dev mailing list > javascript-dev@cycling74.com > http://www.cycling74.com/mailman/listinfo/javascript-dev -- Barry Threw Media Art and Technology San Francisco, CA Work: 857-544-3967 Email: bthrew (at) gmail (dot) com IM: captogreadmore (AIM) http://www.barrythrew.com "The greatest of the changes that science has brought us is the acuity of change; the greatest novelty the extent of novelty." - J. Robert Oppenheimer From pplato at gmail.com Mon Jan 21 09:02:09 2008 From: pplato at gmail.com (Jean-Baptiste Thiebaut) Date: Mon Jan 21 09:02:11 2008 Subject: [javascript-dev] Re: creating a buffer~ object in javascript In-Reply-To: <5AD7D1CD-0B03-49BA-8E05-DCB6329D09AB@gmail.com> Message-ID: <1f019.4794c201@www.cycling74.com> Thanks Barry. C74 devs, any chance that we could manipulate MSP objects with JS? best JB From pplato at gmail.com Mon Jan 21 11:01:24 2008 From: pplato at gmail.com (Jean-Baptiste Thiebaut) Date: Mon Jan 21 11:01:29 2008 Subject: [javascript-dev] creating files problem in a standalone Message-ID: <1f029.4794ddf4@www.cycling74.com> Hi, I'm using the code below to save data in a file. This works well as long as I'm working with Max, but it doesn't write in the file when I run the standalone program. I am able to read the file though. In the code below, I'm posting a message if the system cannot open the file. I never get this message on the console, so I presume that the standalone can create or open the file, but maybe only in read mode? In fact, the data stored in these file can be read but cannot be changed in the standalone version of my program. Thanks for your help. Jean-Baptiste function save(n) { var cpt = n%8; var f = new File("bkp"+cpt,"readwrite"); var s = new Array(4); if (f.isopen) { f.writefloat32(Math.PI); f.close(); post(" The file ",f.foldername,f.filename,"has beed saved"); } else { post("could not create file: ",f , " "); } } From c74-mailinglists at e--j.com Mon Jan 21 16:27:39 2008 From: c74-mailinglists at e--j.com (Emmanuel Jourdan) Date: Mon Jan 21 16:27:51 2008 Subject: [javascript-dev] creating files problem in a standalone In-Reply-To: <1f029.4794ddf4@www.cycling74.com> References: <1f029.4794ddf4@www.cycling74.com> Message-ID: <44B23FE3-9B9A-4D81-9B5B-0A21D92B4FC9@e--j.com> On 21 janv. 08, at 19:01, Jean-Baptiste Thiebaut wrote: > Hi, > > I'm using the code below to save data in a file. This works well as > long as I'm working with Max, but it doesn't write in the file when > I run the standalone program. I am able to read the file though. > In the code below, I'm posting a message if the system cannot open > the file. I never get this message on the console, so I presume that > the standalone can create or open the file, but maybe only in read > mode? In fact, the data stored in these file can be read but cannot > be changed in the standalone version of my program. Hi, The save() method is called when you save the patch, which, AFAIK, is something which is not possible in a standalone. You may have to use other strategy to trigger the writing mechanism of your file. HTH, ej From pplato at gmail.com Mon Jan 21 16:46:24 2008 From: pplato at gmail.com (Jean-Baptiste Thiebaut) Date: Mon Jan 21 16:46:30 2008 Subject: [javascript-dev] Re: creating files problem in a standalone In-Reply-To: <44B23FE3-9B9A-4D81-9B5B-0A21D92B4FC9@e--j.com> Message-ID: <1f04f.47952ecf@www.cycling74.com> Hey Emmanuel, thanks for your answer. Is there a save() method called when the program is closed? I just called this function "save" without guessing it could be a reserved word. I'll try to change the name. I'll let you know if it works. JB From garton at columbia.edu Mon Jan 21 16:50:58 2008 From: garton at columbia.edu (Brad Garton) Date: Mon Jan 21 16:51:22 2008 Subject: [javascript-dev] jsui flicker Message-ID: Hey gang -- I'm doing some operations where I'm encountering flickering in the jsui sketch window. Is there a way to enable double-buffering for it? If I set up two separate sketch objects and somehow toggled between them with each refresh() would that possibly work? OSX 10.4.11, Intel MaBook, MaxMSP 4.6.3, setting up the sketch object with sketch.default2d(). brad http://music.columbia.edu/~brad From c74-mailinglists at e--j.com Mon Jan 21 17:03:33 2008 From: c74-mailinglists at e--j.com (Emmanuel Jourdan) Date: Mon Jan 21 17:03:52 2008 Subject: [javascript-dev] Re: creating files problem in a standalone In-Reply-To: <1f04f.47952ecf@www.cycling74.com> References: <1f04f.47952ecf@www.cycling74.com> Message-ID: <61D15DC3-2809-4137-BCF3-E0A31C9604C7@e--j.com> On 22 janv. 08, at 00:46, Jean-Baptiste Thiebaut wrote: > Hey Emmanuel, > > thanks for your answer. > Is there a save() method called when the program is closed? I just > called this function "save" without guessing it could be a reserved > word. I'll try to change the name. I'll let you know if it works. Nope, it's called when the patch is saved (p11 in JavascriptInMax.pdf). Cheers, ej From c74-mailinglists at e--j.com Mon Jan 21 17:06:09 2008 From: c74-mailinglists at e--j.com (Emmanuel Jourdan) Date: Mon Jan 21 17:06:18 2008 Subject: [javascript-dev] Re: creating a buffer~ object in javascript In-Reply-To: <1f019.4794c201@www.cycling74.com> References: <1f019.4794c201@www.cycling74.com> Message-ID: On 21 janv. 08, at 17:02, Jean-Baptiste Thiebaut wrote: > Thanks Barry. > > C74 devs, any chance that we could manipulate MSP objects with JS? In the meantime, you can use java do achieve that. It's almost as simple as JS for those kinda things. Have a look to the buf.Op object, or to the lists objects in the ejies if you want some examples. Cheers, ej From pplato at gmail.com Tue Jan 22 00:55:56 2008 From: pplato at gmail.com (Jean-Baptiste Thiebaut) Date: Tue Jan 22 00:55:58 2008 Subject: [javascript-dev] Re: Re: creating files problem in a standalone In-Reply-To: <61D15DC3-2809-4137-BCF3-E0A31C9604C7@e--j.com> Message-ID: <1f06d.4795a18b@www.cycling74.com> I changed the name of my function to "_save()" and the same problem occurs: the data can not be saved when the function is called from a standalone, while it works when it is called from Max. I'm not too sure where the file would be created though. When the function is called from Max, the file is created in the same folder that contains the JS file. Within a standalone in Mac OS, where should the file be created anyway? From c74-mailinglists at e--j.com Tue Jan 22 01:15:21 2008 From: c74-mailinglists at e--j.com (Emmanuel Jourdan) Date: Tue Jan 22 01:16:34 2008 Subject: [javascript-dev] Re: Re: creating files problem in a standalone In-Reply-To: <1f06d.4795a18b@www.cycling74.com> References: <1f06d.4795a18b@www.cycling74.com> Message-ID: On 22 janv. 08, at 08:55, Jean-Baptiste Thiebaut wrote: > I changed the name of my function to "_save()" and the same problem > occurs: the data can not be saved when the function is called from a > standalone, while it works when it is called from Max. > > I'm not too sure where the file would be created though. When the > function is called from Max, the file is created in the same folder > that contains the JS file. Within a standalone in Mac OS, where > should the file be created anyway? Can you try to provide an absoulte path to your File object? You may use the max.apppath property to find where the standalone is. ej From pplato at gmail.com Tue Jan 22 05:42:45 2008 From: pplato at gmail.com (Jean-Baptiste Thiebaut) Date: Tue Jan 22 05:42:47 2008 Subject: [javascript-dev] Re: Re: Re: creating files problem in a standalone In-Reply-To: Message-ID: <1f07a.4795e4c4@www.cycling74.com> Quote: Emmanuel Jourdan wrote on Tue, 22 January 2008 08:15 ---------------------------------------------------- > On 22 janv. 08, at 08:55, Jean-Baptiste Thiebaut wrote: > > > I changed the name of my function to "_save()" and the same problem > > occurs: the data can not be saved when the function is called from a > > standalone, while it works when it is called from Max. > > > > I'm not too sure where the file would be created though. When the > > function is called from Max, the file is created in the same folder > > that contains the JS file. Within a standalone in Mac OS, where > > should the file be created anyway? > > Can you try to provide an absoulte path to your File object? You may > use the max.apppath property to find where the standalone is. > > ej > > ---------------------------------------------------- Trying this, I had another unexpected error: function _save(n) { var f = new File("bkp","readwrite"); f.foldername = max.apppath; //this makes the both max and the standalone crash } From pplato at gmail.com Tue Jan 22 05:47:13 2008 From: pplato at gmail.com (Jean-Baptiste Thiebaut) Date: Tue Jan 22 05:47:18 2008 Subject: [javascript-dev] Re: Re: Re: creating files problem in a standalone In-Reply-To: <1f07a.4795e4c4@www.cycling74.com> Message-ID: <1f07b.4795e5d0@www.cycling74.com> > ---------------------------------------------------- > > Trying this, I had another unexpected error: > > function _save(n) > { > > var f = new File("bkp","readwrite"); > f.foldername = max.apppath; //this makes the both max and the standalone crash > } my mistake. f.foldername has no set method... From apalomba at austin.rr.com Wed Jan 23 12:48:11 2008 From: apalomba at austin.rr.com (Anthony Palomba) Date: Wed Jan 23 12:48:19 2008 Subject: [javascript-dev] String.search problem... Message-ID: <1f0c9.479799e2@www.cycling74.com> I am trying to process the lines of a file using "readline". I have pasted my code below. For some reason when I call the method string "search", I get the following error... • error: js: (null): Javascript SyntaxError: unterminated character class , line 0 • error: js: error calling function Test For the life of me, I can not figure this one out. I know search is a method that exists because I have called it before with no problems. Anyone have any ideas? // inlets and outlets inlets = 1; outlets = 1; var IniFile = null; function Test(filename) { if(IniFile != null) { IniFile.close(); IniFile = null; } IniFile = new File(filename, "read"); if(IniFile.isopen == false) { post("FileIO Error: could not open file. "); return; } else post("file open. "); var OutputStr = ""; IniFile.position = 0; post("IniFile.position = " + IniFile.position + " "); post("IniFile.eof = " + IniFile.eof + " "); var Result = 0; var Line = ""; while(IniFile.position != IniFile.eof) { Line = IniFile.readline (256); post("input: " + Line + " "); Result = Line.search("["); post("search done... "); if(Result != -1) { // remove section delimiters. Line.replace("[", ""); Line.replace("]", ""); OutputStr += Line + " "; } } outlet(0, OutputStr); } From pdelges at radiantslab.com Wed Jan 23 14:34:16 2008 From: pdelges at radiantslab.com (Patrick Delges) Date: Wed Jan 23 14:34:20 2008 Subject: [javascript-dev] String.search problem... In-Reply-To: <1f0c9.479799e2@www.cycling74.com> References: <1f0c9.479799e2@www.cycling74.com> Message-ID: On 23-janv.-08, at 20:48, Anthony Palomba wrote: > For the life of me, I can not figure this one out. I know > search is a method that exists because I have called > it before with no problems. Anyone have any ideas? I can't test your code now, but afaik, String.search() expects a regular expression as argument, but "[" doesn't look like a RE. p _____________________________ Patrick Delges Centre de Recherches et de Formation Musicales de Wallonie http://www.crfmw.be/max From jkc at musork.com Wed Jan 23 15:07:57 2008 From: jkc at musork.com (Joshua Kit Clayton) Date: Wed Jan 23 15:08:04 2008 Subject: [javascript-dev] String.search problem... In-Reply-To: References: <1f0c9.479799e2@www.cycling74.com> Message-ID: On Jan 23, 2008, at 1:34 PM, Patrick Delges wrote: > > On 23-janv.-08, at 20:48, Anthony Palomba wrote: > >> For the life of me, I can not figure this one out. I know >> search is a method that exists because I have called >> it before with no problems. Anyone have any ideas? > > I can't test your code now, but afaik, String.search() expects a > regular expression as argument, but "[" doesn't look like a RE. It also might be related to the generally known, but harmless error reported when using regular expression objects in JS. -Joshua From apalomba at austin.rr.com Wed Jan 23 16:45:02 2008 From: apalomba at austin.rr.com (Anthony Palomba) Date: Wed Jan 23 16:45:04 2008 Subject: [javascript-dev] Re: String.search problem... In-Reply-To: Message-ID: <1f0dd.4797d17e@www.cycling74.com> String.search takes a string and searches it for a specified substring. It returns -1 or the index of the beginning of that substring. I am pretty sure this works. From c74-mailinglists at e--j.com Wed Jan 23 16:49:50 2008 From: c74-mailinglists at e--j.com (Emmanuel Jourdan) Date: Wed Jan 23 16:50:00 2008 Subject: [javascript-dev] Re: String.search problem... In-Reply-To: <1f0dd.4797d17e@www.cycling74.com> References: <1f0dd.4797d17e@www.cycling74.com> Message-ID: <60C27758-8E49-4870-9ED9-2ECA240F7364@e--j.com> On 24 janv. 08, at 00:45, Anthony Palomba wrote: > String.search takes a string and searches it for a > specified substring. It returns -1 or the index of the > beginning of that substring. I am pretty sure this works. I use it in ej.function, and it works fine. ej From jkc at musork.com Wed Jan 23 16:54:01 2008 From: jkc at musork.com (Joshua Kit Clayton) Date: Wed Jan 23 16:54:10 2008 Subject: [javascript-dev] Re: String.search problem... In-Reply-To: <1f0dd.4797d17e@www.cycling74.com> References: <1f0dd.4797d17e@www.cycling74.com> Message-ID: On Jan 23, 2008, at 3:45 PM, Anthony Palomba wrote: > > String.search takes a string and searches it for a > specified substring. It returns -1 or the index of the > beginning of that substring. I am pretty sure this works. Your error message would suggest it thinks "[" is the beginning of a regexp charset. So for ordinary strings maybe this is true since they are the same as their representation as a regular expression. Try using "\[" and "\]" --i.e. backslash to escape the brackets... Let us know what you find. -Joshua From jkc at musork.com Wed Jan 23 16:57:44 2008 From: jkc at musork.com (Joshua Kit Clayton) Date: Wed Jan 23 16:57:54 2008 Subject: [javascript-dev] Re: String.search problem... In-Reply-To: <1f0dd.4797d17e@www.cycling74.com> References: <1f0dd.4797d17e@www.cycling74.com> Message-ID: <25631426-8D03-4533-880B-8F23C05AD2D0@musork.com> Btw, the definitive source: http://developer.mozilla.org/en/docs/ Core_JavaScript_1.5_Reference:Objects:String:search It is a regular expression. So you definitely need to escape brackets and the like. -Joshua From apalomba at austin.rr.com Wed Jan 23 17:02:33 2008 From: apalomba at austin.rr.com (Anthony Palomba) Date: Wed Jan 23 17:02:42 2008 Subject: [javascript-dev] Re: Re: String.search problem... In-Reply-To: <25631426-8D03-4533-880B-8F23C05AD2D0@musork.com> Message-ID: <1f0e4.4797d599@www.cycling74.com> I was referencing this... http://www.w3schools.com/jsref/jsref_search.asp Is this a bad source? From jkc at musork.com Wed Jan 23 17:08:04 2008 From: jkc at musork.com (Joshua Kit Clayton) Date: Wed Jan 23 17:08:09 2008 Subject: [javascript-dev] Re: Re: String.search problem... In-Reply-To: <1f0e4.4797d599@www.cycling74.com> References: <1f0e4.4797d599@www.cycling74.com> Message-ID: <4B902DCB-1227-4FE7-BC88-23E8919D0859@musork.com> On Jan 23, 2008, at 4:02 PM, Anthony Palomba wrote: > > I was referencing this... > http://www.w3schools.com/jsref/jsref_search.asp > > Is this a bad source? Well it would appear that this isn't the way it works in JS 1.5 (may have been the case in previous versions, or they may be glossing over regexp behavior). Core Javascript book and mozilla site I sent in my last message are highly recommended -Joshua From apalomba at austin.rr.com Thu Jan 24 09:34:05 2008 From: apalomba at austin.rr.com (Anthony Palomba) Date: Thu Jan 24 09:34:07 2008 Subject: [javascript-dev] Re: Re: Re: String.search problem... In-Reply-To: <4B902DCB-1227-4FE7-BC88-23E8919D0859@musork.com> Message-ID: <1f113.4798bdfd@www.cycling74.com> I went ahead and treated it as a regular expression. Line.search("[/[]") does the trick. Thanks for helping me track this one down. From pplato at gmail.com Tue Jan 29 10:58:04 2008 From: pplato at gmail.com (Jean-Baptiste Thiebaut) Date: Tue Jan 29 10:58:45 2008 Subject: [javascript-dev] Re: Re: Re: creating files problem in a standalone In-Reply-To: <1f07b.4795e5d0@www.cycling74.com> Message-ID: <1f23d.479f692b@www.cycling74.com> Hi, I'm a bit desperate to get this working. The function below save a file while I'm running Max but doesn't when I'm running the standalone. But, more strange, while running the standalone, the file is opened (I have a message on the console) but the file is not written on the disk. I've checked everywhere and the file is not created, although the condition "f.isopen" is satisfied. function _save(n) { var f = new File("bkp","readwrite"); if (f.isopen) { f.writefloat32(3.14159); f.close(); post(" the file has been saved"); } else post("could not create file: ",f , " "); } Any idea? Thanks JB From pplato at gmail.com Tue Jan 29 12:02:01 2008 From: pplato at gmail.com (Jean-Baptiste Thiebaut) Date: Tue Jan 29 12:02:07 2008 Subject: [javascript-dev] Re: Re: Re: creating files problem in a standalone In-Reply-To: <1f23d.479f692b@www.cycling74.com> Message-ID: <1f242.479f7829@www.cycling74.com> It seems that the problem is elsewhere. Please don't waste your time on this, I'll let you know what I've done wrong :) From pplato at gmail.com Wed Jan 30 01:42:54 2008 From: pplato at gmail.com (Jean-Baptiste Thiebaut) Date: Wed Jan 30 01:42:57 2008 Subject: [javascript-dev] Re: Re: Re: creating files problem in a standalone (problem solved!) In-Reply-To: <1f242.479f7829@www.cycling74.com> Message-ID: <1f267.47a0388e@www.cycling74.com> Hi, I finally solved the problem. We apparently can't modify a file that has been included in the standalone package. To give you an example, I have been including a number of files, called "bkp0", "bkp1", and so on, in my standalone so the files could be used by the programs. My app allows to modify these files. When these are stored within the program package I can't modify them, so I guess that it forces the file to be opened as "read" instead of "readwrite", for instance. The solution was to remove the files before creating the standalone so that they would not be included, then add them manually at the same level as the application. The files can then be modified. Cool. For those who used my program Pompiloop and reported about this bug, this is now fixed and should be online sometime today at http://www.pompiloop.com/ Jean-Baptiste From c74-mailinglists at e--j.com Wed Jan 30 03:15:04 2008 From: c74-mailinglists at e--j.com (Emmanuel Jourdan) Date: Wed Jan 30 03:15:28 2008 Subject: [javascript-dev] Re: Re: Re: creating files problem in a standalone (problem solved!) In-Reply-To: <1f267.47a0388e@www.cycling74.com> References: <1f267.47a0388e@www.cycling74.com> Message-ID: On 30 janv. 08, at 09:42, Jean-Baptiste Thiebaut wrote: > > Hi, > > I finally solved the problem. We apparently can't modify a file that > has been included in the standalone package. > > To give you an example, I have been including a number of files, > called "bkp0", "bkp1", and so on, in my standalone so the files > could be used by the programs. My app allows to modify these files. > When these are stored within the program package I can't modify > them, so I guess that it forces the file to be opened as "read" > instead of "readwrite", for instance. > > The solution was to remove the files before creating the standalone > so that they would not be included, then add them manually at the > same level as the application. The files can then be modified. I can confirm the behavior. Thanks for the report. ej