return-value

Proper way to return an array

Hey there, I never seem to get this right. I've got a method that returns a mutable array. What is the proper way to return the array and avoid potential memory leaks? If I plan to store the results locally inside another view controller, does that affect the way the array should be returned? Lastly, what if it's just an non-mutable...

unable to return 'true' value in C function

If Im trying to check an input 5 byte array (p) against a 5 byte array stored in flash (data), using the following function (e2CheckPINoverride), to simply return either a true or false value. But it seems, no matter what I try, it only returns as 'false'. I call the function here: if (e2CheckPINoverride(pinEntry) == 1){ PTDD_PTDD1 =...

FORTRAN function returning an array causes a segfault (calling from C++)

Basically, here's my problem. I'm calling someone else's FORTRAN functions from my C++ code, and it's giving me headaches. Some code: function c_error_message() character(len = 255) :: c_error_message errmsg(1:9) = 'ERROR MSG' return end That's the FORTRAN function. My first question is: Is there anything in there that would cause a s...

how to set a new value for a dijit.InlineEditBox

Hi All, i have problems to set a returned value to a declarative dijit.InlineEditBox the most near to a final solution was function(field,val,pid) { switch (field) { case 1: cell_name = "off_"+pid; break; case 6: cell_name = "saleprice_"+pid; break; default: break; } cell...

C++ -- return x,y; What is the point?

Hello, I have been programming in C and C++ for a few years and now I'm just now taking a college course in it and our book had a function like this for an example int foo(){ int x=0; int y=20; return x,y; //y is always returned } I have never seen such syntax. In fact, I have never seen the , operator used outside of parameter ...

Pick Return Values of Stored Procedure

Hi, I have a stored procedure that returns a result with 250!!! columns. But I only need 3 out of the 250. I want to call the SP and put only the 3 column values in a temp table. I don't want to define a temp table with 250 columns! This is how I would like to do it, but this doesn't work of course: create #myTempTable (id int, valu...

Throwing exception vs returning null value with switch statement

So I have function that formats a date to coerce to given enum DateType{CURRENT, START, END} what would be the best way to handling return value with cases that use switch statement public static String format(Date date, DateType datetype) { ..validation checks switch(datetype){ case CURRENT:{ return getFormattedDa...

can a function return more than one value?

can a function return more than one value? Edit Except return by reference. ...

Java: How can a constructor return a value?

$ cat Const.java public class Const { String Const(String hello) { return hello; } public static void main(String[] args) { System.out.println(new Const("Hello!")); } } $ javac Const.java Const.java:7: cannot find symbol symbol : constructor Const(java.lang.String) location: class Const System.out.println(new Co...

How to amend return value design in OO manner?

Hello. I am no newb on OO programming, but I am faced with a puzzling situation. I have been given a program to work on and extend, but the previous developers didn't seem that comfortable with OO, it seems they either had a C background or an unclear understanding of OO. Now, I don't suggest I am a better developer, I just think that I ...

jQuery Ajax returns the whole page

Dear all, I have a jquery-ajax function that sends data to a php script and the problem is with the return value, it returns the whole page instead of single value. Thank you for your time and help. $("#ajaxBtn").click(function(){ var inputText = $("#testText").val(); $.ajax({ type: "POST", url: "index.php", data: "testAjax="+inputTex...

Is there a work around for addEventListener callbacks with return value?

Hi, I'm currently experimenting with custom (level 2 DOM) events and I've now arrived at the problem that addEventListener() will not accept callbacks that return a value -- or at least I'm unfamiliar with the proper approach to this. Basically what I want is this: addEventListener("customEvent", function() { r...

What to Return? Error String, Bool with Error String Out, or Void with Exception

I spend most of my time in C# and am trying to figure out which is the best practice for handling an exception and cleanly return an error message from a called method back to the calling method. For example, here is some ActiveDirectory authentication code. Please imagine this Method as part of a Class (and not just a standalone funct...

How to make return value optional for a method,if possible ?

I have a method private static DataTable ParseTable(HtmlNode table) and sometimes this method has no return value then I want to make return value optional, is it possible ? I have tried with if condition.But there is error. How can I make return value optional for the method if possible ? ...

Return value from nested function in Javascript

I have a function that is set up as follows function mainFunction() { function subFunction() { var str = "foo"; return str; } } var test = mainFunction(); alert(test); To my logic, that alert should return 'foo', but instead it returns undefined. What am I doing wrong? UPDATE: Here's my actual co...

Returning object from function

I am really confused now on how and which method to use to return object from a function. I want some feedback on the solutions for the given requirements. Scenario A: The returned object is to be stored in a variable which need not be modified during its lifetime. Thus, const Foo SomeClass::GetFoo() { return Foo(); } invoked as: ...

C - how do i return multiple values from a function?

if i have a function that produces a result int and a result string how do i return them both from a function? as far as i can tell i can only return 1 thing, as determined by the type preceding the function name ...

Problem with returning values from a helper method in Rails

I want to print some objects in a table having 2 rows per object, like this: <tr class="title"> <td>Name</td><td>Price</td> </tr> <tr class="content"> <td>Content</td><td>123</td> </tr> I wrote a helper method in products_helper.rb, based on the answer of this question. def write_products(products) products.map { |prod...

C++ return a "NULL" object if search result not found

I'm pretty new to C++ so I tend to design with a lot of Java-isms while I'm learning. Anyway, in Java, if I had class with a 'search' method that would return an object T from a Collection< T > that matched a specific parameter, I would return that object and if the object was not found in the collection, I would return a NULL. Then in m...

Using a constructor for return.

Hi, Just a quick question. I've written some code that returns a custom class Command, and the code I've written seems to work fine. I was wondering if there are any reasons that I shouldn't be doing it this way. It's something like this: Command Behavior::getCommand () { char input = 'x'; return Command (input, -1, -1); } Any...