argument-passing

PHP: Pass anonymous function as argument

我怕爱的太早我们不能终老 提交于 2019-12-05 15:02:21
问题 Is it possible to pass an anonymous function as an argument, and have it execute immediately, thus passing the function's return value? function myFunction(Array $data){ print_r($data); } myFunction(function(){ $data = array( 'fruit' => 'apple', 'vegetable' => 'broccoli', 'other' => 'canned soup'); return $data; }); This throws an error due to the Array type-hint, complaining of an object being passed. Alright, if I remove the type-hint, it of course spits out Closure Object , rather than the

Pass multiple files / folders from windows explorer to external application

流过昼夜 提交于 2019-12-05 13:33:32
Hi does anyone know how to get windows explorer to pass multiple files / folders through to an external app (c#) referenced in the registry? I am current able to act upon a single file / folder using the %1 syntax but not sure how to get explorer to pass through multiple items. Does anyone know how to do this? When you select multiple files in Explorer, your shell context menu extension's IShellExtInit::Initialize method will be called and pdtobj contains the selection. Note writing managed shell extension is not supported. I don't think this is possible. When you open multiple files using

Passing a character vector as arguments to a function in plyr

丶灬走出姿态 提交于 2019-12-05 10:01:42
问题 I suspect I'm Doing It Wrong, but I'd like to pass a character vector as an argument to a function in ddply . There's a lot of Q&A on removing quotes, etc. but none of it seems to work for me (eg. Remove quotes from a character vector in R and http://r.789695.n4.nabble.com/Pass-character-vector-to-function-argument-td3045226.html). # reproducible data df1<-data.frame(a=sample(1:50,10),b=sample(1:50,10),c=sample(1:50,10),d=(c("a","b","c","a","a","b","b","a","c","d"))) df2<-data.frame(a=sample

How can I pass arguments into SwingWorker?

偶尔善良 提交于 2019-12-05 07:19:11
I'm trying to implement Swing worker in my GUI. At the moment I have a JFrame containing a button. When this is pressed it should update a tab displayed and then run a program in the background thread. Here is what I have so far. class ClassA { private static void addRunButton() { JButton runButton = new JButton("Run"); runButton.setEnabled(false); runButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { new ClassB().execute(); } }); mainWindow.add(runButton); } } class ClassB extends SwingWorker<Void, Integer> { protected Void doInBackground() { ClassC

Magento custom admin module is blank

左心房为你撑大大i 提交于 2019-12-05 07:03:28
I've create a custom admin module but i can't put a content in it, it always is blank i'm trying with a simple code for test, but nothing seem to work public function indexAction() { $this->loadLayout(); $this->_addContent($this->getLayout()->createBlock('adminhtml/template')->setTemplate('uhmaadmin/contactos.list.phtml')->toHtml()); $this->renderLayout(); } an in the .phtml echo 'hello world'; but doesn't print nothing, if a make an error in the phtml, the system crash, it means that its getting the file, but, what i'm i missing please, help The $this->_addContent method on an admin

Arguments with Powershell Scripts on Launch

天大地大妈咪最大 提交于 2019-12-05 06:41:04
Like in C and other languages, you can give to the script/.exe arguments when you physically execute the script. For example: myScript.exe Hello 10 P Whereby Hello, 10 and P are passed to some variable in the program itself. Is this possible in Powershell? and if so, how do you give those args to a given $variable Thanks! Define your script with a param block like so: -- Start of script foo.ps1 -- param($msg, $num, $char) "You passed in $msg, $num and $char" You can further type qualify parameters as well e.g: -- Start of script foo2.ps1 -- param([string]$msg, [int]$num, [char]$char) "You

Passing a touch event to all subviews of a View Controller

被刻印的时光 ゝ 提交于 2019-12-05 02:10:10
问题 I have a view controller which creates multiple subviews on top of it. All subviews and the view controller accept touches. How can i communicate the touch point information to all the subviews on the screen? Keep in mind that each subview covers the entire screen so after a few additions its a bit like pages in a book. That is, any subviews below the top subview can't be touched directly by the user. I have tried using [self.nextResponder touchesBegan:touches withEvent:event] however this

Command line passing quotes within quotes

孤者浪人 提交于 2019-12-05 02:06:22
I've been searching for a solution to this but couldn't find one. Not sure if its possible. Can I pass into command-line execution that passes a in a bat file which has an input file as its arguments? So from the command-line it'll look like this: C:\run.exe "C:\space folder\run.bat "C:\space folder\input.txt"" The problem is with the folders that has spaces so the quotes are required to be in there. Try this: C:\run.exe "C:\space folder\run.bat \"C:\space folder\input.txt\"" And here is a link that you can see all escape characters http://www.robvanderwoude.com/escapechars.php I know it's an

How to pass an argument with space from bash script to bash script?

走远了吗. 提交于 2019-12-04 17:33:31
I have a script the manipulates data, creates arguments and sends them to a second script. One of the arguments contains a space. script1.sh: args=() args+=("A") args+=("1 2") args+=("B") . script2.sh ${args[@]} script2.sh: for f in "$@" do echo f=$f done I'd like to get "1 2" as single argument, but receive them separately: f=A f=1 f=2 f=B I tried also converting the input in script2 to list in=($@) and iterating over it using for f in ${in[@]} but got the same result. So, the problem might be in one of the following: building the list of arguments ; passing the built list ; parsing the input

What is the neatest way of passing flags to a Matlab function?

泪湿孤枕 提交于 2019-12-04 14:48:35
I'm designing a function that takes as argument one structure and any number of flags. The function will contain a couple of if s checking whether a specific flag is set. What is the neatest way to achieve this? I was thinking about passing the flags as separate string arguments. Is there a neater solution? I would do it like using varargin and ismember : function foo(arg1,arg2,varargin) flag1=ismember('flag1',varargin); flag2=ismember('flag2',varargin); flag3=ismember('flag3',varargin); And you can call the function like that: foo(a1,a2,'flag3','flag1') This will activate flag1 and flag3 .