Re: Re[2]: ?include? in jscript?

Date : Tue, 05 Feb 2008 13:06:54 +0100
To : XSI(at)Softimage.COM
From : Julien Stiegler <julien.stiegler(at)free.fr>
Subject : Re: Re[2]: ?include? in jscript?
here is a simple addon that i use to define a standard location for eveluated
external js scripts
http://animatic.no-ip.com/pub/dev/xsi/readExternalScript.xsiaddon

Selon Frank Lenhard <franky(at)ixdream.com>:

> that will be the 3rd method that i will try :)
> the other two, suggested in the thread, didnt worked for me.
> likely because of user error....
>
> meanwhile i switched to a proper editor outside of xsi, which makes
> life a LOT easier, when it comes to syntax errors and readability.
> just the quick search for commands and other xsi specifique stuff is
> gone. but meanwhile i spend more time writing code then readin the
> docs ;)
>
> ciao
> franky
>
>
> Monday, February 4, 2008, 8:54:18 PM, you wrote:
>
> HN> we use the file system object over here:
>
> HN> var fso = ActiveXObject("Scripting.FileSystemObject");
> HN> var f = fso.OpenTextFile( "//server/scripts/toinclude.js", ForReading );
> HN> var s = f.ReadAll();
> HN> eval(s);
> HN> s.Close();
>
> HN> The problem is it won't point out the right line in case of an error and
> HN> it's not really clean but it works.
>
> HN> On Feb 4, 2008 8:06 PM, Matt Lind <mlind(at)carbinestudios.com> wrote:
>
> >>  With a little preplanning, this is not really an issue.  There won't be
> >> namespace issues in JScript if you only put objects in an 'include' file.
> >> The namespace of the object will protect the object's methods and
> properties
> >> from becoming mangled.  If you have other functions that are called
> >> frequently, package them into an XSI command so you can call it whenever
> you
> >> want and not worry about 'include' files.
> >>
> >> Worst case scenario, you can put a small prefix in front of all variable
> >> names found in the 'include' file to avoid the namespace issue too.  eg:
> >> 'lib_name' and 'lib_type' istead of just 'name' and 'type'.
> >>
> >> Variable names don't have to be long to accomplish that feat.
> >>
> >>
> >> Matt
> >>
> >>  ------------------------------
> >> *From:* owner-xsi(at)Softimage.COM [mailto:owner-xsi(at)Softimage.COM] *On
> >> Behalf Of *Bradley Gabe
> >> *Sent:* Sunday, February 03, 2008 1:35 PM
> >>
> >> *To:* XSI(at)Softimage.COM
> >> *Subject:* Re: ?include? in jscript?
> >>
> >> It's all about name scope.
> >> Let's say in the body of your jscript you name a variable or function
> >> "foo", and then there is also a variable or function named "foo" in the
> file
> >> you include. Since jscript is copy/paste of text, your two foos are going
> to
> >> conflict and cause errors. Jscript can't tell the difference between your
> >> local foo and imported foo.
> >>
> >> In Python, when you import a file, all it's variables and functions are
> >> imported in the namespace of that file (very much like Model Space in
> XSI!).
> >> So if your file is named "myLib" then it's foo variable or function will
> be
> >> "myLib.foo".
> >>
> >> So for Jscript, if you intend to do any including, you *must* name all
> >> your variables and functions something likely to be unique. It forces
> >> annoyingly long variable and function names.
> >>
> >>
> >> On Feb 3, 2008 3:11 PM, Stephen Blair <Stephen_Blair(at)softimage.com> wrote:
> >>
> >> >  Yeah, like this you mean?
> >> >
> >> > <script type="text/javascript" src="../../doc/shared/utils.js"></script>
> >> >
> >> > How is the Python way object-oriented?
> >> >
> >> > The html way is pretty much just like #include in C++ or C.
> >> >
> >> >
> >> >
> >> >  ------------------------------
> >> > *From:* owner-xsi(at)Softimage.COM [mailto:owner-xsi(at)Softimage.COM] *On
> >> > Behalf Of *Bradley Gabe
> >> > *Sent:* Sun 03 February 2008 3:52 PM
> >> > *To:* XSI(at)Softimage.COM
> >> > *Subject:* Re: ?include? in jscript?
> >> >
> >> >   There *is* include in jscript if you are writing for netview.
> >> > However, it must be considered as literally cut and paste of text, it's
> >> > not an object oriented include the way it would be in Python.
> >> >
> >> > On Feb 3, 2008 7:42 AM, Stephen Blair <Stephen_Blair(at)softimage.com>
> >> > wrote:
> >> >
> >> > > Hi Franky
> >> > >
> >> > > There is no such feature in Jscript.
> >> > >
> >> > > Some people use eval. See "The Include() Function" section here:
> >> > > http://digivation.net/programming/registrytools
> >> > >
> >> > > Another approach (used by the SDK Wizards) is to have a custom object
> >> > > that provides features used by all the different wizards.
> >> > >
> >> > > So each wizard calls a command to create an instance of the helper
> >> > > object, and then calls methods on the helper object.
> >> > >
> >> > >
> >> > >
> >> > >
> >> > > // Steve
> >> > > // Team Lead, XSI Customer Support
> >> > > //
> >> > > // See the XSI wiki for KB articles, FAQs, and more...
> >> > > // softimage.wiki.avid.com/Category:Support
> >> > >
> >> > > -----Original Message-----
> >> > > From: owner-xsi(at)Softimage.COM [mailto:owner-xsi(at)Softimage.COM] On
> >> > > Behalf
> >> > > Of Frank Lenhard
> >> > > Sent: Sunday, February 03, 2008 8:36 AM
> >> > > To: XSI(at)Softimage.COM
> >> > > Subject: ?include? in jscript?
> >> > >
> >> > > Hi scripters,
> >> > >
> >> > > i dont know if something like i whish for exists in jscript. so far i
> >> > > didnt found any info.
> >> > >
> >> > > what i basically want is writing functions in ONE script and include
> >> > > that script with one nifty line like "include c:\1.jscript" into the
> >> > > current script and have all the functions declared in 1 available in
> >> > > script 2.
> >> > >
> >> > > would keep the scripting much eaasier to read and navigate, then to
> >> > > mess with thousands of lines of code.
> >> > >
> >> > >
> >> > > ciao
> >> > > franky
> >> > >
> >> > > ---
> >> > > Unsubscribe? Mail Majordomo(at)Softimage.COM with the following text in
> >> > > body:
> >> > > unsubscribe xsi
> >> > >
> >> > > ---
> >> > > Unsubscribe? Mail Majordomo(at)Softimage.COM with the following text in
> >> > > body:
> >> > > unsubscribe xsi
> >> > >
> >> >
> >> >
> >>
>
> ---
> Unsubscribe? Mail Majordomo(at)Softimage.COM with the following text in body:
> unsubscribe xsi
>


-- 
Julien Stiegler
Réalisation de film d'animation, vidéo interactive,
pré-production, post-prodution.
http://animatic.no-ip.com/cv.html

---
Unsubscribe? Mail Majordomo(at)Softimage.COM with the following text in body:
unsubscribe xsi


Search the XSI List archives here or use the advanced search form to search across mailing lists. Searching help is available.
This site supposedly brought to you by Benjamin Grosser and the Imaging Technology Group.