function

How to turn jQuery/Javascript functions into methods

Could anyone explain how to turn functions into methods and the variables into parameters of an object in jQuery/Javascript? And even more interesting Why i should do that? ...

JavaScript function's memory size

This seems rather obvious to me, but I just wanted to make sure. In terms of memory used when the foo function is stored, would it better to do this: function foo(){ var hey = {}; hey.a = 1; hey.b = 1; alert('done'); } or function foo(){ var hey = getHey(); alert('done'); } function getHey(){ var hey = {};...

Objective C member in C++ class

Hi. Is it possible to have a objective c member in a c++ class @interface ObjectiveCClass : UIViewController { int someVarialbe; } - (void)someFunction; @end class CPlusPlusClass{ ObjectiveCClass obj; // have a objective c member void doSomething(){ obj.someFunction; // and call a objec...

How would you create a non localized variable in a function so that it is accessible by other functions in javascript?

I have a variable in a function that I want to be accessible by other functions. How would you do that? ...

dynamic element id with php and jquery

Ok this might be a bit confusing, but here goes. Let's say I have a a few select dropdowns on a page. <select id="filter" name="filter[]"> <option value="">-- Select Filter --</option> </select> <select id="load_choice" name="load_choice[]"> <option value="">-- Select Load_choice --</option> </select> ...

php functions - doesn't work

Hi! I guess I have a little understanding about functions and how they work.. Idea is to get "user's group" from database, but I don't want to write the code evey time when I need it so I decided to put it in function. function get_role() { $user_id = $_SESSION['login_ok']; $res = mysql_query('SELECT role FROM users WHERE id = "'.$us...

Error using load command to open .mat file in Matlab

Here's a part of my code where I am entering a name of the .mat file, which is located in the same folder as my code. However it does not identify the file name and gives an error: "??? Error using ==> load Unable to read file 'q_5wells_yearly_CMG.mat': No such file or directory." q_MethodType=input('Do you want to use q from "CMG", ...

How To Extract Function Name From Main() Function Of C Source

Hi! I just want to ask your ideas regarding this matter. For a certain important reason, I must extract/acquire all function names of functions that were called inside a "main()" function of a C source file (ex: main.c). Example source code: int main() { int a = functionA(); // functionA must be extracted int b = functionB(...

Two functions doing the exact same thing, alias?

In a derived class I have a function called evaluate() (it's a virtual in the base class). In this derived class i also have a function set_value() and hence i want get_value() as well. get_value() should return the exact same thing as evaluate() Is there anyway to say that a call to get_value is a call to evaluate()? With some sort of ...

C++: error: expected primary-expression

void add(int register, int& acc) { acc += register; } main.cpp:124: error: expected primary-expression before ‘register’ wth is wrong right there? ...

using jquery contains inside a function?

Hi all, I'm trying to use the jquery :contains (or .contains()) selector inside a function, however I can't seem to get it to work. Basically I'm passing a string to a function and I want to check the variable if it contains X, do something else do something else. If that makes sense. Here's my code. function checkMe(myVar) { if ($...

problem with using extract php function?

<?php function check($user_id, $topic_id){ $query = mysql_query("SELECT user_id, topic_id FROM sa where topic_id='$topic_id' and user_id='$user_id'"); if (mysql_num_rows($query)==1){ return 'you have already voted'; } else { $against = ' <li> <button type="submit" value=...

can any one list all the valid arguments for setstyle() function for UIcomponents?

hello i am working with actionscript flex and using UIcomponents i need all the valid arguments for this function for example component.setStyle("borderColor","white"); i need all valid strings for first string parameter and 2nd valid argument for there value setting, i have some of them that are given below but i need all possible...

Is it possible to have a function(-name) as a template parameter in C++?

I don't want function pointer overhead, I just want the same code for two different functions with the same signature: void f(int x); void g(int x); ... template<typename F> void do_work() { int v = calculate(); F(v); } ... do_work<f>(); do_work<g>(); Is this possible? To clear up possible confusion: With "template paramete...

How to terminate code that takes long in vb.net?

How to terminate function/code (not entire page) when it takes some time, for example, more than 1 sec? If Code > 1 Sec Then Terminate the code.... I found the command "Server.ScriptTimeou", but it stops the entire page instead of one command. ...

PHP: Callback functions

Some functions in PHP require a callback function. How can I do this in a function myself? First of all, how do I define a function that require a callback function? And secondly, how do I provide a custom function as the callback function? How do I provide a regular function, an instance function and a static function? ...

override base php functions

Hi, I have made a function simular to the print_r function in php. Is there a way that you can add to the base functions of php so any sites that are on your server can use your new function. basically i have made a print r with a header to save the sessions to a file for debugging . does any one know if this is possible. Thank you :...

Replace an element in a list in Scheme

Hi, I'm looking for a function in Scheme to replace a element in an equation by a value. Exemple : '(+ a b c a) with (1 2 3) should give me '(+ 1 2 3 1). (I don't want to resolve the equation, it was just an exemple) Basically, I want to say that a=1, b=2, c=3 To proceed, I extract the variables of my first list in another list. The...

Javascript: Function for an event

So I would like to create a function from this: element.onclick = function(e){ ... code ... } To something like this: element.onclick = doSomething(e); element2.onclick = doSomething(e); function doSomething(e){ ... code ... } In this way I could call the function multiple times but in this way e is not passed as an event...

What's the meaning and use of "res" in function arguments?

Hi, here's a short question that my googling failed to deliver any clues on. It seems to be pretty commonplace to use the word "res" for one of the indexes in function arguments. Its existence appears to be agnostic to whatever programming language you look at. What does it stand for? A simple guess would be, "resource", perhaps? If th...