FAQ Database Discussion Community


Passing *arg arguments from list

python,function,arguments,argument-passing
I'm in a situation when I have to call one function foo: def foo(arg1,arg2,*args): pass The problem is that I have the *args arguments stored during computing as a list. Like this: a = 'arg1' b = 'arg2' list_of_args = ['arg3','arg4','arg5'] How can I call the function foo with this...

rails passing “each” argument in a view to a controller

ruby-on-rails,model-view-controller,argument-passing
I am trying to pass arguments from a "each" loop in a view to a controller. I have a list of contracts. The 'contract' model has a 'signed' attribute which is either nil or include a datetime if the contract is signed. I want to list all the contracts in...

Function does not recognize typedef argument

c,function,struct,typedef,argument-passing
okay, ive searched a solution for like two days now but i couldnt find whats going wrong with my code. ;( The task is simple: define a new type using typedef and have a function read out lines of this new type from a file into an array of again...

How to get current system time and cast in array?

c++,datetime,argument-passing
I want to get time and date separately to put it into an array. I would like the calling function to be like int date(int Day,int Month,int Year) but it isnt correct. How can I define arguments Year Month Day and Hour min sec of function to use them ?...

Calculate percentage Javascript

javascript,html,percentage,argument-passing
I have a question about javascript logic what I use to get percent of two inputs from my text fields. Here is my code: var pPos = $('#pointspossible').val(); var pEarned = $('#pointsgiven').val(); var perc = ((pEarned/pPos) * 100).toFixed(3); $('#pointsperc').val(perc); For some reason if my inputs are 600 and 200, my...

Passing string “classValue” from a C# Class to a C# form string “formValue”

c#,string,class,parameter-passing,argument-passing
I would like to complete a command in C# using a class called GenerateKeys inside the class there is a function called GenKeyA(classValue); this is called from the default button1_click event handler in Visual Studio 13, using the form string variable formValue like so. GenKeyA(formValue), and by doing this i...

$(this) selector works in jsfiddle but not on my script [closed]

jquery,this,argument-passing,replacewith
See jsfiddle example... http://jsfiddle.net/nnmEY/21/ Objective... Modify textarea via the select menu and or via direct input and have the textarea value passed on to the div. Issues... 1.) The script at the very bottom of the example below works fine in jsfiddle but not in the example. 2.) I'm also...

Segmentation fault in passing matrix to C function

c,segmentation-fault,argument-passing
I can't figure out what is wrong with this chunk of code (and couldn't find any advice from previous Q&A): #include<stdio.h> void fld(const int **b){ int i, j ; printf("Hello R\n"); for (i=0; i<3; i++){ for (j = 0; j<3; j++) printf("%d", b[i][j]); printf("\n"); } return; } int main(){ int...

How to make function argument optional in PHP?

php,function,argument-passing,optional-parameters,default-arguments
Suppose following is my function definition: public function addPhotoFeed($val) { ----------------------------- ------------------------------ ----------------------------- } In above function $val is an array that is passed as an argument to the same. Now I want to call the above function when I don't pass any argument. So how should I call it?...

What do we call the argument (variable or its value) of a function in Javascript?

javascript,function,arguments,argument-passing
OK lets take an example: function student(name,age){ document.write("I am " + name + "and I am " + age + " years old." ); } var student_name = "Divyansh"; var student_age = 17; student(student_name,student_age); // now my question is what do we call the arguments of the function student :...

Powershell parameter passing to function

function,powershell,argument-passing
I'm facing with an annoying problem: my script seemingly doesn't pass any argument to a function I've defined. $server = 'http://127.0.0.1:8080' Function Get-WorkingDirectory([string]$address) { #echo $address $content = Get-Content -path C:\....\file.txt $content -contains $address } #end Get-WorkingDirectory function if(Get-WorkingDirectory $server) { echo "works" } else { echo "error" } It...

JavaScript - If a function is passed as an argument, can it be returned as a string before the function is evaluated?

javascript,function,arguments,argument-passing
Consider the following code: function add(a,b) { return a + b; } function displayFunction(func) { console.log(_WHAT_SHOULD_GO_HERE_); // I want to log 'func' to the console } displayFunction(add(2,3)); // I want this to log "add(2,3)" Is this even possible to do in JavaScript?...

What is the meaning of … in parameter list in function prototype? [duplicate]

c,function,argument-passing,variadic-functions
This question already has an answer here: What does … mean in an argument list in C? 14 answers I saw a function declaration in C like this static _Noreturn void err_syserr(char *fmt, ...) What does the ... mean?...

Having an issue with running an external programs arguments in C#

c#,arguments,argument-passing
I have the following command which works fine in Perl my $bugcmd = `"C:\\Program Files (x86)\\McAfee\\VirusScan Enterprise\\scan32.exe" $source /all /archive /loguser /prompt /log $path$itemID.txt /autoexit`; However in C# I cannot for the life of me get the damn thing to create a log file in C# it scans it just...

x86 calling convention: should arguments passed by stack be read-only?

c,x86,stack,argument-passing,calling-convention
It seems state-of-art compilers treat arguments passed by stack as read-only. Note that in the x86 calling convention, the caller pushes arguments onto the stack and the callee uses the arguments in the stack. For example, the following C code: extern int goo(int *x); int foo(int x, int y) {...

Pass empty argument in java (to be parsed as not getting any agrument al all)

java,arguments,argument-passing
I was wondering if there is any way in java to pass an argument to a method which is actually read by java as not getting any argument at all. More concrete: I have got two versions of a method, one requiring one argument and the other none at all....

How to put arguments in a function at run time?

c++,linux,runtime,exec,argument-passing
So I am using execlp in my c++ program. execlp is of the form " int execlp(const char *file, const char *arg0,...,const char *argn)" meaning that it can take arbitrary amount of arguments. I just want to know that is there a way I can put arguments inside this function...

call_user_func_array to not accept unexpected function parameters

php,function,argument-passing,php-5.5
I have a function which accepts no parameters, i.e. function doSomething(){...}. If I run, call_user_func_array('doSomething', array('param1' => 'something')); it doesn't return an error. Can I make it force an error like, "This function should not accept parameters"....

Xpages Combobox setting values in managed bean

xpages,argument-passing,managed-bean
I am trying to pass arguments to a managed bean. The bean is configured and works, has two methods "getResponsible" and "setResponsible". Calling "myLookup.responsible" works. I cannot pass arguments to my bean, and can't figure out why. The below code does not work. <xp:comboBox id="comboBox1"> <xp:selectItems> <xp:this.value><![CDATA[#{myLookup.setResponsible("Something")}]]> </xp:this.value> </xp:selectItems> </xp:comboBox>...

Is it possible to pass argument via method reference?

java,java-8,argument-passing,method-reference
I have the following code line: MyClass{ Runnable job; ... } and inside one of the method: this.job = myImporter::importProducts; Now importProducts is method without arguments: public void importProducts() { ... } But I need to add argument to this method now. After adding new argument, line: this.job = myImporter::importProducts;...

`Cannot convert 'char(*)[50]' to 'char**' for argument '1' to 'void prac(char**)'` when passing a 2D array to a function [duplicate]

c++,function,char,argument-passing
This question already has an answer here: Correct way of passing 2 dimensional array into a function 6 answers I wanna pass 2D char array to function. However, an error comes: Cannot convert 'char(*)[50]' to 'char**' for argument '1' to 'void prac(char**)' How can I fix the code ?...

Operator overloading code compilation error, template argument deduction/substitution failure

c++,gcc,operator-overloading,argument-passing
I'm trying to apply some concepts of operator loading that I've learnt in the following C++ class. #include<iostream> using namespace std; class Point { private: int x, y; public: Point(int, int); Point operator+(const Point&); friend istream& operator>>(istream& in, Point&); friend ostream& operator<<(ostream& out, Point&); Point operator=(const Point&); }; Point::Point(int x...

How do I pass an int map[60][60] array from my main.cpp file to my findpath.cpp file in c++?

c++,arrays,argument-passing,multiple-files
Alright so I've got an array int map[60][60]; which gets populated by walls and with a start position and such in int main(). Later I call on my path finding algorithm which is located in another .cpp file string route=findPath(xA, yA, xB, yB); which passes random start and end points...

Threading a bool function passing string argument

c++,multithreading,c++11,argument-passing
I am new working with threads.. but I got the concept and have been playing with it in the last days. But now I am trying to create a thread calling a bool function and passing a string as argument. The code is basically: bool className::analyseData(const std::string& filename) { ......

call RMarkdown on command line using a.R that is passed a file

r,command-line,automation,argument-passing,rmarkdown
In summary, I am using my script 'Graphs.R' on 'input_file1.txt' in RStudio to create a Rmd which I then knit to html. I would like to automate this process to run more files on the command line. So far, I can get the Rscript to run on the command line...

make argument passing and multiple .PHONY targets

makefile,gnu-make,argument-passing
This Makefile .PHONY contains two targets: clean and cleanx. When I entered "make clean" or "make cleanx" worked fine. But, when I do "make" in the command line, it acts like "make clean". I expected that "make" should not do anything. There must be that I misunderstood. Would you explain...

Clojure single function argument of large hash-map?

dictionary,clojure,hashmap,argument-passing,destructuring
I'm trying to parse the result of an old API that returns CSV data (with no header). The parse-response function works great, but when I try to check with verify-response it fails with ArityException Wrong number of args (0) passed to: PersistentHashMap. How can I pass the hash-map through a...

In R: use system() to pass python command with white spaces

python,r,system,whitespace,argument-passing
Im trying to pass a python command from R (on Windows x64 Rstudio) to a python script via the command promt. It works if I type directly into cdm but not if I do it via R using the R function system(). The format is (this is how I EXACTLY...

Multiple arguments to function called by pthread_create() - argument is function pointer

c++,pthreads,function-pointers,argument-passing
My case is similar to another Question. I would like to pass a function as argument and an integer value. Testing the case with a simplfied construction: void print (int x, int y) { cout << "x = " << x << ", y = " << y << endl;...

Passing shell command to a terminal application from an App in Mac

python,osx,argument-passing,exit-code,py2app
I have frozen a python based GUI script using Py2app successfully but I run into trouble using this app on Mac. This app is supposed to send arguments/parameters to Clustal, a terminal-based application, but it instead returns an error non-zero exit status 127, '/bin/sh: clustal: command not found'. I found...

Java code, passing arguments to method

java,argument-passing
I'm not sure what I did wrong here, this is my code package methods; public class example { public static int sum(int x, int y){ return x+y; } public static void printSomething() { int a = 1; int b = 2; System.out.println("The sum of "+ x + " and "+...

Function does not return any value in C

c,argument-passing
I'm trying to make a calculation in C and trying to return the result value of a mathematical calculation but nothing prints out to screen when passing to main fuction. I have tried various methods but something is missing. Can you help me correct the code in a way that...

How to pass argument to callback and don't lose bind?

javascript,jquery,callback,argument-passing
I have the following code: $.getJSON('getAllTerminals.json', renderTerminalsOnMapAndFitBounds.bind({index:globalRequestCounter++, navigateToTypedText:true})) ... function renderTerminalsOnMapAndFitBounds(data, updateSelectedTerminals) { renderTerminalsOnMap.call(this,data); fitBounds(); if(this.navigateToTypedText === true){ navigateMapToTypedAdress(); } if (updateSelectedTerminals) { $.getJSON('getSelectedTerminals', {}, function (json) { window.MARC.addTerminalPage.terminalsSelected = json; update(); initPage(); }); } } Can you...

Batch echo string is capped when passed as argument

csv,batch-file,for-loop,argument-passing
I run the batch script on below on a csv file. @echo off set "filename=test.csv" for /f "USEBACKQtokens=*" %%A in ("%filename%") do ( call :myecho "%%A" ) pause :myecho echo %1 GOTO :eof A typical line in the csv file looks like this: Text and some more 2/11/2015,A234,Mr. Example Guy,18217.01,"$20,729.89","$4,111.06","$4,453.08"...

Functional-style JavaScript: good practice to avoid argument mutation?

javascript,functional-programming,argument-passing
This is a rather general question. Functional-style programming promotes the idea that a program is about transforming data through functions, and that mutation should be avoided (except possibly within a function, seen as a basic unit of abstraction). But in this program: function foo (bar) { bar.k1 = "bananas"; return...

PowerShell Splatting the Argumentlist on Invoke-Command

powershell,argument-passing,invoke-command
How is it possible to use the parameters collected in a hash table for use with ArgumentList on Invoke-Command? $CopyParams = @{ Source = 'E:\DEPARTMENTS\CBR\SHARE\Target' Destination = 'E:\DEPARTMENTS\CBR\SHARE\Target 2' Structure = 'yyyy-MM-dd' } Invoke-Command -Credential $Cred -ComputerName 'SERVER' -ScriptBlock ${Function:Copy-FilesHC} -ArgumentList @CopyParams Whatever I try, it's always complaining about the...

How to send a variable between two C programs

c,pipe,exec,fork,argument-passing
I have a C program, xyz.c which does some computations on a certain variable, say transferme. I want to transfer this variable/ pass this variable to another C program, say jkl.c. I have been trying to do the following: Fork the xyz.c and use execvp() to pass this transferme to...

JS: this reference does not work [duplicate]

javascript,jquery,this,argument-passing
This question is an exact duplicate of: Using this in event handler in strict javascript? 3 answers I want to encapsulate my Javascript code for certain objects in structures as indicated below. However, I ran into trouble with the semantics of this. While this during tiles.init() refers to the...

How to parse same argument twice or more than once to python script?

python,argument-passing
I have written a python script which uses argeparse module for handling arguments. e.g. Test_Dual.py -g Linux Now, I want to give it two options for same argument, like Test_Dual.py -g Linux -g ESX -g Windows How can I do that?...