function

Write an Objective-C method, and a c function, when writing for the iPhone?

When using XCode for writing for the iphone SDK... like a simple function that accepts a text-string URL and visits the website, and returns the HTML... which is better? Use Objective-C and write a "method" that accepts an NSString and returns an NSString. or Use C and write a "function" that accepts a string and returns a string. Ho...

Fix incorrect nesting

function drawinventoryList() { inventoryArray.sort(); var inventoryString = ""; for (x in inventoryArray) { arrayValue = inventoryArray[x]; var counter = parseInt(x) + 1; if (counter == 1) { inventoryString = "<table width='100%' celpadding='0' cellspacing='0' style='border:1px solid #d00;'...

Pass variables to a pre-defined jQuery function.

Ok, so I have: function myfunc(foo,bar) { $('#div' + foo).hide(); $('#div' + bar).show(); return false; } Then I have: function myOtherFunc() { // define vars foo and bar myfunc(foo,bar); } var timerId = setInterval(myOtherFunc, 5000); // run myOtherFunc every 5 seconds. which works fine. But the I have: $('#myLink...

jquery function problem

what's wrong with this code, first time I click the submit button it loads the iframe once, then clicking it again will load the iframe twice. and so on.. code: JS $(function() { $("form").submit(function() { // $("form").attr('target','myframe'); $('#myframe').load( function(){ alert('Hello'); }); });...

this inside function

My question is: function Foo() { this.foo = "bar"; // <- What is "this" here? } From what I can tell it depends on how Foo is used, i.e. as a constructor or as a function. What can this be in different circumstances? ...

Why Do I Get "nested functions are disabled..." Error in my Code?

Basically, a program to find the largest prime factor of a number. Don't know if the logic is correct cuz I can't run it to test it. I know this is long. But please forgive me. //largest_prime.c #include <stdio.h> int main() { int num,large; int prime(int); int lprime(int); printf("Enter number: "); scanf("%d",&num)...

What to do with Unicode non-awareness in PHP < 6?

I'm working on a project which needs to be Unicode aware. PHP provides bunch of useful functions like str_count_words() to calculate the number of words in some input, but they won't work against UTF-8 data in PHP < 6 which is a shame. The same applies to strlen(), strrev(), etc. What should I do about this? PHP 6 is still not even out ...

Jquery Replace with return value of Javascript function

OK I am just starting out with jQuery. I have a page with a table of date-values. Each is wrapped in a tag which I can find with $('mytag'). <mytag>2009-10-31</mytag> How, using Jquery, would I take each of the source values and pass it to a Javascript function then replace that source value within the table with the result of t...

In python is there any way I can obtain the arguments passed to a function as object ?

I don't want to use *args or **kwargs since I can't change function declaration. For example: def foo( a, b, c ) """Lets say values passed to a, b and c are 1,2 and 3 respectively""" ... ... """ I would like to generate an object preferably a dictionary such as {'a':1, 'b':2, 'c':3} """ ... ... Can anyone suggest a way...

Why Syntax Error on Function - Python

I'm just starting to learn python... so bear with me please Why is it giving me a Invalid Syntax error with this block of code def InvalidArgsSpecified: print ("*** Simtho Usage ***\n") print ("-i Installs Local App,, include full path") print ("-u Uninstalls Installed App,include ID or Name") print ("-li Lists all inst...

Oracle Function: Replicate wm_concat

I currently am working on a project within Crystal Reports that refuses to use the undocumented function WM_CONCAT, which is allowable within Oracle 10g. Here is the WM_CONCAT header information WM_CONCAT(p1 IN VARCHAR2) RETURN VARCHAR2 To use WM_CONCAT I pass it the following: WM_CONCAT(column1); This function seems to accept a co...

Passing a char** into a function by reference

Season's greetings! I have a function that prints out the contents of a char** that is being used as an array to store a number of strings. The is declared like this: char** commandArray = (char**)malloc(historySize); where historySize is a global int set to 8, for now. The array is populated with commands that the user enters, in s...

Switch pointers in a function in the C programming language

How do you switch pointers in a function? void ChangePointers(int *p_intP1, int *p_intP2); int main() { int i = 100, j = 500; int *intP1, *intP2; /* pointers */ intP1 = &i; intP2 = &j; printf("%d\n", *intP1); /* prints 100 (i) */ printf("%d\n", *intP2); /* prints 500 (j) */ ChangePointers(intP1, intP2); printf("%d\n", *intP1); /* ...

Sizeof an array in the C programming language?

why isn't the size of an array sent as a parameter the same as within main? #include <stdio.h> void PrintSize(int p_someArray[10]); int main () { int myArray[10]; printf("%d\n", sizeof(myArray)); /* as expected 40 */ PrintSize(myArray);/* prints 4 not 40 */ } void PrintSize(int p_someArray[10]){ printf("%d\n", sizeof(...

Put a function in an XML field

Is it possible to put a function in an XML field? For example i have the following xml file: <?xml version="1.0" encoding="utf-8" ?> <prova> <prova> <continente>Europa</continente> <stato>Italia</stato> <societa>SSC Napoli</societa> <actual>1.09769</actual> <estimate>0.447969</estimate> </prova> <prova> .... </prova> </prova> I...

Performance advantages of using methods inside of classes verses data structures with libraries of functions?

Basically is the only advantage of object oriented languages the improved understanding of a programs purpose? Do the compilers of object oriented languages break apart the objects into structures and function libraries? ...

are stored procedures faster than functions or not

I am using stored procedures at the moment but I have a lot of stuff like this: if ... begin select 'success' return end if ... begin select 'notgood' return end if ... begin select 'someelse' return end so I'm thinking that it would be a better idea to use functions instead, but is there any performance difference between functions a...

jQuery Carousel function issues

Hi there, Ive been writing a simple jquery function that turns a div with a list of images into a carousel. Here is the markup.. <div id="carousel"> <ul> <li><img src="images/music1.jpg" /></li> <li><img src="images/music2.jpg" /></li> <li><img src="images/music3.jpg" /></li> </ul> </div> and in my carousel.js file i hav...

Passing a string with spaces as a function argument in bash

I'm writing a bash script where I need to pass a string containing spaces to a function in my bash script. For example: #!/bin/bash myFunction { echo $1 echo $2 echo $3 } myFunction "firstString" "second string with spaces" "thirdString" When run, the output I'd expect is: firstString second string with spaces thirdStr...

Which is more fundamental: Python functions or Python object-methods?

I am trying to get a conceptual understanding of the nature of Python functions and methods. I get that functions are actually objects, with a method that is called when the function is executed. But is that function-object method actually another function? For example: def fred(): pass If I look at dir(fred), I see it has an att...