arguments

PHP 4 Default Function Parameter

Hello, can I use this syntax under PHP 4 (default function parameter) : function myFunction($arg1 = 'defaultValue') {} Thanks. ...

How to map a tuple of data to a tuple of functions?

I have the following Python code: data = ['1', '4.6', 'txt'] funcs = [int, float, str] How to call every function with data in corresponding index as an argument to the function? Now I'm using the code: result = [] for i, func in enumerate(funcs): result.append(func(data[i])) map(funcs, data) don't work with tuple of function...

Javascript arguments as array?

so I have a button with this event: onmousedown="hideElements('\x22cartview\x22,\x22other\x22')" and then this function hideElements: function hideElements(what) { var whichElements=[what]; alert(whichElements[0]); } I want it to alert "cartview" but it alerts "cartview","other" I am aware of the arguments object ...

How to do a preg_match in php?

Hi I have this argument in php and i want this to just allow users to enter a domain name...i want it so that it doesnt allow characters like "/" "?" and so on...so i only get the domain name such as "http://somedomain.co.nz" or "http://www.somedomain.co.nz" if(!preg_match('/^(http):\/\/([A-Z0-9][A-Z0-9_-]*(?:\.[A-Z0-9][A-Z0-9_-]*)+):...

Drupal: Dynamic View using Arguments

For a current project i need to setup a specific view to display a gallery detailpage. It should work like this: 1. User clicked a node (costum-post-type: gallery) 2. User received an overview page with linked images 3. User clicked an image 4. User received the gallery page (gallerific view) Step 1-3 are done. But how can I get Drupa...

Why does this cause a syntax error?

Hello, In python, I wrote this: bvar=mht.get_value() temp=self.treemodel.insert(iter,0,(mht,False,*bvar)) I'm trying to expand bvar to the funtion call as arguments. But then it return, File "./unobsoluttreemodel.py", line 65 temp=self.treemodel.insert(iter,0,(mht,False,*bvar)) ^ ...

How to pass method arguments to a selector

If I have a method like this: - (void) foo { } Then I can access it through a selector like this: @selector(foo) But what if I have a method like this: - (void) bar:(NSString *)str arg2:(NSString *)str2 { } Then how do I access it through a selector? ...

what is $@ OR searching for an explaination of $@ in bash

I reckon that the handle $@ in a shell script is an array of all arguments given to the script. Is this true? i ask, because i normally use search engines to gather information, but I cant google for $@ and I have grewn too custom to easily getting served everything. ...

Length of arguments of Python function?

Possible Duplicate: How to find out the arity of a method in Python For example I have declared a function: def sum(a,b,c): return a + b + c I want to get length of arguments of "sum" function. somethig like this: some_function(sum) to returned 3 How can it be done in Python? Update: I asked this question because I wa...

Why does this TCL proc with no args not work?

This should be an easy one for someone... I had a function in a TCL script called unwrap. Modifying it, I realized I no longer needed to pass it args. So I changed it to unwrap {} { ... } Now when I call it with no args, i.e.: unwrap I get an error invalid command unwrap Ideas? How do I properly format a TCL function with no a...

Casting Command Line Arguments?

i have a command line executable program that accepts a configuration file as it's one argument for launch. the configuration file contains only 2 lines of code: #ConfigFile.cfg name=geoffrey city=montreal currently, the wrapper program that i'm building for this command line executable program writes the configuration file to disk a...

LaTeX: Use some characters in a string

Hi: I need a macro that extracts pairs of number from a string that looks like this: n1-m1,n2-m2,n3-m3,n4-m4 (it could be longer) where n1,m1,n2,m2,... are numbers from 0 - 15. How can I go about getting the pairs (n1,m1), and (n2,m2), (n3,m3), etc inside my macro? I will need to use each pair once, after which I can, if needed,...

Javascript eval() for function with argument

How do I do this? function myUIEvent() { var iCheckFcn = "isInFavorites"; var itemSrc = ui.item.find("img").attr("src"); if (eval(iCheckFcn(itemSrc))) { alert("it's a favorite"); } function isInFavorites(url) { return true; } // returns boolean ...

Converting list to *args in Python

In Python, how do I convert a list to *args? I need to know because the function scikits.timeseries.lib.reportlib.Report.__init__(*args) wants several time_series objects passed as *args, whereas I have a list of timeseries objects. Any help is greatly appreciated :) ...

isdigit() Segmentation Fault

Getting a weird segmentation fault on following code when I try to pass a number into my application on command line. int offset = 3; int main(int argc, char *argv[]) { // Check for arguments to see whether there is a custom offset if (argc == 2) { // If argc == 2 then we have a offset? if (isdigit((unsigned cha...

How to pass variable arguments from bash script to python script

Hi All... I've been trying to solve this issue for sometime now with no luck. The crust of the situation is that I'm using a bash script to send parameters to a a python script: Example: foo.sh calls bar.py....the call looks like: bar.py $var1 $var2 ... $varn The python script then prints all the arguments using the sys.argv array. T...

Drupal: passing arguments to drupal_get_form form function

Is there any way to pass arguments into a function called via drupal_get_form function something like drupal_get_form('form_func', array('arg1' => 1, ...));? ...

when to use const and const reference in function args

When writing a C++ function which has args that are being passed to it, from my understanding const should always be used if you can guarantuee that the object will not be changed or a const pointer if the pointer won't be changed. When else is this practice advised? When would you use a const reference and what are the advantages over...

How to Pass a variable to another Thread

using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { Console.WriteLine("Taking data from Main Thread\n->"); string message = Console.ReadLine(); ThreadStart newThrea...

How can I parse command line arguments?

I want to parse a list of arguments in a perl script, for example i have this situation : script.pl -h 127.0.0.1 -u user -p pass arg1 arg2 arg3 How can i do for parse the list of argument that aren't option in an array, and the option parameter in scalar value ? Thanks. ...