arguments

Python: Strange behaviour of recursive function with keyword arguments

Hi folks, I've written a small snippet that computes the path length of a given node (e.g. its distance to the root node): def node_depth(node, depth=0, colored_nodes=set()): """ Return the length of the path in the parse tree from C{node}'s position up to the root node. Effectively tests if C{node} is inside a circle a...

Overrible predefined Bash variables with arguments

Can someone point me out what is the problem when I want to overrible a default value in a variable with an argument in Bash? The following code doesn't work: #!/bin/bash VARIABLE1="defaultvalue1" VARIABLE2="defaultvalue2" # Check for first argument, if found, overrides VARIABLE1 if [ -n $1 ]; then VARIABLE1=$1 fi # Check for seco...

PHP system batch args

Using PHP's system function, how can you pass arguments to a batch file? It would probably look something like this system("batch.bat argument", $output); I found out how to do it with a C++ executable here I'm guessing it should be relatively simple... What the real question is is how to receive the argument with a batch file? ...

Convincing customers to upgrade to Java 5

We sell packaged Java web applications to some of our customers. It's basically a collection of servlets, some SOAP web service and some static resources. We don't do EJB nor any other Java Enterprise fancy stuff. Some of our clients are running IBM WebSphere Application Server v5.1, hence we are limited to Java 1.4 for the run-time...

Conventional ways to pass arguments to interpreted program

I'm writing an interpreter. The interpreter accepts arguments that it itself uses, including a file to interpret. The interpreted program should not see the interpreter arguments when it queries for arguments and should see arguments meant for the interpreted program. But that's not difficult to do. Instead, I'm interested in styles on h...

Dropping a file onto a script to run as argument causes exception in Vista

edit:OK, I could swear that the way I'd tested it showed that the getcwd was also causing the exception, but now it appears it's just the file creation. When I move the try-except blocks to their it actually does catch it like you'd think it would. So chalk that up to user error. Original Question: I have a script I'm working on that I...

PHP function missed argument error ?

Hello everyone, In PHP I allow the user to enter a url and load a file, function, parameters accordingly with a simple routing file. A Url of http://localhost/user/edit/1 will call the file user.php and the function edit() inside it and pass the parameter 1 to it. If the user removed the argument 1 and the preceeding slash so a function ...

javascript missing ) argument

I'm getting this error with this javascript can anyone help me figure out what i'm doing wrong? $(this).prepend('<a class="booknow2 sidelink sidelinkNew" href="javascript:__doPostBack('SetSess','')"><img src="../../images1/button/leftEdge.png" width="4" height="35" style="float:left; margin:0; padding:0;" alt="book now" /><img src="../....

drupal multiple view arguments with PHP code validation for empty arguments

I have a view set up to accept 2 arguments. The url is like this: playlists/video5/%/%/rss.xml It works fine if I supply the url with 2 arguments like playlists/video5/front/coach/rss.xml. I have 2 arguments of "Taxonomy: Term" But I need it to run even if 1 or no arguments are supplied. It looks like you can do this with PHP Code under...

Difference when omitting the C++ template argument list

When can you omit the C++ template argument list? For example in Visual Studio 2010 this piece of code compiles fine: template<class T> Vec2<T> Vec2<T>::operator+ (const Vec2 &v) const { return Vec2(x + v.x, y + v.y); } If you inline the code, it actually compiles without any argument list. But is this really the same as the follo...

javascript too many constructor arguments

I'm trying to import a set of coordinates from an external javascript. I have to include about 78.740 elements in the constructor, but firefox just throws an error: "too many constructor arguments" Does anybody have any ideas? This is my code: function CreateArray() { return new Array( ... ... ... 78.740 elements later ... ); } ...

Javascript named function paramaters vs arguments object

If I have a function as such: function doStuff(arg) { arguments[0] = "4" + arg; console.log(arg); console.log.apply(null, arguments); } Clearly doStuff("name") prints "4name" twice. Do arg and arguments[0] point to the same thing? Can I use them interchangably. Is javascript doing anything internally that I should be aware a...

What are the arguments to main() for?

Everytime I create a project (standard command line utility) with Xcode, my main function starts out looking like this: int main(int argc, const char * argv[]) What's all this in the parenthesis? Why use this rather than just int main()? ...

How do I pass an anonymous subroutines when calling a Perl subroutine?

mysub gets a subroutine reference as its first argument. Can I simply call mysub(sub{some subroutine body here}) ? I.e. define an anonymous subroutine right at the call? Is the syntax OK (is it really a reference to sub that is passed)? ...

Connecting to mysql in ruby produces wrong number of arguments error (4 of 0) - how to debug?

I'm trying to connect to a hosted MySQL database from my Ruby script. require "rubygems" require "mysql" con = Mysql::new('host', 'user', 'pass', 'database') Running this results in: ArgumentError: wrong number of arguments (4 for 0) method initialize in untitled at line 4 method new in untitled at line 4 at top level ...

C Struct pointer as Parameter

I'm trying to pass a pointer to a struct in C but i cannot: float calcular_media(struct aluno *aluno) { Output warning: C:\WINDOWS\system32\cmd.exe /c gcc main.c aluno.c aluno.c:7:29: warning: 'struct aluno' declared inside parameter list What am I doing wrong? Thank you. ...

Javascript function argument handling

It seems the best way to deal with arguments in javascript functions is to require the caller to pass an associative array: example = function(options) { alert('option1: ' + options.a + ', option2: ' + options.b); } Now arguments are named and not needed in any particular order when calling this function: example({'b':'hello option...

How to pass a string to a function in Objective-C

I made a method like this: -(void) doSomething:(NSString *)str { } I call it like this doSomething(foo); It doesn't work. ...

How to pass arguments to stage instances in ActionScript 3?

I have an instance on my stage that I dragged from my library at design time. This instance links to a custom class who's constructor takes an argument. package { import flash.display.MovieClip; import flash.media.Sound; public class PianoKey extends MovieClip { var note:Sound; public function PianoKey...

Argument of type float does not match GLfloat?

im trying to do something here but that error shows up i really have no idea how to get it done right i tried to put all the variables in the Figure.h as GLfloat instead of just float and the same error keeps appearing any idea? here is my Figure.h Class Figure { public: Figure(float x,float y,float z); void Paramete...