CreateVrmlFromString escape char 
Author Message
 CreateVrmlFromString escape char

I need to *copy* a small PROTO x number of time into an array.
The PROTO is declared on top of the file and I used EXTERNPROTO in the
function refering to the top DPoint PROTO.
But I get: # Error parsing '\' at line 49: invalid symbol...
Didnt find any reference that say backslash is illegal in this function.

Any ideas how to copy a PROTO with CreateVrmlFromString/URL?

DEF T Transform {}
DEF PointScript Script {
 field SFInt32 maxnumber 1000
 field SFNode  base USE T
 directOutput TRUE
 url "javascript:
 function initialize() {
  for(i=0; i<maxnumber; i++) {
   x = (Math.random()-0.5)* 100;
   y = (Math.random()-0.5)* 100;
   z = (Math.random()-0.5)* 100;
   base.children[i] = Browser.createVrmlFromString(
    "EXTERNPROTO DPoint [
    exposedField SFVec3f translation
    ] \"points02.wrl#DPoint\"
    DPoint { }"
   );
   base.children[i].translation = new SFVec3f(x, y, z);
  }
 }"

Quote:
}

Thanks in advance

Sylvain Carette
vrml designer-composer



Sat, 12 Oct 2002 03:00:00 GMT  
 CreateVrmlFromString escape char

Dear Sylvain,

I had about the same problem as you have. I fixed it like this: i declarered a wrl file with several EXTERNPROTO declarations (nothing else).
I copied this file to several other files e.g. (Note: this is Visual Basic)

    Copy "reference.wrl", "world1.wrl"
    Copy "reference.wrl", "world2.wrl"
    Copy "reference.wrl", "world3.wrl"

I don't know it is possible with javascript to copy files, but if you can't you can do it with a java.class file.

Another solution may be, is that you replace the \ with Chr(34) (also Vb) and put the strings together. I'm not sure about this (Chr(34) existing in javascript).
It could depend on the characterset choosen in the beginning of the VRML file like UTF8, .... Anyway 34 is the decimal equivalent of the double quote in ASCII.

I hope i helped a bit with this.

Greets,

Gerry


    I need to *copy* a small PROTO x number of time into an array.
    The PROTO is declared on top of the file and I used EXTERNPROTO in the function refering to the top DPoint PROTO.
    But I get: # Error parsing '\' at line 49: invalid symbol...
    Didnt find any reference that say backslash is illegal in this function.
    Any ideas how to copy a PROTO with CreateVrmlFromString/URL?
    DEF T Transform {}
    DEF PointScript Script {
     field SFInt32 maxnumber 1000
     field SFNode  base USE T
     directOutput TRUE
     url "javascript:
     function initialize() {
      for(i=0; i<maxnumber; i++) {
       x = (Math.random()-0.5)* 100;
       y = (Math.random()-0.5)* 100;
       z = (Math.random()-0.5)* 100;
       base.children[i] = Browser.createVrmlFromString(
        "EXTERNPROTO DPoint [
        exposedField SFVec3f translation
        ] \"points02.wrl#DPoint\"
        DPoint { }"
       );
       base.children[i].translation = new SFVec3f(x, y, z);
      }
     }"
    }
    Thanks in advance

    Sylvain Carette
    VRML designer-composer



Sat, 12 Oct 2002 03:00:00 GMT  
 CreateVrmlFromString escape char
Hi Sylvain,

Quote:
>I need to *copy* a small PROTO x number of time into an array.
>The PROTO is declared on top of the file and I used EXTERNPROTO in the

function >refering to the top DPoint PROTO.

If I understand you correctly you want get x _instances_ of the proto,
is that correct ?!

If yes, here's how I would do it
Please note the ' instead of ".

newstring = 'EXTERNPROTO DPoint [ '+
              ' exposedField SFVec3f translation '+
              ' ] \"points02.wrl#DPoint\"';

for(i=0;i<maxnumber;i++){
   x = (Math.random()-0.5)* 100;
   y = (Math.random()-0.5)* 100;
   z = (Math.random()-0.5)* 100;
  newstring += 'DPoint{ translation '+x+' '+y+' '+z+' } ';

Quote:
}

  newNode = new MFNode();
  newNode = Browser.createVrmlFromString(newstring);

  base.addChildren = newNode;

haven't tested these particular lines, but I do it all
the time, so it should work :-)

all the best,

Roland

.............................................................................

   Roland Praehofer - webdesign.sound.virtual_environments


   web:http://www.memeticdesign.de
   tel:+49 30 827 029 77
   fax:+49 30 827 029 78
.............................................................................

Quote:

> But I get: # Error parsing '\' at line 49: invalid symbol...
> Didnt find any reference that say backslash is illegal in this
> function.
> Any ideas how to copy a PROTO with CreateVrmlFromString/URL?

> DEF T Transform {}
> DEF PointScript Script {
>  field SFInt32 maxnumber 1000
>  field SFNode  base USE T
>  directOutput TRUE
>  url "javascript:
>  function initialize() {
>   for(i=0; i<maxnumber; i++) {
>    x = (Math.random()-0.5)* 100;
>    y = (Math.random()-0.5)* 100;
>    z = (Math.random()-0.5)* 100;
>    base.children[i] = Browser.createVrmlFromString(
>     "EXTERNPROTO DPoint [
>     exposedField SFVec3f translation
>     ] \"points02.wrl#DPoint\"
>     DPoint { }"
>    );
>    base.children[i].translation = new SFVec3f(x, y, z);
>   }
>  }"
> }
> Thanks in advance

> Sylvain Carette
> VRML designer-composer



Sat, 12 Oct 2002 03:00:00 GMT  
 CreateVrmlFromString escape char
Thx Roland and Gerry

Always feel anxious when I have to deal with strings........
Your solution Roland seem what I need and if you say you do it all the time I
feel more secure now... :-)

Sylvain Carette
VRML designer-composer

Quote:

> Hi Sylvain,

> >I need to *copy* a small PROTO x number of time into an array.
> >The PROTO is declared on top of the file and I used EXTERNPROTO in the
> function >refering to the top DPoint PROTO.

> If I understand you correctly you want get x _instances_ of the proto,
> is that correct ?!

> If yes, here's how I would do it
> Please note the ' instead of ".

> newstring = 'EXTERNPROTO DPoint [ '+
>               ' exposedField SFVec3f translation '+
>               ' ] \"points02.wrl#DPoint\"';

> for(i=0;i<maxnumber;i++){
>    x = (Math.random()-0.5)* 100;
>    y = (Math.random()-0.5)* 100;
>    z = (Math.random()-0.5)* 100;
>   newstring += 'DPoint{ translation '+x+' '+y+' '+z+' } ';
> }
>   newNode = new MFNode();
>   newNode = Browser.createVrmlFromString(newstring);

>   base.addChildren = newNode;

> haven't tested these particular lines, but I do it all
> the time, so it should work :-)

> all the best,

> Roland

> .............................................................................

>    Roland Praehofer - webdesign.sound.virtual_environments


>    web:http://www.memeticdesign.de
>    tel:+49 30 827 029 77
>    fax:+49 30 827 029 78
> .............................................................................


> > But I get: # Error parsing '\' at line 49: invalid symbol...
> > Didnt find any reference that say backslash is illegal in this
> > function.
> > Any ideas how to copy a PROTO with CreateVrmlFromString/URL?

> > DEF T Transform {}
> > DEF PointScript Script {
> >  field SFInt32 maxnumber 1000
> >  field SFNode  base USE T
> >  directOutput TRUE
> >  url "javascript:
> >  function initialize() {
> >   for(i=0; i<maxnumber; i++) {
> >    x = (Math.random()-0.5)* 100;
> >    y = (Math.random()-0.5)* 100;
> >    z = (Math.random()-0.5)* 100;
> >    base.children[i] = Browser.createVrmlFromString(
> >     "EXTERNPROTO DPoint [
> >     exposedField SFVec3f translation
> >     ] \"points02.wrl#DPoint\"
> >     DPoint { }"
> >    );
> >    base.children[i].translation = new SFVec3f(x, y, z);
> >   }
> >  }"
> > }
> > Thanks in advance

> > Sylvain Carette
> > VRML designer-composer



Sat, 12 Oct 2002 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. How NOT to interpret backslashes to escape chars.

2. problems escaping chars

3. send escape char with telnet

4. Can't escape special chars in regex.match

5. avoiding escaping chars in exec commands

6. Escape codes / printing a document with embedded escape codes

7. How to escape escape?

8. Expect script changing telnet escape using `set escape ^\` problem

9. Object comment do: [:char | char yourself]

10. reversing lines char by char, but not the line order in a file

11. How to read line char by char?

12. CHAR and [CHAR]

 

 
Powered by phpBB® Forum Software