return-value

Returning multiple values

I have a function that identify coordinates on a page, and I am returning them as a Dictionary<int, Collection<Rectangle>> GetDocumentCoordinates(int DocumentId) However, later I need information about each page - if it was validated, what is the page resolution, color/bw, etc. I could create another function and run through pretty mu...

Java Generics: How do i make the method return type Generic?

Consider this example (typical in OOP books): I have an Animal class, where each Animal can have many friends. And subclasses like Dog, Duck, Mouse etc which add specific behavior like bark(), quack() etc. Here's the Animal class: public class Animal { private Map<String,Animal> friends = new HashMap<String,Animal>(); public v...

Velocity and ignoring java method return

I want to add an element to the list in my Velocity macro. Is this only way to avoid 'true' text appearing to the Velocity output? #set($path = []) #set($swallow = "a") #set ($swallow = $path.add("blaablaa")) ...

Does any Common Lisp function return 3 values?

Does any Common Lisp (builtin) function return more than 2 values? I know many that return 2, but I can't think of one that returns 3. (I saw a comment here about returning more than 2 values, and tried to think of a case where CL did this, but can't.) ...

Send Return Code back from child script to the Parent script

My child script can create a rc=110 when a FTPed file is not located. The Parent script sets the Error Handling RC=1. I want the Error Handling to set to the RC created in child script. Any ideas? ...

Should I return TRUE / FALSE values from a C function?

After programming in C for several years, I realized that I have been ignoring the C convention of returning zero from a function to indicate success. The convention seems semantically wrong to me, as zero is of course false. The problem is I like to name functions like is_valid_foobar(), and in order to accomodate the convention of '...

Can I avoid casting an enum value when I try to use or return it?

If I have the following enum: public enum ReturnValue{ Success = 0, FailReason1 = 1, FailReason2 = 2 //Etc... } Can I avoid casting when I return, like this: public static int main(string[] args){ return (int)ReturnValue.Success; } If not, why isn't an enum value treated as an int by default? ...

How do I return hundreds of values from a C++ function?

In C++, whenever a function creates many (hundreds or thousands of) values, I used to have the caller pass an array that my function then fills with the output values: void computeValues(int input, std::vector<int>& output); So, the function will fill the vector output with the values it computes. But this is not really good C++ style...

Returning values...(Edited with new code and more questions) - illegal start of expression

These are my questions: I'm getting a couple of errors on the line "public static boolean validNumCheck(String num){" - "illegal start of expression", "';' expected", and "')' expected". How can I give the user 3 tries in total for each number? I believe right now the programme asks the user for 3 numbers and gives them 3 tries in tota...

Can I return a List from a LotusScript Function?

I want to return a List from a Function in LotusScript. eg. Function myfunc() List As Variant Dim mylist List As Variant mylist("one") = 1 mylist("two") = "2" myfunc = mylist End Function Dim mylist List As Variant mylist = myfunc() Is this possible? If so, what is the correct syntax? ...

Passing a string value to Inno Setup from command line app

The scenario is that we have a client/server app with the client install being a bootstrapper using Inno Setup that downloads the client from the server specified by IP/Port number. We'd like to be able to detect if there is a server on the local network via UDP broadcasting, and can write a console app that does that. Problem is, how ...

Good ASP.NET MVC pattern for form submit and immediate result display

I hear everyone recommends redirecting the user (HTTP GET) after he submits the form (HTTP POST). It's clean, there is no "do you want to resend" alert, it's simple... But, what if I want to show some result to the user? Okay, I can add some parameter to the GET url, like "/?message=1" and then check for that parameter.orm But, what ...

Byte array as an out parameter not recognized

I had a webmethod working which returned a byte array to the caller: public byte[] DownloadPDF(string URI) I had to change this to return another output (a string). So, I decided to change the method completely by now returning void and having 3 parameters like this: public void DownloadFile(string URI, out byte[] docContents, out st...

How do I get my widget not to crash if there is no value in a xml node?

I'm getting an xml file and want to get data from it. The source of the xml doesn't really matter but what I;ve got to get a certain field is: tracks = xmlDoc.getElementsByTagName("track"); variable = tracks.item(i).childNodes.item(4).childNodes.item(0).nodeValue; Now this works like a charm, EXCEPT when there is no value in the node....

Add image to listbox

Hi, I have a few images with some text, I need to show the image with the relevant text in a listbox. Browsing google I came across this sample class, public class Customer { public string Fname; public string Lname; public Customer(string firstName, string lastName) { Fname = firstName; Lname = lastName; } public overri...

Passing functions which have multiple return values as arguments in Python

So, Python functions can return multiple values. It struck me that it would be convenient (though a bit less readable) if the following were possible. a = [[1,2],[3,4]] def cord(): return 1, 1 def printa(y,x): print a[y][x] printa(cord()) ...but it's not. I'm aware that you can do the same thing by dumping both return value...

PowerShell converts values returned from function. How to avoid this?

I am trying to return List< T> from PowerShell function, but get one of: null - for empty list System.Int32 - for list with one element System.Object[] - for list with more elements Code: function CreateClrList { $list = New-Object "System.Collections.Generic.List``1[System.Int32]" $list.Add(3) $list } Write-Host (Creat...

Should functions that only output return anything?

I'm rewriting a series of PHP functions to a container class. Many of these functions do a bit of processing, but in the end, just echo content to STDOUT. My question is: should I have a return value within these functions? Is there a "best practice" as far as this is concerned? ...

What does IAlertNotifyHandler's OnNotification() return value do?

BY now I've created a number of custom alert handlers for SharePoint 2007 using the IAlertNotifyHandler interface. Using this interface you have to implement a method called OnNotification(), which has the following signature: bool OnNotification (SPAlertHandlerParams ahp); As you can see this method should return a boolean value. The...

Catching return codes in production environments?

Hi All, I want to know if check for return codes for all of functions that we write for production environment. for e,g, i use C a lot and do u catch the return codes for the standard library also, not just the functions that you write , but the 3rd party API/standard library/any other library. Most code i see in production do not do t...