function

Scope of THIS keyword in Function?

Should 'this' in the following code not still refer to the DOM object selected by the MooTools selector? $$('div').addEvent('click', function() { var click1 = function(){$(this).setStyle('background', 'red');} click1(); }); ...

What is meant by 'use of a function'

$3.6.1/3 states- "The function main shall not be used (3.2) within a program.". The sample academically motivated program below uses the name 'main' in a couple of ways which I thought are legitimate. This is based on the assumption that 'usage of a function' is related to calling the function (directly/indirectly). struct MyCla...

Delphi equivalent of .net's DateTime.ToString("s") (DateTime Sortable)

Is there an equivalent in Delphi? I've looked over the documentation and can't find anything that would give me the output I want. ...

PHP global or $GLOBAL

Hello! Is there a best practice / recommandation when I want to use a variable declared outside of a function when it comes to using: global $myVar $GLOBALS['myVar'] Thank you. ...

values not being copied to the next (local) environment?

Consider this output from browser() that is located inside calcDistance: Called from: calcDistance(object = rst, xy = xy[[i]][j, ], effect.distance = effect.distance) Browse[1]> ls.str() effect.distance : num 236 object : Formal class 'RasterLayer' [package "raster"] with 12 slots xy : Named num [1:2] -101.8 35.5 Browse[1]> debuggin...

JavaScript: functions passed as a parameter to an if block

In the below code how does passing bar as function (n) { return n; } to foo evaluate to true in the if block? function foo(bar) { if (bar) { // true } else { // false } } This has me puzzled so any help is much appreciated. ...

Can OpenCL inline functions return OpenCL types?

I know OpenCL supports inline functions, but can those functions accept and return OpenCL types? Specifically, I am interested in something with this signature: float4 func(float4 x, float4 y) ...

Passing type of template function to template class used within it?

I am trying to build a template function. Inside templated classes are used and I would like to pass the template type of the function to those classes. So I have: template <class T> T find_bottleneck (ListGraph &g, CrossRefMap<ListGraph, Edge, T> &weight, Node &s, Node &t) { // Check if theres a single edge left if (countEdge...

PHP: Is it possible to return multiple values from a function?

I have a function that should return several values. Is this possible, perhaps with an array? If so, how would I reference that array? Do I have any alternatives to using an array? ...

How is the square root function implemented?

How is the square root function implemented? ...

Allowing javascript function to accept any number of arguments

I would like the below function to be more flexible and accept multiple callbacks to other functions if they are defined in the arguments. $(function() { function icisDashBox(colorElem, thisWidth, thisHeight, completeCallBack) { $(colorElem).colorbox({ transition: 'none', ...

Writing php Time() to mysql using

I want to log the time that a user posted a message and display it in a Twitter like fashion. I found a function that does this but it does not work with mysqls Timestamp type. In the instructions it says that it uses the time()format to calculate it. How should I be writing the times to my Database in order for it to work??? This is...

How can I perform Jquery function during AJAX

I am using Jquery AJAX to post a form on my page. I want to hide a div whilst AJAX is being performed and show it again when AJAX is a success. How can I do this?? Check my code here: $(document).ready(function(){ $("form#microblogpost").submit(function() { // we want to store the values from the form input box, then send via ajax belo...

Things which can be done with MYSQL instead of involving PHP

What are the must-know MYSQL functions (like IF etc..,) which every web developer should know? ...

Creating Classes and Properties in AS3

I'm new to AS3. Learning how to create classes. Is comp = new HouseObjects creating a new class? Is comp creating an instance of the HouseObjects? I realize that this is inside public class TreeHouse. I'm thinking that HouseObjects, how I set it up is not a class...not sure what the correct way to set up classes and properties. Also I n...

PHP funtion flags, how?

I'm attempting to create a function with flags as its arguments but the output is always different with what's expected : define("FLAG_A", 1); define("FLAG_B", 4); define("FLAG_C", 7); function test_flags($flags) { if($flags & FLAG_A) echo "A"; if($flags & FLAG_B) echo "B"; if($flags & FLAG_C) echo "C"; } test_flags(...

Thread.interrupt() What does it do ?

Could you explain me what does this function do when invoked? ...

Accessing this from within an object's inline function

I'm having difficulty referencing "this" from within a javascript inline function, within an object method. var testObject = { oThis : this, testVariable : "somestring", init : function(){ console.log(this.testVariable); // outputs testVariable as expected this.testObject.submit(function(){ var a...

C Unstringification with macros

Is there any way to unstringify strings provided as macro arguments? I need to be able to call functions who's names are in strings. Something like this: void hello() { printf("Hello, world!"); } call_func("hello"); How would I implement call_func. It would be in a module that would be #included and would be used to call functio...

Can I store JavaScript Functions in arrays?

How can I store functions in an Array with named properties, so I can call like FunctionArray["DoThis"] or even FunctionArray[integer] Note: I do not wish to use eval. ...