parameters

How to pass parameters to a proc when calling it by a method? (ruby)

proc = Proc.new do |name| puts "Thank you #{name}!" end def thank yield end proc.call # output nothing, just fine proc.call('God') # => Thank you God! thank &proc # output nothing, too. Fine; thank &proc('God') # Error! thank &proc.call('God') # Error! thank proc.call('God') # Error! # So, what should I do if I have to pass the ...

Passing by reference and using ref

I looked at the similar questions and read some articles. THis article has some pictures which makes it clear. SomeObject so = new SomeObject(); somefunction(so); Console.write(so.x); // will print 1 SomeObject so1 = new SomeObject(); somefunctionByRef(so1); Console.write(so1.x); // will print 1 static void somefunction(SomeObject s...

Stored procedure: Searching in a table when passing an array of values

Hi, I need to create a stored procedure which receives a parameter (named @codes). This is a string which contains a list of codes separated by a semicolumn. I'd need to look inside a table and return all rows that have a code (which is in the column EANcodes) which was passed in the @codes parameter. Can anyone help me get started. M...

Dynamically passing parameters from ASPX host to Silverlight 4 xaml code-behind

Okay, first off, I'm new to Silverlight and am looking for someone to provide guidance as to whether the following solution is the prescribed way of going about this. Yesterday I started working on a problem that, at first blush, seemed pretty simple and straightforward. I need to pass a few parameters from an ASPX code-behind, which ho...

map<T,T>::iterator as parameter type

I have a template class with a private map member template <typename T> class MyClass { public: MyClass(){} private: std::map<T,T> myMap; } I would like to create a private method that accepts an iterator to the map void MyFunction(std::map<T,T>::iterator &myIter){....} However, this gets a compile error: identifier 'iterat...

How to pass parameters with hash in PHP

Hello, Recently when i saw google results page, the query and other parameters where passed with # (hash) instead of the usual "?" Also, in facebook i saw the same thing. This was quite interesting and after a simple search with google, i found the results related to perl and Ruby but no result with PHP. Is it possible to pass parame...

Purpose of static keyword in array parameter of function

While browsing some source code I came across a function like this: void someFunction(char someArray[static 100]) { // do something cool here } With some experimentation it appears other qualifiers may appear there too: void someFunction(char someArray[const]) { // do something cool here } It appears that qualifiers are onl...

Simple Django validation with multiple parameters issue

Hi everyone, I've been playing with Django for a couple of days and stumbled upon the following issue. I have the following models: Employee = (id, employeeName) Project = (id, projectName) Assignment = (fk_employee, fk_project, from_date, to_date) What I want to do is to create a validator that won't allow assignment periods to overl...

How do I pass a UDF scalar function into a stored procedure?

Trying to put a function call that returns an int into a call for a stored procedure. Getting "Incorrect syntax near '.'." usp_Document_ReserveForGrader '98832750-142F-4623-91F7-6E43C6F1A963', 12,dbo.Workflow_FirstProgress() ...

C#: does using ref/out for a method parameter make any difference if an object variable is being passed?

Possible Duplicate: Passing By ref and out C#: does using ref/out for a method parameter make any difference if an object variable is being passed? In C#, an object variable passes only a reference to the method, which means it is already a ref/out parameter. Is this correct? ...

NHibernate group by named parameters doesn't work with repeated parameters

My query in HQL is basically: select functionA(a, :paramA), functionB(b, :paramB), functionC(c, :paramC), sum(d) from tableA groupby by functionA(a, :paramA), functionB(b, :paramB), functionC(c, :paramC) However this gets turned into SQL of select functionA(a, @param0), functionB(b, @param1), functionC(c, @param2), sum(d) from table...

Java generic cast by parameter type

Hi, what, if at all possible, would be a good solution to implement the following desired functionality where I want to: Cast the return type of a routine to the type of the routine parameter, e.g., // Foo and Bar are two types of Common interface Common{} interface Foo extends Common {} interface Bar extends Common {} // Examp...

Is there any way to set parameter default as function of previous parameter? [C++]

I assume not, but I just wanted to check - is there any way in C++ to do something like the following? Obviously when I try the below I get a scope-based error about bar. void foo(Bar bar, int test = bar.testInt) { ... } ...

Parameters assigment with default values for a function

Hi, I have thread spawning function which accepts many parameters which have default values in the declaration. int spawn( funcptr func, void *arg = 0,int grp_id = 1,const char*threadname); I want to initialize first parameter func and the last parameter thread name and remaining variables assigned their default values. spawn( myfunc...

Using the argparse output to call functions.

Currently my code looks like this. It allows me to parse multiple parameters my program script gets. Is there a different way that is closer to 'best practices'? I haven't seen code actually using the output of argparse, only how to set it up. def useArguments(): x = 0 while x <= 5: if x == 0: ...

Passing parameters in REST? can I only pass strings or xml is allowed?

I have a customer table which consists of almost a 50++ fields. I was just thinking if would it be feasible if I pass these through a XML formatted text since their are a lot of parameters Sample Below: [OperationContract] [WebInvoke(UriTemplate = "new/customerxml/", Method = "POST", BodyStyle = WebMessageBodyStyle.Wrapped, ResponseFor...

Shell script parameter substitution

Can someone tell me what the difference is between these two conventions for getting the name of the currently running script? #!/bin/sh echo $0 echo ${0##*/} Does the second version strip the path from the script name? Thanks! ...

Free memory and nil in Delphi using a single function.

I have a lot of memory allocations and the same number of FreeMem calls. What I didn't have though is a check before calling freemem to see if the pointer was nil, and a line after freeing to set the pointer to nil. I tried to create a function to do this procedure FreeMemAndNil(p: Pointer; size: Integer = -1); begin if p <> nil t...

Powershell: call an exe with parameters from items in an array?

I have a set of commands that I'd like to run and do some returncode checks against the result, so i figured it would be easy to put them into an array for execution. Let's take this one as an example: C:\windows\system32\inetsrv\AppCmd.exe set config "Default Web Site/" /section system.webServer/webdav/authoring /enabled:true /commit:...

Accessing parameters in a webservice from a different application.

Hi, I have C# webservice webmethods hosted on a server and accessed by different applications(web,winforms etc). Is there any way i can detect that these parameters are sent from winforms, these are from webservices on a webservice? All they do is adding a web reference and passing parameters, i wish to see in my end what parameters t...