parameter-passing

'pass parameter by reference' in Ruby ?

In Ruby, is it possible to pass by reference a parameter with value-type semantics (e.g. a Fixnum)? I'm looking for something similar to C#'s 'ref' keyword. Example: def func(x) x += 1 end a = 5 func(a) #this should be something like func(ref a) puts a #should read '6' Btw. I know I could just use: a = func(a) ...

Concise Method for Passing Associative Arrays to Method

Looking for a way to pass an associative array to a method. I'm looking to rewrite an Actionscript tween package in C# but running into trouble with "associative" arrays/objects. Normally in Actionscript I might do something like: public function tween(obj:DisplayObject, params:Object = null):void { if (params.ease != null) { ...

How do you pass a another control into a user-created ASP.NET control as a parameter in its decleration using the ID of the other control?

I'm trying to create a control (MyControl) which does things to other controls on the page it's on. It has a property: public property System.Web.UI.Control SomeOtherControl; I want to be able to set this property from the ASPX page that uses the control. Right now, the only way I can do it is in the Page_Load of the code-behind: MyC...

how to pass int/char into system() a Linux system call

Ok it might sounds dumb, but I couldn't figure out a way to pass int/char into this system call here is how I would like it to work system ("cal %d %d", month, year); I expect this will give me the following command on terminal "cal 3 2009" and the terminal will show me the calendar of March 2009. But the compiler is complaining ...

Pass by name and pass by value-result languages

For my programming languages course, I'm trying to write some code snippets in languages that use pass by name or pass by value-result, preferably by default, but any language that even supports either of those would be fine. However, I haven't been able to find a single language that supports either of them. Does anyone know of a langua...

Reporting Services: Overriding a default parameter with an expression in a linked report

So I've got a "daily dashboard" report in SSRS 2005. It has a parameter, @pDate, which defaults to "=Now". I'd like to use this same report in a linked report to show yesterday's final dashboard (which would then be mailed out via subscription), and override the parameter default with another expression, "=dateadd(d,-1,Now)." But when I...

ReportViewer Web Control and Dynamic Connection Strings

So I have a report in Reporting Services 2005. In it is one parameter (ConnectionString) which determines which data source the report will use. It also has several other parameters which are dropdown lists derived from the data source chosen in the ConnectionString parameter. In Report Manager, this works great. All of the dropdowns ar...

A general short guideline for passing method parameters by ref or by value ( C#) ?

Something like: if the value of the variable after the method call has to be returned : if can be instantiated before the method call use ref if does not need to be instantiated before the call use out if the value of the variable is used for returning , deciding or calculating other values from the method call do not use ref neither...

How can I pass MemoryStream data to unmanaged C++ DLL using P/Invoke

I need your help with the following scenario: I am reading some data from hardware into a MemoryStream (C#) and I need to pass this data in memory to a dll implemented in unmanaged C++ (using pointer ??). The data read (into stream) is very large (megabytes). I understand that I can P/Invoke this dll but what I am not sure is how to pas...

Passing Files as Parameters

Hello. I have created an example to introduce my question. public class Algorithm { // This is the best, but circumstances prevent me from doing this. /*public static void computeSomething(Data data) { // Compute some stuff }*/ public static void computeSomething(DataFileReader reader) throws IOException {...

How to pass a parameter from Batch file to a function inside a Powershell script

I have a Batch file which will call a Powershell Script : BATCH FILE : @ECHO OFF powershell ..\PowerShellScript.ps1 The powershell script in turn has a function which expects a parameter : POWERSHELL SCRIPT: function PSFunction([string]$Parameter1) { Write-Host $Parameter1 } Lets say i have a value : VALUE1 which needs to ...

experiencing lag in variable passing between popup and opener

Hey all, I am getting some strange (at least to me!) behaviour from the javascript in a web application I am developing. There is a popup window with a form. Upon validation and submission, the information from the form is aggregated into a comma-separated string. This string is then passed to opener window by assigning the string (da...

How do i set an optional parameter in PHP after the first optional parameter

Hi I'm fairly new to php and I am trying to figure how do I set an optional parameter after the first optional parameter? For example I have the following code: function testParam($fruit, $veg='pota',$test='default test'){ echo '<br>$fruit = '.$fruit; echo '<br>$veg = '.$veg; echo '<br>Test = '.$test; } If i make the following calls...

What does map(&:name) mean in Ruby?

...

PHP Variable Passing not working in database call.

This works. function get_distinct_size_for_bracelets() { $sql = "SELECT DISTINCT size FROM mytable WHERE id = 27 AND type='plastic' ORDER BY size"; } This does not work and stops php dead with no error reporting. function get_distinct_size_for_bracelets($myvalue) { $sql = "SELECT DISTINCT size FROM mytable WHERE id = 27 AND ...

how to pass parameters to a function in a .net dll via COM/VB6?

hi guys, i have a .net dll written in c# which reads data off a data source and acts as a wrapper to allow other apps to call its function to retrieve those data. the thing is i didn't anticipate the .net dll to be used for other than .net apps, so now i was told this all is going to be used in a vba/powerpoint macro which i figure is r...

PHP: string parameter to __construct not passed correctly.

Hi! I'm trying my hand at TDD with PHP and am writing a webbased app to access articles in a MySQL database; this is the test function: class TestArticleTestCase extends UnitTestCase { ... public function testArticleGenerateInsertSqlString() { $testArticle = new Article("12345", "2009-09-13 20:20:20", "Test heading", "Test text")...

NSIS get caller file path

I have an altered Java Launcher exe file written in NSIS that launches a JAR file (http://nsis.sourceforge.net/A%5Fslightly%5Fbetter%5FJava%5FLauncher). I want to pass into the JAR a parameter, that parameter being the absolute path of the file which called the exe. In a BAT file I can use "start MyApp.jar %1" and that fills in the abs...

Pass Value from Parent to child

i have create one MDIParent Form this mdiform exist following items button1, Button2 if we are click on button form 1 will be displaying that form1 form contain btNext Button if click the btNext from form1, the butoon2 (MDIForm buttom).. should be click then need to display the form2 i tried code is below inside the BtNext button ...

Assembly Function to C Program without Parameter Passing or Return Value

I need to create an assembly function that adds two positive numbers together, called by a C program. The C program would look like this: #include <stdio.h> int main(void){ int a = 0; int b = 0; int c = 0; printf( "Enter first number: " ); scanf( "%d", &a ); printf( "Enter second number: " ); scanf( "%d", &b ); sum(); printf( "Answer ...