function

integrating a function

hi this is the follow-up to my question about getting a div's content. the second function is the one im having a hard time with. im pretty sure i can call a function from another one, but im not sure about placing them into oneanother like i did here. its obviously a silly attempt to make the code work, since it gives me an error: Bla...

Does using prototypes in JavaScript have any real world advantages?

I just finished Doug Crockford's The Good Parts, and he offers three different ways to go about inheritance: emulation of the classical model, prototype-based inheritance, and functional inheritance. In the latter, he creates a function, a factory of sorts, which spits out objects augmented with desired methods that build upon other obj...

Turn function on and off

I have a jQuery tip function. I would like to create a button to turn on and turn off the function. I want it to be on by default. Is it possible to create a link to turn on and off a function? ...

Android Development: Switching Between Views Without Loosing onClickListeners

Hello, On my application I'm developing, the main.xml layout (the default layout of my app) has a few buttons that have been assigned onClickListeners (not the implementation way). One of those buttons I want to have the ability to take you to another view. On the other view (preview.xml), there's another button that takes you back to ...

Why does this function not autolink?

function twitterify($ret) { $ret = preg_replace("#(^|[\n ])([\w]+?://[\w]+[^ \"\n\r\t< ]*)#", "\\1<a href=\"\\2\" target=\"_blank\">\\2</a>", $ret); $ret = preg_replace("#(^|[\n ])((www|ftp)\.[^ \"\t\n\r< ]*)#", "\\1<a href=\"http://\\2\" target=\"_blank\">\\2</a>", $ret); $ret = preg_replace("/@(\w+)/", "<a href=\"http://www.twit...

C how to use the function uname

Hi all, I should write a function to get some information about the system (the most important information is the the architecture). I found the function uname which can be used including sys/utsname.h. Well, though I googled and I read the documentation, I couldn't find any example of the function and I don't understand how to use uname...

Perl Module Method Calls: Can't call method "X" on an undefined value at ${SOMEFILE} line ${SOMELINE}.

All over the place, especially in DBI, I see this message come up all the time. It's confusing, because the first thing that comes to mind is that the arguments I'm passing the function are set to undef (or something similar), but it's clearly not the case. Given a module and a corresponding script... Module: ./lib/My/Module.pm packag...

Are there any good libraries of functions to use with collections in Java, such as...

Are there any good libraries of functions to use with collections in Java. I'm thinking along the lines of implementations of partition, take, drop, takeWhile, dropWhile, map, filter, reduce...? I can write them myself, but it feels like re-inventing the wheel. Thanks, Alex ...

In PHP, why wasn't echo implemented as a function? (not echo vs. printf)

I'm just curious. In PHP, why wasn't echo implemented as a function? Why didn't PHP just give us printf and never tell about echo? Please note that: This is not a question about echo vs. printf. I already knew that echo is a language construct. UPDATE: By the way, was printf implemented using echo? ...

Question on Function Declaration

Given the two code examples which is preferred? In the first the return variable is defined as a local variable. In the second the return variable is passed by the caller. Are you allowed to define a function and return a variable that was passed to it? I's this simply a preference of one or the other? is there a performance difference? ...

htmlspecialchars or mysql_real_escape_string????

I am unsure which one to use in this situation??? $query1 = "SELECT * FROM messages WHERE messages.custid='".htmlspecialchars($_SESSION['customerid'])."' ORDER BY messages.id LIMIT $start, $limit "; ...

What is the difference between functions in math and functions in programming?

What is the difference between functions in math and functions in programming? ...

Inheritance and templates and virtual functions ( this can get messy)

Just finding my way around templates so was trying out a few stuff. Let me know what I am doing wrong here. I am trying to overload a inherited templates virtual method. // class templates #include <iostream> using namespace std; template <class T, class A> class mypair { T a, b; public: mypair (T first, T second) {a...

How can I import a python module fuction dynamically?

Assuming def my_function(): is located in my_apps.views I would like to import "my_function" dynamically without using something like exec or eval. Is there anyway to accomplish this. I'm looking to do something similar to: my_function = import_func("my_apps.views.my_function") my_function() ... code is executed ...

if [ $? -ne 0 ] then syntax error then unexpected

Hi all, I have been trying to execute the following unix shell script which is not working. I am running it by ksh. echo $?; if [ $? -ne 0 ] then failed $LINENO-2 $5 $6 fi failed() { echo "$0 failed at line number $1"; echo "moving $2 to failed folder" } This is giving an error saying "Synatx error:then unexpected". Basicall...

How to implement a funtion that takes a param array (variable number of args) of generic args

I have seen a question here where they implemented a generic dispose method that takes any IDisposable object and calls dispose on it. I would like to make this such that it can take variable number of args. However, I do want to restrict the args to be IDisposable at compile time. (This is because some people in my organization will en...

Where do I define view functions in CakePHP?

Hi, I have a modifier procedure to show the "date" of an event. if($event['Event']['is_multi_day']){ if( date('n',strtotime($event['Event']['start_day']) ) == date('n',strtotime($event['Event']['end_day'])) ) $date = date('j',strtotime($event['Event']['start_day'])).' - '. date('j',strtotime(...

WPF - Bind DisplayMemberPath to a Function?

Hey all, Is there a way I can bind the DisplayMemberPath of combobox to a function? The object with which I am currently working has three properties I wish to use for presentation; FirstName, LastName, and MiddleName. I wrote a static method in a Formatting class to handle it. This method is called FullName and accepts three string ...

PHP preg_filter() substitute in PHP<5.3?

Had to deploy some PHP code onto a shared server with only PHP5.2.8. All code works EXCEPT for the preg_filter() call which was added in 5.3+ (and against which the code was written). Can anyone recommend an easy substitute for preg_filter() in PHP5.2? ...

return statements inside a function

I was wondering how people handle return statements in a function. I have a method that allocates some memory but has a return false; statement when a function goes wrong. this statement is located about half way through the function so my memory is leaked if that function fails. This isn't the only return ...; statement I have in this f...