function

Newbie C Array question over functions.

Hi all, I bought a C book called "The C (ANSI C) PROGRAMMING LANGUAGE" to try and teach myself, well C. Anyhow, the book includes a lot of examples and practices to follow across the chapters, which is nice. Anyhow, the code below is my answer to the books "count the longest line type of program", the authors are using a for-loop in th...

JS variable number of arguments to function

Is there a way to allow "unlimited" vars for a function in javascript? Example: load(var1, var2, var3, var4, var5 etc) and load(var1) Tom ...

What is a good general approach for deciding return values in C?

My program is written in C for Linux, and has many functions with different patterns for return values: 1) one or two return n on success and -1 on failure. 2) some return 0 on success and -1 on failure. 3) some return 1 on success and 0 on failure (I generally spurn using a boolean type). 4) pointers return 0 on failure (I generally sp...

Javascript Cookie and Redirect Question

Hello, I have two scripts that do what I want, but I need to combine them. Basically if there is a cookie for "US" then it let's the user browse the US site. However if no cookie exists then I want it to run the Geo redirect based on location. They both work on there own but I can not for the life of me get it to do the cookie part firs...

Javascript passing function into parameter?

Hi, I use the JQuery dialog and from the PHP I can build some add-in to the button. To be able to add code from the server side I pass a method by parameter. The problem is that FireBug tell me that the method is not defined : okHandler is the parameter of this method call to raise the dialog and it contain a simple alert message for...

So Echo isn't echoing

So I've got all of this really neato PHP code and I've started doing some reuse with functions out of necessity. I'm debugging, trying to figure out why I can't delete comments on my website while I'm deleting folder (because who wants orphaned comments?) So I have a call to deletefolder( $parent) inside a file called deletefolder.php....

How can I pass an id to a function in jquery?

The following code allows the user to click on the question of a flashcard and it displays the answer. The problem is it displays all the answers for all the flashcards. How can I pass the id of each flashcard so that the user can click on the title and toggle the question open and closed? <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 ...

How to call DLL function in vbscript

I am writing VB script in which I have to call a function of a COM DLL. The fuction which I want to use is in structure and thus I want to create the object of that structure to access the required function. e.g. I have a dll 'BasicCom.dll', in which struct abc { bool xyz(); } Now I want to call xyz(). Is any one have any idea, h...

JavaScript function is not defined

Consider: File script.js, function AdaugaComboBox(id, name){ var select_tag = document.getElementById(id); select_tag.innerHTML += "<select name='"+name+"'><option value='0'>Selecteaza autor</option></select><br/>"; return true; } and file index.html: <html> <head> <script src="js/script.j...

Calling a function from another function

Hi guys I have a problem in calling a function from a function. These are the two functions: function getevents() { $date = $this->input->post('attendanceDateadd'); $Event = $this->input->post('Event'); $Timing = $this->input->post('Timing'); $CompanyName = $this->input->post('CompanyName'); $EventDescription ...

Same named function with multiple arguments in PHP

I started off OOP with Java, and now I'm getting pretty heavy into PHP. Is it possible to create multiples of a function with different arguments like in Java? Or will the interpreted / untyped nature of the language prevent this and cause conflicts? ...

"function foo(bar) { }" versus "foo = function(bar) { }"

function foo(bar) { // ... } and foo = function(bar) { // ... }; What is the benefit of one versus the other? The main benefit I see in the latter is not running into errors with a function name already being defined. However, there may be other benefits or drawbacks that aren't obvious. What are they (if any)? ...

How do I create a child class of Javascript's Function class?

I would like to create a Javascript class that I can use like so: var f = new myFunction(arg1, arg2); f.arg1; // -> whatever was passed as arg1 in the constructor f(); f instanceof myFunction // -> true typeof f // -> function I can treat it like a normal object, even adding the native Function object to the prototype chain, but I can...

How to implement a function that can take arbitary parameters in PHP?

Does PHP has such a feature? ...

Efficiency of using a function to output html tags in php

Trying to come up with a basic way to display code in a way that would be nicely maintainable, I thought of doing something like this: echo htmlfunction('a',array('href'=>'http://google.com'),'google'); to generate: <a href="http://google.com"&gt;google&lt;/a&gt; this would use as a global scale function to output all html tags. th...

Functions for value intervals

I'm currently dealing with a lot of possibly indefinite date spans, ie. StartDate EndDate --------- --------- 01JAN1921 31DEC2009 10OCT1955 null ... where the other end of the interval might be unknown or not defined. I've been working on little functions for detecting overlap, whether an interval is a subinterval of a...

functions memory management C++

hi everyone, i have a little bit lame question, but it's time i have this finally clear. consider regular function with some parameters and a return type. My questions are: are there always made some copies of parameters? i mean even if the function expects reference or pointer as parameter, there are actually new references/pointers ...

Double const declaration

Hi. I often see the following function declaration: some_func(const unsigned char * const buffer) { } Any idea why the const is repeated before the pointer name? Thanks. ...

Javascript AJAX failing when put in to a function

I've written the following code to get JSON data with a POST request. $.post("http://example.com/songs/search_api/index.php", "data[Song][keyword]=Stereophonics", function(data){ /*$("#results").append(data);*/ alert("test"); var songdata = JSON.parse(data); //$("#results").empty(); ...

Matlab function/class history

How to find out about a particular function or class in which version of Matlab/toolbox it was first introduced? I know I can look through all Release Notes, or Google can help sometime, but is there any better way? ...