Call a Function within a Function - Printable Version -Shoutbox (https://shoutbox.menthix.net) +-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58) +--- Forum: Messenger Plus! for Live Messenger (/forumdisplay.php?fid=4) +---- Forum: Scripting (/forumdisplay.php?fid=39) +----- Thread: Call a Function within a Function (/showthread.php?tid=64896) Call a Function within a Function by Black_Ice on 08-14-2006 at 10:30 AM
I'd just like a little guidence with this one please. How (if you can) can I call a function in a function. The first function being outside the 2nd one. Example: RE: Call a Function within a Function by vikke on 08-14-2006 at 10:31 AM
code: RE: Call a Function within a Function by Intosia on 08-14-2006 at 10:52 AM http://en.wikipedia.org/wiki/JavaScript RE: Call a Function within a Function by Black_Ice on 08-14-2006 at 10:56 AM Correct me if I'm wrong but isn't JavaScript different to the JScript we use in WLM P! RE: RE: Call a Function within a Function by alexp2_ad on 08-14-2006 at 10:57 AM
quote:Same kind of syntax, they are very, very close. RE: RE: Call a Function within a Function by Intosia on 08-14-2006 at 10:58 AM
quote:Well, its not -the same- but stuff like syntax and functions and stuff is the same, thats why i give you the link RE: Call a Function within a Function by Black_Ice on 08-15-2006 at 08:25 AM
Ok thanks very much. For anyone seeking this answer. It's quite simple: code: RE: Call a Function within a Function by davidt on 08-15-2006 at 09:13 AM Yes, functions are global and so can be called from anywhere. It's only the variables withinn functions that stay within the function. RE: Call a Function within a Function by markee on 08-15-2006 at 09:16 AM
quote:Though you can carry it over to another function when you call upon that second function, you just have to put it between the brackets. RE: Call a Function within a Function by davidt on 08-15-2006 at 09:35 AM
Yeah - I was talking about situations like RE: RE: Call a Function within a Function by vikke on 08-15-2006 at 09:42 AM
quote: When you're not talking about classes. RE: Call a Function within a Function by Intosia on 08-15-2006 at 09:46 AM
Like this: code: I gave the wrong link, here you can find all stuff like that: http://en.wikipedia.org/wiki/JavaScript_syntax RE: Call a Function within a Function by vikke on 08-15-2006 at 09:56 AM That's wrong? RE: RE: Call a Function within a Function by CookieRevised on 08-15-2006 at 10:01 AM
quote:functions can be perfectly local to another function too. Just as variables can be global to all functions too. code:Tip: try to not use global variables, unless it is absolutely nessecairly (goes for all languages you program in). ------------------------------------------------------------------------- quote:Numbers and Boolean values (true and false) are copied, passed, and compared by value. When you copy or pass by value, you allocate a space in computer memory and copy the value of the original into it. If you then change the original, the copy is not affected (and vice versa), because the two are separate entities. Objects, arrays, and functions are copied, passed, and compared by reference.** When you copy or pass by reference, you essentially create a pointer to the original item, and use the pointer as if it were a copy. If you then change the original, you change both the original and the copy (and vice versa). There is really only one entity; the "copy" is not actually a copy, it's just another reference to the data. When comparing by reference, the two variables must refer to exactly the same entity for the comparison to succeed. For example, two distinct Array objects will always compare as unequal, even if they contain the same elements. One of the variables must be a reference to the other one for the comparison to succeed. To check if two Arrays hold the same elements, compare the results of the toString() method. strings are copied and passed by reference, but are compared by value. Note that if you have two String objects (created with new String("something")), they are compared by reference, but if one or both of the values is a string value, they are compared by value. Note: When you pass a parameter to a function by value, you are making a separate copy of that parameter, a copy that exists only inside the function. Even though objects and arrays are passed by reference, if you directly overwrite them with a new value in the function, the new value is not reflected outside the function! Only changes to properties of objects, or elements of arrays, are visible outside the function. **(To be very stricly correct that isn't entirly true though (JScript internally still makes a copy; but it also internally copies back the changed copy; aka: it isn't 'by reference' as in other languages <= hard to explain, though you shouldn't be bothered with it either, it's just per-info)) |