[Javascript] Object Not Defined

Troy III Ajnej trojani2000 at hotmail.com
Mon Nov 21 12:42:11 CST 2011


*It was a joke. Although, to tell you the truthI wasn't planing to share it before publishing anyway.I've paid for some web space since June and was aimingto put some of these scripts up there soon, but time lapsed and I even forgot my password.
But since you are the first one to approach this problemin intelligent way...To emphasize :: Your approach impliesguesswork. And guesswork is one step deeper into, what we call, AI.But relying on existing methods, current practice & experienceof ECMA scripting world, right now, it's practically impossible.
(Being able to inspect your guess, find out if it exists and makeuse of some presumed resource of a certain kind, is intelligence).

Right now you are restricting yourself into only gettingwhat you need and substitute its absence. But soon you will be ableto think backwards :) [code retroactively]; "I will create a Title for this content only if a given content structure implies one. Therefore, if the title is declared, I will create a title element,if not, the kind of this content doesn't need a title, but if the title is undefined\empty\left blank or so, I will substitute it withsay "Untitled"; etc., etc."

I've written this because I know there is no such method in existenceand was never written before. And because I like and I need intelligentcoding methods.
In fact you'll need its "isDefined" sibling which I modified to returnthe actual value (when present) instead of a Boolean, so that a positiveguess will contain actual data instead. That is, instead of: "yes, me doez haz teh codez", to say: "here iz teh codez"
---------------------------------------------------------------------/* b.b. Troy III  p.a.e. */isDefined=function(x){try{return eval(x)}catch(e){return!1}}---------------------------------------------------------------------[I lied, only 60 bytes here]
And here is a ready method to handle it practically: ---------------------------------------------------------------------/* b.b. Troy III  p.a.e. */readFrom=function(x,y){return isDefined(x)||y}---------------------------------------------------------------------
and an example of using it to assign the requested value onto a temporary variable name:---------------------------------------------------------------------title=readFrom("a.b.c.d.e.f.g.h.i.j.k.title", "untitled");alert(title);
//and of course, title.innerText=readFrom("a.b.c.d.e.f.g.h.i.j.k.title", "untitled");//is also possible!
---------------------------------------------------------------------!The second argument is optional. Should be omitted when testing if thereadFrom contains data\was successful; like for example:
alert( !!readFrom( "a.b.c.title")  ) // --> true:false

To further it on;*Might be a good practice deleting the temporary "title" variable, as soon as you're done using it. Sort of prevent yourself from using aprevious read for current title if something went wrong with a new assignment.
---------------------------------------------------------------------delete title;alert( isDefined('title') ) //will return "false"//meaning, don't declare this kind variable pointers.//otherwise deletion attempt will cause an error.------------------------------------
Possible values for variable name cases are: 1.value; 2.undefined; 3.false.Meanings:1. the variable has the actual value;2. the variable name is initialized & permanent;3. the variable name doesn't exist.

For object properties (1st level depth) possible values shrink back to 1,2.Etc, etc ..., but we can discuss these some other time.

Have fun. 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                Troy III
       progressive art enterprise
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

> From: riegel at clearimageonline.com
> Date: Mon, 21 Nov 2011 09:25:23 -0500
> To: javascript at lists.evolt.org
> Subject: Re: [Javascript] Object Not Defined
> 
> I actually started to write a script but decided to ask this group
> first. Perhaps your script take the same line I was thinking might
> work.
> 
> I figured the collective knowledge would at the least help set the
> direction for such a script.
> 
> Terry
> 
> Sent from my iPhone
> 
> On Nov 21, 2011, at 9:19 AM, Troy III Ajnej <trojani2000 at hotmail.com> wrote:
> 
> >
> > Hi there,(sorry for delay).I said "some time ago", which means I'll have to look for it!My test files have become a mess...But of course "I haz teh codez". (Been busy yesterday)
> > It bites me though:"how much would you be ready to pay for this?"[Can't help it, just curious :D ]
> > I'll get back to you in less than an hour, [in case it takes longer to find it - I will write it again], so either way it will take less than anhour to get back to you.
> > p.s: the script is so short; looks almost silly, it's less than 70 bytes long.
> > Regards.
> > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> >                Troy III
> >       progressive art enterprise
> > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

 		 	   		  


More information about the Javascript mailing list