argument-passing

Best practices for number of arguments for subroutines in C

I've recently started working on developing APIs written in C. I see some subroutines which expect 8(Eight) parameters and to me it looks ugly and cumbersome passing 8 parameters while calling that particular subroutine. I was wondering if something more acceptable and cleaner way could be implemented . ...

C++: References as constructor arguments, help...

Hi, I have a base class(Base) whose constructor takes a reference as argument. In my derived class its constructor, I call the superclass-constructor and of course I need to pass a reference as argument. But I have to obtain that argument from a method of which the return type is by value... I will give a short example: class Base { p...

Function expects 2 arguments when should only one

I have a function friend_exists like this: def friend_exists(request, pid): result = False try: user = Friend.objects.get(pid=pid) except Friend.DoesNotExist: pass if user: result = True return result I'm calling it from my other function like this: exists = friend_exists(form.cleaned_da...

Django return redirect() with parameters

In my view function I want to call another view and pass data to it : return redirect('some-view-name', backend, form.cleaned_data) , where backend is of registration.backends object, and form.cleaned_data is a dict of form data (but both must be either sent as *args or **kwargs to prevent raising Don't mix *args and **kwargs in call ...

How to set parameter for flash in web application?

What's the best way to pass a predefined argument to flash? ...

Using arguments passed into a function iphone SDK

Hi, Wondering what I am doing wrong here. I am trying to pass an integer to my custom class and when I output the argument in the function is is some random number instead of what I pass. Here is my method call in RootViewController.m: int orgID = organObj.organID; NSLog(@"OrganID from RVC: %d", orgID); // this outputs the correct...

Getting parameters from a file via shell script into python script in the right format

I have the following shell script: #! /bin/sh while read page_section page=${page_section%%\ *} section=${page_section#* } #NOTE: `%* }` is NOT a comment wget --quiet --no-proxy www.cs.sun.ac.za/hons/$page -O html.tmp & wait # echo ${page_section%%\ *} # verify correct string chopping # echo ${page_section#* } # verify ...

Validating arguments to a method

Hello, I have a question on the best practice for validating arguments to a method when the arguments are contained within an object. For example, if you have: public class Student { public int getStudentId(); public String getStudentName(); public String getStudentSSN(); public double getStudentGpa(); public String...

perl - help passing/looping in arguments from file or within a separate perl data structure

I have a while loop that reads in a single file: my %MyItems = (); while (my $line = <>) { chomp $line; if ($line =~ m/(.* $mon $day) \d{2}:\d{2}:\d{2} $year: ([^:]+):backup:/) { my $BckupDate="$1 $year"; my $BckupSet =$2; $MyItems{$BckupSet}->{'MyLogdate'} = $...

AMFPHP overiding default function arguments?

I've got this odd problem. If I make a call on that function through amfphp service browser and give it a valid ID and leave the $num_images field blank amfphp will actually pass a blank string as the argument. // if i call this function width just an ID function getWorkers($id, $num_images = 100) { ... // num_images will be se...

Javascript: passing multiple arguments as a single variable

Hi, is it possible to pass multiple arguments using a single variable? For example, if I wanted to do something like: function foo(x,y){ document.write("X is " + x); document.write("Y is " + y); } var bar = "0,10"; foo(bar); The example above is an simplified example of what I was trying to do. It doesn't work (because the "...

Magento custom admin module is blank

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')->toHt...

powershell pass system.object[] without unrolling

any ideas on how I can pass the Get-PSCallStack with out having it unroll. It appears to be a system.object[] but from what i have read online they don't remain intact when passed and " unroll ". I tried placing a comma in front to prevent it but that did not work. function Pass-Callstack ([System.Object]$arg0) { Write-Host 'Start Pass-...

passing a value from flipsideviewcontroller to mainviewcontroller

Hi, i am tryng to pass a value from a slider on the flipside view to a instance variable on the mainview that i use to create a maximum user input number. I know that most of the code works as i can send a value across by initializing maxValue with a number in the (void) viewdidload. However, when i try to initialize it as shown below i...

Passing 2D arrays in C

I took a hiatus from C and am just getting back into it again. If I want to create a 2D array of doubles, I can do it two ways: double** m_array = (double**) malloc(2*sizeof(double*)); double* m_array = (double*) malloc(2*sizeof(double)); OR double array[2][2]; But, when I wish to pass the malloc'd array versus passing the other...

static method as default parameter to a class method

My question is about two answers to another question: http://stackoverflow.com/questions/3083692/using-class-static-methods-as-default-parameter-values-within-methods-of-the-same. I am trying to understand if there's really a difference between what the two answers do, and if so, what's the pros and cons of each. Question: how to use ...

Call Ruby script on multiple input files with wildcard

Hi, I am relatively new to Ruby and need to write a script that will handle mulitple input files. It should be called like so: script.rb -i file* where the directory contains multiple files, like file1.xml, file2.xml and so on. Just a quick question: How will this wildcard be expanded? Do I need to program that in my script? I am usi...

printf as argument of function

Usually usage of function: my_func("test"); Whether I can use this parameter so? my_func(printf("current_count_%d",ad_id)); int my_func(const char *key) ...