arguments

Arguing about usability and "prettyness"

As a UI guy (coding and designing user interfaces) I often find myself in the odd situation arguing about the quality of userinterfaces with programmers and other "laymen". I find it somewhat hard to argue about things like colors, icons or layout and it doesn't seem that there is a factual right or wrong. But still - without having a c...

Passing optional arguments to a COM function in VC++

I have an MFC wrapper over a COM object. There is a function that takes a large number of options, which are mostly optional. How do I pass some arguments but not others? For what it's worth, the optional arguments are listed as VARIANT*. Below is the code CComVariant vFalse = false; CApplication application; { application.Cr...

Are there any programming languages with functions with variable arguments not at the end?

Python, C++, Scheme, and others all let you define functions that take a variable number of arguments at the end of the argument list... def function(a, b, *args): #etc... ...that can be called as followed: function(1, 2) function(1, 2, 5, 6, 7, 8) etc... Are there any languages that allow you to do variadic functions with the ...

Passing arguments with DOS wildcards to a Python script

I want to do something like this: c:\data\> python myscript.py *.csv and pass all of the .csv files in the directory to my python script (such that sys.argv contains file1.csv, file2.csv, etc.) But sys.argv just receives *.csv indicating that the wildcard was not expanded, so this doesn't work. I feel like there is a simple way to ...

Loop function parameters for sanity check

I have a Python function in which I am doing some sanitisation of the input parameters: def func(param1, param2, param3): param1 = param1 or '' param2 = param2 or '' param3 = param3 or '' This caters for the arguments being passed as None rather than empty strings. Is there an easier/more concise way to loop round the func...

How to emulate keyword arguments in ActionScript 3 functions

Functions in Python can be called using keyword arguments of the form keyword = value. For instance, the following function: def parrot(voltage, state='a stiff', action='voom', type='Norwegian Blue'): print "-- This parrot wouldn't", action, print "if you put", voltage, "volts through it." print "-- Lovely plumage, the", typ...

How best to determine if an argument is not sent to the JavaScript function

I have now seen 2 methods for determining if an argument has been passed to a JavaScript function. I'm wondering if one method is better than the other or if one is just bad to use? function Test(argument1, argument2) { if (Test.arguments.length == 1) argument2 = 'blah'; alert(argument2); } Test('test'); Or function...

build argument lists containing whitespace

In bash one can escape arguments that contain whitespace. foo "a string" This also works for arguments to a command or function: bar() { foo "$@" } bar "a string" So far so good, but what if I want to manipulate the arguments before calling foo? This does not work: bar() { for arg in "$@" do args="$args \"pre...

Arguments or parameters?

I often find myself confused with how the terms 'arguments' and 'parameters' are used. They seem to be used interchangeably in the programming world. What's the correct convention for their use? ...

How do I pass information between Flash's ExternalInterface and JavaScript?

How do i pass three arguments using external interface in flash to a java script function and get back output and display it in flash? ...

Custom Rails URL argument separators?

We're building a Facebook application at work using Ruby on Rails. We're currently switching it from a canvas to an iframe application for technical reasons. There is however a problem, Facebook sends you the fb_sig_api_key and others as GET varialbes in the URL (blah.com/?fb_sig_api_key=12345&whatever=hello). However, for some reason,...

Commandline arguments not working - Skips over them completely.

Alright, I'm trying to get arguments to work properly with a small test application. My code is below. I'm not too experienced at C++, so I'm not sure why when I launch test with -print (or --print) it automatically states "Not a valid option" and then finishes up. #include <iostream> int main(int argc, char* argv[]) { int option; ...

Passing an array as a function parameter in C++

In C++, arrays cannot be passed simply as parameters. Meaning if I create a function like so: void doSomething(char charArray[]) { // if I want the array size int size = sizeof(charArray); // NO GOOD, will always get 4 (as in 4 bytes in the pointer) } I have no way of knowing how big the array is, since I have only a point...

passing args (arguments) into a window form application

Hi guys, I have my Windows Application that accepts args and I use this in order to set up the Window behaviour problem is that I need to pass text in some of this arguments but my application is looking at it as multiple args, so, this: "http://www.google.com/" contact 450 300 false "Contact Info" true "Stay Visible" true has actua...

Passing arguments to views in ASP.NET MVC?

Hi, I've been experimenting with ASP.NET MVC and following this tutorial to create the basic task list application. I've gotten it running fine, everything is working although the video is in VB and I had some trouble getting it "converted" to C# but muddled through thanks to the codesample. Now, to further my knowledge I've decided to...

Express the usage of C++ arguments through method interfaces

Is there a common way to express the usage of arguments in C++? I want to implicitly tell the consumers of my class how the arguments they pass will be used by the class. Examples: I own your argument (will clean it up) I will hold a reference to your argument during my lifetime (so you should NOT delete it while I'm stile alive) I w...

jQuery and closure.

I have a multiple menu's on my page which all use the same mouseover and click events, so I decided to get it into a function. However vars seem to always be assigned to the last of the arguments for the hover(function, function) function. $(document).ready( function() { menuMouseOver = function() { for(i=0, u=arguments.length; i<u;...

JScript Arguments Collection - .Net Equivalent

When writing code in JScript, as I am wont to do as I have never been a fan of ASP.Net and Jscript is infinitely more elegant than VBScript, you can call upon the arguments collection. This is extremely useful to pass into error handlers as you can then output messages to development teams which tell them exactly what the state of the ap...

Pass arguments into C program from command line.

So I'm in Linux and I want to have a program accept arguments when you execute it from the command line. For example, ./myprogram 42 -b -s So then the program would store that number 42 as an int and execute certain parts of code depending on what arguments it gets like -b or -s. ...

Execute PowerShell Script from C# with Commandline Arguments

I need to execute a PowerShell script from within C#. The script needs commandline arguments. This is what I have done so far: RunspaceConfiguration runspaceConfiguration = RunspaceConfiguration.Create(); Runspace runspace = RunspaceFactory.CreateRunspace(runspaceConfiguration); runspace.Open(); RunspaceInvoke scriptInvoker = new Run...