function

Is there a Function type in C# ?

I like to know if in C# there is a Function type like in AS3 for example. I would like to do somnthing like this (but in C#): private function doSomething():void { // statements } var f:Function = doSomething f() ...

Same JS function -- Many times?

I previously got this (useful!) answer about using .next() for same DIV blind effect. However, I can't seem to get this simple function to work for more than one DIV at the same time: $(document).ready(function(){ $("#closeButton").click(function (){ $(this).next().toggle("fast"); }); }); Any ideas? Thanks. ...

Lua decimal sign?

I've used this in other languages, but lua seems to be lacking this rather useful function. Could one of you nice chappies provide me a lua function to get the sign of the number passed to it? ...

killSession() PHP function inside $(window).unload

I'm doing a simple chat script and I have the killSession function which kills the current session and deletes the user from the DB. The problem is that after the name is set and verified the chat form doesn't load, it just kills the session and goes back to the loginForm(). Here's the script: <?php if (!isset($_SESSION['name'])) { log...

HOW TO make test.php continue with rest of coding without waiting for a function to complete task?

Hi there, This is the case. At test.php, I have a function dotask(a,b,c,d); This function need to do task that need 2-4 minutes to complete. Task including insert new record into db, curl call to other url to do task and etc. However, I want test.php to: Just make sure dotask(a,b,c,d) is called, no need to wait until task completed th...

Adding variables together using Actionscript

Hi Everyone - I am trying to translate this statement into Actionscript: "Sally is 5 years old. Jenny is 4 years old. The combined age of Sally and Jenny is 9 years." This is what I have so far: function getAges (sallyAge:Number,jennyAge:Number,combinedAge:Strin g) { trace("Sally's Age:" + sallyAge); trace("Jenny's Age:" + jennyAge); ...

using pointers to get values back from a function (c++)

i have a function to calculate several different values: int ASPfile::get_dimensions(int* Lat, int* Lon, vector<double>* Latgrid, vector<double>* Longrid) { _latsize = get_latsize(); _lonsize = get_lonsize(); Lat = &_latsize; Lon = &_lonsize; latgrid = read_latgrid(); longrid = read_longrid(); *Latg...

How to convert a Variable argument function into a macro?

Hello, I have a variable argument function which prints error messages in my application,whose code is given below. void error(char *format,...) { va_list args; printf("Error: "); va_start(args, format); vfprintf(stderr, format, args); va_end(args); printf("\n"); abort(); } This function error()is used in e...

Is it possible to send an Object's Method to a Function?

I am wondering if it is possible (and what the syntax would be) to send an object's method to a function. Example: Object "myObject" has two methods "method1" and "method2" I would like to have a function along the lines of: public bool myFunc(var methodOnObject) { [code here] var returnVal = [run methodOnObject here] [code...

how to pass a stl vector to a function which takes a const [] (c++)

i have a 3d stl vector, vector<vector<vector<double> > > mdata; i also have a function myfun(const double ya[]); to be more precise, it's a function from the GNU Scientific Library, gsl_spline_init(gsl_spline * spline, const double xa[], const double ya[], size_t size); but this is not related to my problem. so now i want to pa...

How do I round to the nearest 0.5?

I have to display ratings and for that i need increments as follows: If the number is 1.0 it should be equal to 1 If the number is 1.1 should be equal to 1 If the number is 1.2 should be equal to 1 If the number is 1.3 should be equal to 1.5 If the number is 1.4 should be equal to 1.5 If the number is 1.5 should be equal to 1.5 If...

Function turns into an endless loop

I have a problem with a function I have written in php. As you can see the function uses itself to return an array of the values. public function getRepeat($day = "array") { if ($day == 'array') {//Return an array with the repeated days as values foreach (array(1,2,3,4,5,6,0) as $value) { if ($this->getRepeat($value)) {...

Returning an Javascript Object's property by Value NOT Reference

So I have a class foo that has a method which returns an array bar. I have another function that calls foo.getBar and then filters the array. I want to be able to always get the original contents of bar when I use a different filter, but bing seems to be just creating a reference to bar, not a separate array. I have tried using return th...

Determine calling function in javascript

How can I find out in a javascript function which was the calling (the former in the call stack) function? I would like to determine if the former called function is a __doPostback in the onbeforeunload event. ...

what is the fastest way of calling and executing a function in C?

I have a lot of functions(huge list) defined and compiled. And I use function pointers to call and execute the functions by sending arguments dynamically during runtime. It is an iterative process involving more than hundred thousand function calls every iteration. I want to know which is the efficient way of calling an compiled functio...

Specifying constraints for fmin_cobyla in scipy

I use Python 2.5. I am passing bounds to the cobyla optimisation: import numpy from numpy import asarray Initial = numpy.asarray [2, 4, 5, 3] # Initial values to start with #bounding limits (lower,upper) - for visualizing #bounds = [(1, 5000), (1, 6000), (2, 100000), (1, 50000)] # actual passed bounds b1 = lambda x: 5000 ...

How to use a class's method inside a function (PHP) ?

I'm trying to use the new PHP mysqli extension. I've got a function (safe()) that recursively uses mysql_real_escape_string to make strings safe. How do I use my mysqli connection inside this function to call the mysqli::escape_string() function? Example: $db = new mysqli($host,$user,$password,$database_name); function safe ($data) {...

How to prevent passing down of parameter from one function to another

Example: Class A { public function __construct() { $this->b_Instance = new B(); } public caller() { $this->b_Instance->call_me($param1,$param2,$param3); } } Class B { public function __construct() { //lots of variables here } public function call_me($param1,$param2,$param3)...

Strange JavaScript syntax like this: (function(){//code}) (); ???

What does the below JavaScript mean? Why is the function embedded inside ()? (function() { var b = 3; a += b; }) (); ...

How to get JavaScript caller function line number? How to get JavaScript caller source URL?

I am using the following for getting the JavaScript caller function name: var callerFunc = arguments.callee.caller.toString(); callerFuncName = (callerFunc.substring(callerFunc.indexOf("function") + 8, callerFunc.indexOf("(")) || "anoynmous") Is there a way to discover the line number from which the method was called? Also, is there ...