arguments

Loop over the arguments array, without knowing how many arguments, in a shell script?

Hi, I want to pass many arguments to a shell script which I don't know how many arguments they are going to be and I want to handle them. I did the following code: int=$1 src=$2 r=$3 string=$4 duration=$5 ./start.sh $int $r $src "$string" sleep $duration shift; shift; shift; shift; shift while [ $# -gt 2 ] do r=$1 string=$2 ...

Specific functions vs many Arguments vs context dependent

An Example Suppose we have a text to write and could be converted to "uppercase or lowercase", and can be printed "at left, center or right". Specific case implementation (too many functions) writeInUpperCaseAndCentered(char *str){//..} writeInLowerCaseAndCentered(char *str){//..} writeInUpperCaseAndLeft(char *str){//..} and so on... ...

passing arguments to _beginthread() -- whats wrong?

I have this code and I am not getting the expected results... whats wrong? typedef struct { int data1; int data2; }t; void foo(int a, int b) { Handle handle; t arg; arg.data1 = a; arg.data2 = b; handle = (HANDLE) _beginthread( myFunc, 0, (void*) &arg); } void myFunc(void *param) { t *args = (t*) param; int ...

Quoting the argument

- (IBAction) charlieImputText:(id)sender { NSAppleScript *keystrokeReturn = [[NSAppleScript alloc] initWithSource:@"tell application \"System Events\" to keystroke return"]; [keystrokeReturn executeAndReturnError:nil]; [progressBarText startAnimation:self]; charlieImputSelf = [sender stringValue]; NSAppleScript *sendCharlieImput = [[...

Difference Between Parameter And Argument?

is there a difference between a parameter and an argument, or are they simply synonyms? ...

Command line arguments: use of space between program argument, and the argument's argument

Here, i have a program, which takes arguments (how surprising...). I want him to have several arguments, as: ./myprogram -f filename.txt -x -o so i want main args with "-", and these arg shall accept an other arg, in the example, a filename. I have this structure, very simple: int main(int argc, char *argv[]) { printf("Program n...

how to pass command argument while calling link button onclick function dynamically? (c#)

Hi there! I have a function for which i am sharing a group of link buttons with. the function signature is like: protected void FunctionName(object sender, EventArgs e) { ... } Now I have about 4-5 link buttons which i am using to call the same function but just filtering the stuff via command argument like: <asp:LinkButton ID="l...

How does Java handle arguments separated by | ?

How does Java handle arguments separated by | ? for example private void foo(int i) { System.out.println(i); } private void bar() { foo(1 | 2 | 1); } Which would give the output 3 I've seen this used in SWT/JFace widget constructors. What I can't figure out is how the value of i is decided. ...

Writing a 'print' function in Python

I want to create a function that works like the build-in print function in Python: print 'test', i, 'started' So a call like this should work: log('test', i, 'started) The log function should call the logging.info() function (from the Python logging module). How can I create such a function? This is my first try: import logging ...

Python, rasing an exception without arguments

Hi, I would like to know the best practice about raising an exception without arguments. In the official python documentation, you can see this : try: raise KeyboardInterrupt (http://docs.python.org/tutorial/errors.html chap. 8.6) and in some differents code, like Django or Google code, you can see this : def AuthenticateAndRu...

How to parse command line arguments in python?

I would like to be able to parse command line arguments in my python 2.6 program. Ideally, I want to be able to handle these cases: # show some help ./myprogram --help # these are equivilent ./myprogram --block=1 ./myprogram -b 1 # this means verbose, and twice as verbose: ./myprogram -v ./myprogram -vv ...

How to debug an wrong number of arguments (1 for 0) in Rails error?

Hi, I was trying to do some refactoring and messed things up but now don't know where or how to debug because it's not clear where the problem lies. Some suggestions on how to dig into the error and code would be helpful...thanks! http://gist.github.com/474290 ...

Why isn't a function's arguments object an array in Javascript?

Since it seems like the first thing people do is convert arguments into a real array, I'm interested in why the Javascript language authors and implementers decided, and continue to think, that arguments should not be a real Array. I don't mean this as flamebait, I'm sincerely interested in the thinking behind it. Since the function is n...

Pass list as argument to Python C module?

I found this nice example of a Python C Module, where a single integer is passed along as the only argument. How can I instead pass a python list as argument? ...

Types by argument??

I'm wondering if is possible pass types by argument in Java. Let me explain better: Suppose the next code class Bee { // Class implementation } class Worker extends Bee { // Class implementation } class Queen extends Bee { // Class implementation } And now create a container with my bees objects Vector<Bee> x=new Vec...

Preserving quotes in bash function parameters

What I'd like to do is take, as an input to a function, a line that may include quotes (single or double) and echo that line exactly as it was provided to the function. For instance: function doit { printf "%s " ${@} eval "${@}" printf " # [%3d]\n" ${?} } Which, given the following input doit VAR=42 doit echo 'single quote ...

Using an argument of a function in normal mode in Vim?

I have a Vimscript function defined like this: function Cs(a, b) normal a:a|"cylr a:b|x"cP endfunction However, the intended action (do some crazy stuff with the arguments a and b in normal mode) doesn't work, instead it takes the first "a" as "append" and writes the rest of the line to the file. How can I use arguments on a "no...

Get term id argument from ubercart catalog

Hi Trying to figure out how to get taxonomy term id from ubercart catalog page. It looks like ubercart catalog system does not support "native" drupal structure "taxonomy/term/id" I've used this snippet as argument for block provided by Views module if (arg(0) == 'taxonomy' && is_numeric(arg(2))){ return arg(2); } else { return FAL...

Python pack arguments??

Hi, is to possible to "pack" arguments in python? I have the following functions in the library, that I can't change (simplified): def g(a,b=2): print a,b def f(arg): g(arg) I can do o={'a':10,'b':20} g(**o) 10 20 but can I/how do I pass this through f? That's what I don't want: f(**o) Traceback (most recent call last): ...

Is there a way to get an array of the arguments passed to a method?

Say I have a method: public void SomeMethod(String p1, String p2, int p3) { #if DEBUG object[] args = GetArguments(); LogParamaters(args); #endif // Do Normal stuff in the method } Is there a way to retrieve an array of the arguments passed into the method, so that they can be logged? I have a large number of meth...