return-value

function keeps returning undefinded variable instead of array from php explode

the rgborhex function is returing an undefined variable: function rgborhex($unformatedColor){ if(strpos($unformatedColor, "-") == false) { //did not find a - in the color string; is not in rgb form; convert $rgbColor = hextorgb($unformatedColor); $rgbColor = explode("-", $rgbColor); return $rgbColor; } else { // found a - i...

What should I return for errors in my functions in C?

Hi, Currently I'm returning -1 in my custom functions in C if something wrong happens and 0 for success. For instance, working with a linked list and some function needs a non-empty list to work properly. If the list passed as argument is empty, I return -1 (error) and 0 if it's not empty and the function worked without a problem. Shou...

Java passing value

I have three programs, first does a selenium test import com.thoughtworks.selenium.*; import java.util.regex.Pattern; import junit.framework.*; public class MyTest extends SeleneseTestCase { int flag_eco; public void setUp() throws Exception { setUp("http://www.mysite.com/", "*iexplore"); } public void testMyTest() throws Excep...

Why Java return statment inside the catch block not working?

Why does the following code always return true even when an exception is thrown? public boolean write (ArrayList<String> inputText, String locationToSave) { try { File fileDir = new File(locationToSave); Writer out = new BufferedWriter(new OutputStreamWriter( new FileOutputStream(fileDir), "utf8")); ...

Something really dumb with return values

I'm doing something really dumb, and I don't see it. I've got an object doc with a method: -(float) currentOrient { return 50.5; } In another object, I call: -(void) showPage { float rot2=0; rot2 = [doc currentOrient] ; NSLog(@"SP rotation is %.2f", rot2); } However, the output is : SP rotation is 1112145920.0000...

What type should I use with this aggregate query?

I am just getting my feet wet with LINQ to SQL, and need some advice in implementing a simple scenario: I have a method ListTagCounts that is doing an aggregate query with LINQ To SQL. I was not sure of the return type to use, so used the ToList() method and created a class just for the return type in order to get it to compile. Schema...

What are the standard return values for a command line application?

I know that a command line application should return 0 on success. But are there any "standards" for what other values refer to? e.g. Invalid Arguments, etc. Are there differences under Windows and Unix? ...

Does a passed final variable in Java stay final on the other side?

I've just come across some code that's confusing me slightly; there are really 2 variations that I'd like to clarify. Example 1: public String getFilepath(){ final File file = new File(this.folder, this.filename); return file.getAbsolutePath(); } What would be the purpose of declaring file "final"? Since Java prim...

C-structs, NSObjects, float, int, double, ...

Hello, First of all: this is a though question, sorry for that, but I hope someone can help me! I'm making a UIML renderer on the iPhone. UIML is a language to describe interfaces. I want to render the XML and show the Interface on the iPhone. To inform you bettter, i first explain what I'm doing: <?xml version="1.0"?> <uiml> <in...

Returning a copy of an Object's self in C++

Ok, So I've googled this problem and I have searched stack overflow but I can't seem to find a good answer. So, I am asking the question on here that is particular to my problem. If it is an easy answer, please be nice, I am new to the language. Here is my problem: I am trying to write a method for a C++ class that is overloading an ope...

How to get all returned lines with each oracle errror message into one variable using perl

How do i get all of the lines of "$dblink is down" into one $l_msg string? Ideally I would like to get the error returned by oracle on failure and I cannot see a way to solve this. my $dblinks = $l_dbh->selectcol_arrayref("select dbname from db_link"); for my $dblink (@$dblinks) { my $l_results = eval { my ($l_erg) = $l_dbh->s...

Javascript dialog return

Hi, I've got a javascript function that draws a dialog. I'd like to have it return the value the user specifies. The problem is, the dialog is closed when a user clicks on of two buttons, which have onClick events assigned to them. The only way I know to grab these events is by assigning functions to them, which means that a return ca...

Why do we follow opposite conventions while returning from main()?

I have gone through this and this, but the question I am asking here is that why is 0 considered a Success? We always associate 0 with false, don't we? ...

Heap corruption issues

Inside my template function I have the following code: TypeName myFunction() { TypeName result; void * storage = malloc( sizeof( TypeName ) ); /*Magic code that stores a value in the space pointed to by storage*/ result = *(TypeName *)storage; free( storage ); return result; } This causes an "HEAP CORRU...

If a method returns an interface, what does it mean?

I see many methods that specify an interface as return value. Is my thought true that it means: my method can return every class type that inherits from that interface? if not please give me a good answer. ...

returning a Void object

What is the correct way to return a Void type, when it isn't a primitive? Eg. I currently use null as below. interface B<E>{ E method(); } class A implements B<Void>{ public Void method(){ // do something return null; } } ...

php callback appending an extra 0?

I am trying to write a simple Wordpress plugin, which updates a custom field value and increments it by one, and then echos the result which is handed back to my javascript code. For some reason, the data returned by the callback function always has an extra 0 appended to the end. function like_post_callback() { $clicked = $_POST['c...

Memory leak when returning object

I have this memory leak that has been very stubborn for the past week or so. I have a class method I use in a class called "ArchiveManager" that will unarchive a specific .dat file for me, and return an array with it's contents. Here is the method: +(NSMutableArray *)unarchiveCustomObject { NSMutableArray *array = [NSMutableArray a...

Fetching data (responsebody) with a HttpClient in an AsyncTask and returning the data outside the AsyncTask to the UI-thread

Basically I'm wondering how I'm able to do what I've written in the topic. I've looked through many tutorials on AsyncTask but I can't get it to work. I have a little form (EditText) that will take what the user inputs there and make it to a url query for the application to lookup and then display the results. What I think would seem t...

Getting stored procedure's return value with iBatis.NET

How can I retrieve the return value of a stored procedure using iBatis.NET? The below code successfully calls the stored procedure, but the QueryForObject<int> call returns 0. SqlMap <procedure id="MyProc" parameterMap="MyProcParameters" resultClass="int"> MyProc </procedure> <parameterMap id="MyProcParameters"> <parameter pr...