FAQ Database Discussion Community


Can't Override onPostExecute() method in AsyncTask Class

android,android-asynctask,return,return-value
I know there are several question which are quite similar to this one, but they didn't helped me so far. I'm still not able to override this AsyncTasks. Can you hel me? I already made sure that doInBackground() devlivers some type that onPostExecute() requires (Boolean in the first and JSON...

Incorrect command-line perl error value in $?

linux,perl,return-value
I am using command-line perl to perform a inplace substitution in a file. This is the code: (note the root perm with sudo) sudo perl -i -pe "s/foo/bar/" config.txt If this succeeds, 'echo $?' return 0. Now I make the file un-writable even for root using chattr like this: sudo...

Is my Java hello-world program correct?

java,parameters,return-value
I just started a Java Programming class and received my first assignment. I am tasked with the following Construct a simple flowchart that describes simple logic flow through a program (this is easy, I have done this) Translate said flowchart into pseudo code (I know this is easy, but still...

how can I display the information in a textbox from this code?

c#,textbox,return-value,boolean-logic,registrykey
I am working on a small tool that essentially looks for multiple installed software on the host computer. I found a piece of code that a much better programmer put together in C#, however, I'm wondering two things. 1. What do I replace with the registry title to search installed...

Best way to avoid 'control reaches end of non-void function' warning in release mode

c++,return-value,compiler-warnings,suppress-warnings
I have a class (here MyObject) with a function returning a name by refererence depending on the internal type of the object. Moreover, this function can only be called for some values of the internal type. /** * \brief Return the name depending of the internal type * \pre The...

APL return value of a function

return,return-value,apl
I want to know how to return a value after my function finishes running. I have, for example: FUNCTION X ? X ⍴ 10 //This means, generate X random numbers (X is the function's argument) within the range 1-10. I just want to know how I can return the value...

How to return a value inside of while loop

c#,while-loop,return-value
I have a method, return type is List<User>. In this method I have infinite while loop to accept information from another client over socket. Once a new client accepts, I will add this user into list and continue to listen for new client. I give the construction of the method....

struct.field returns another value, why?

c,struct,return,return-value
My goal is to create an fisrt of my custom struct type. When run, prints out 24. Can't undrestand why: #include <stdio.h> typedef struct strktura { int number; char name; } strktura; strktura new_one(int number, char name){ strktura a; a.number=number; a.name=name; } main() { strktura first=new_one(2,"A"); printf("%d\n",first.number); } ...

i want to remove double quotes from a string without replace function

javascript,arrays,regex,string,return-value
I want to remove Double Quote from string "Hello" word. I have array var ary = ['a', 'b' , 'c'] Now when I take value from array it's return into string like if I use ary[0] = "a" but I want in value like a . Because I have One...

How to use functions in c++?

c++,function,return-value
I am supposed to get the following code to display something along the lines of: "The sum of 1 to 10 is 55." (The larger number can be any number that was just the example I got.) I was given this code to use. #include <iostream> using namespace std; //...

Sharing values between methods

python,python-3.x,return,return-value
I thougth I knew how to use return in Python but something came up and i dont understand it. class Projet(object): def pathDirectory(self): pathDir= str(QFileDialog.getExistingDirectory(ui.pathTab1, 'Select Path','', QFileDialog.ShowDirsOnly)) return pathDir def goFunc(self, pathDir): # do function # HERE pathDir is a boolean and not a str with the path directory...

Getting a return value from id command in bash

bash,return-value
Trying to test if a user exists with the id command like the following: id -un username or just id -u username This works great, but I need to just evaluate true or false. Can someone help me understand how I just get back a true false from this command...

java - StringUtils.join() returning pointer

java,types,return-value,primitive
I was trying to join the elements of an array via the StringUtils.join(array, separator) method from the Apache commons library. Can anyone please explain me why I cannot get the resulting string and only a pointer to its location if I use an array of primitive types like int[] ?...

unable to return String in Java [closed]

java,string,return-value
import java.io.*; import java.lang.*; public class basics{ String input()throws IOException{ InputStreamReader isr = new InputStreamReader(System.in); BufferedReader br = new BufferedReader(isr); String type=br.readLine(); return type; } String work(String S){ int whitespace; int count=0; String wrd=new String[5] int lenghth=S.length(); int t=0; while(t<length){ if(S.charAt(t)=='') { whitespace++; count++; } else{ wrd[count]+=S.charAt(t); } Random rand...

return a js object from a javascript function that is called from a node cpp addon

node.js,npm,return-value
I am tyring to create and return a javascript function object from a function that is called from a c++ node addon. The object was getting created, but wasn't getting returned by the function. callback function that creates an object named cursor var callback_fn = function(record){ var res = new...

Tcl procedure return vs. set as return operator

function,tcl,return-value
Let us say that I have a procedure, and I wish to return a value of a variable local to the procedure. There are many ways to do that, but 2 very simple ones, are, at the very last line of the procedure puts either of these command (assume that...

How do I return a value within a while loop

python,while-loop,return-value
I'm working on an assignment for one of my CS courses. I've gotten this thing just about figured out, but I don't know how to return a value within my while loop. The problem I'm having is I need to add the quotient each time through the while loop until...

Android fragment null pointer exception on rootView [closed]

android,android-fragments,fragment,return-value
Can anybody help me with this I'm using the android navigation fragment template and I'm new-ish to android, I've just started adding some views to the fragment rootView and a TTS engine, but I'm coming up with an error when adding either the onClickListener to a button in my rootView...

SSIS return varaiable in Execute SQL task

ssis,sql-server-2012,return-value
I have a question for how to use 'return value' parameter in Execute SQL task in SSIS. I see there are 3 types of parameter in 'Parameter mapping' - input value, output value, and return value. I totally understand how to use input value and output value. But when I...

Java return value not working in if-statement [duplicate]

java,if-statement,methods,return-value
This question already has an answer here: How do I compare strings in Java? 23 answers I have an if statement that is supposed to compare the return value of a method, which I've set as a string, to determine which method to call next. However, the method doesn't...

C++ - Return by copy behavior [duplicate]

c++,return-value
This question already has an answer here: What are copy elision and return value optimization? 4 answers I am studying this little example below just to understand better the behavior of passing values by copy in C++. #include <iostream> using namespace std; class A{ public: A(){ cout << "A()"...

Return splitted value

java,regex,split,return-value
I'm having problems in splitting values in java. I have a string, and this must be split using the method .split(), but I need to return this value. For example I have this string: [#ff0000]red[#0000ff]blue Now I need you to return the value FF0000 for the red, and the value...

How to return a value of indeterminate type from a switch statement from a method

c#,switch-statement,return,return-value
I have the following switch statement: switch (SomeType) { case SomeType.A: var data = (Type_1)SomeType.Data; case SomeType.B: var data = (Type_2)SomeType.Data; case SomeType.C: var data = (Type_3) SomeType.Data; case SomeType.D: var data = (Type_4) SomeType.Data; case SomeType.E: var data = (Type_5) SomeType.Data; case SomeType.F: var data = (Type_6) SomeType.Data; }...

I need to set two 2d Arrays equal to one another

java,arrays,multidimensional-array,return-value
Im trying to take a 2D array, which I return in one method, and call it into another method and set a second 2D array equal to the values of the first. This is the first method: int xx = 23; int yy = 9; move(xx,yy, myArray); myNewArray = myArray;...

Importing config with parseconfig in ruby

ruby,return-value,config
I have a .publicancreators.cfg with that content: # Global name = Sascha Manns email_private = [email protected] Then i have defined a method: def self.config config = ParseConfig.new(File.join(File.dirname(__FILE__), '.publicancreators.cfg')) name = config['name'] email_private = config['email_private'] return %w(name email) end For using that i'm running inside my main program: a, b =...

Return Variable From Method

c#,variables,return-value
I know how to pass variables to a procedure, but how do I return a variable to the calling procedure? For example, this is my syntax, no issue at all passing in the variable arr but how can I return the value nummmm back to Main? Please disregard the empty...

parse.com - Get Object delay in iOS

ios,swift,parse.com,return-value
I would like to get an object and print it. So I have created a function that will deal with getting the object and returning it back. The problem is, the object is printed too early. This is my function: func getParseObject(){ println("i'm inside the function") var query = PFQuery(className:...

How can I comment out my Ruby return values with something like “# =>”?

ruby,comments,return-value,read-eval-print-loop
Having just started with Ruby and while following a tutorial, the result was shown as: a + b # => 3 I have never seen such a possibility; that seems so handy! Could you please tell me what it is? is it proprietary or is it for everyone?...

Returning an variable of class' type by value from the method

c++,copy,return-value,copy-constructor
Good day,gentlemens! Lets consider the code: class Test { int a; public: Test(){} Test( Test& t){cout<<"hello\n";} //copy constructor Test foo() { return Test();} }; int main() { Test t; } The issue is that given code isn't compiled.If we delete the copy constructor everything goes well. What is the problem?...

handling return from function where no return type is expected in some case in java

java,function,error-handling,return-value
I had writtern a piece of code:In this code we are calling validitem function to check if passes param is some valid item or not.If it is valid item,i want to return that item else i want to abort processing stating its not valid item.Please suggest solution for the initial...

How to make my method return a Collection instead

java,hashmap,return-value
My method should be called Public Collection<Character> mostCommonFirstWeighted() but the way I solve the problem is to make it return List<Map.Entry<Character, Integer>> How do I fix this so my return statement is a collection of characters instead? public List<Map.Entry<Character, Integer>> mostCommonFirstWeighted() { HashMap<Character, Integer> hashmap = new HashMap<Character, Integer>(); for...

how to set value float in C#?

c#,types,floating-point,return-value
i want to set 20770897 to C# float type but this is changed to 20770896 ! why? for example: float test = 20770897; value automatic changed to 20770896 ? help please. i am getting id from web service . these is return a float value but it is not true...

Recursive function in PHP function : how to prevent return value?

php,function,recursion,return,return-value
I am working on an API to get data, just like the other standard API, it limit on the return numbers of item , e.g. each page return only 1 item in my case. So , I have to get the total_count, page_size (it is 1 at my case), and...

Return multiple rows from a recursive stored procedure

sql,oracle,stored-procedures,return-value
I would like to return multiple rows as a result from a stored procedure. I am calling this stored procedure recursively, to read all nested values. This is my current procedure: CREATE OR REPLACE PROCEDURE TEST ( MATERIAL_H IN VARCHAR2, ) AS BEGIN FOR R IN (SELECT COMPONENT FROM TTP10.PSMS...

What if I need to differentiate 0 from NULL in C++?

c++,null,return-value
** Please don't criticize the purpose of the code itself. It's from Pat Morin's Open Data Structures book. Not my first choice, its assigned reading/practice. I just wanted to know if there is a way to differentiate, or a better way to go about this. Textbook--> http://opendatastructures.org/ods-cpp/** ** Another note:...

Extract return value from FOR loop

java,for-loop,return-value
I am trying to implement a method whose return value is defined into the for loop. However I always get eclipse telling me that I have to initialize it. But if I do this, and set it to say, null, it always stays null... What am I doing wrong? public...

Scala - Map with default value None?

scala,dictionary,return-value,options
Given trait A case class B extends A trait C I'm trying to implement something akin to this: val m = scala.collection.mutable.HashMap[String, C=>Option[A]]( ... //some pre-defined mappings ).withDefaultValue((_:C) => None) This will give me a type mismatch: expected: C=>Option[A], actual: C=>None.type I heard scala expects None to be returned from...

what does the function returns with in C program , in case if there is no return statement in the code

c,return,return-value
I made a function on how to reverse a singly linked list recursively in C. the function is as below. struct node * reverseSLL2(struct node *p,struct node *temp) { struct node *temp1; if(p!=NULL) { temp1=p->link; p->link=temp; reverseSLL2(temp1,p); //return; } else { return temp; } } I call head=reverseSLL2(head,NULL) , where...

Does anyone know if it is possible to return nothing in console for elisp after a function ends?

emacs,lisp,elisp,return-value
Right now whenever I try to not return anything, I get nil or t. The last spot of my function ends in an if statement that has nothing in the body. So like this: (if (counter<ten) () (...)) ...

Value Keeps Returning Early

ruby,return-value,primes
I'm writing a method that keeps returning a value early. I know how to write in a different way, but I would like to understand why writing it this way keeps returning the wrong value. I'm trying to get the "nth" prime number, and the below method seemingly works, and...

variable is not assigned in for loop despite EnableDelayedExpansion

batch-file,for-loop,return-value
I have the following batch script that is supposed to generate filenames on the fly. Unfortunately I can't get the function to assign a return value to filename. Each echo returns an empty line. @echo off setlocal EnableDelayedExpansion for /l %%i in (0,1,1) do ( call :create_filename %%i filename echo(!%filename%!...

Proper programming - should a function return a value on all code paths?

vb.net,return-value
My VB.Net class's constructor is passed a value for an Enum property. If I create a method in this class that uses Select Case statements, is it proper programming to include a Case Else line (that would never be executed)? I understand it, just want to know what is "proper"...

How do I pass variables from one Jframe (or class) to another in java?

java,swing,netbeans,return-value,encapsulation
I have looked at a couple of examples that would return values, but I don't fully understand how to make them work in my own code. I figured I should post it here and see if I can get some good pointers. I need to do a check to see...

What happens to unused return values?

java,garbage-collection,return-value
First I did look into this. I found the same question on here but in regards to C++: What happens to unused function return values? My interest is in Java (though the thread was indeed interesting). General consensus was that nothing really happens and if anything gets overridden later. Are...

Unable to return value from nested function in Javascript

javascript,function,return-value,nested-loops
Hey guys i prepare a project with html5 geolocation that will calculate the distance. I've got a problem with returning value from nested function in Javascript, can anyone help me ? Here is my code: /* DISTANCE CALCULATOR FUNCTION */ function distanceCalc(latitudeB,longitudeB) { var result; if (navigator.geolocation) { navigator.geolocation.watchPosition(showPosition); }...

Arrange divs in ASC order based on child inputs value

jquery,sorting,return-value
How would you order divs based on a child inputs value? I want to eventually get this to work on keyup. <div class="wrap_0"> <input class="sort_by" value="10"/> </div> <div class="wrap_1"> <input class="sort_by" value="3"/> </div> <div class="wrap_2"> <input class="sort_by" value="7"/> </div> Change to: <div class="wrap_0"> <input class="sort_by" value="3"/> </div> <div class="wrap_1"> <input...

Print the return value of user-defined function

function,tsql,return-value
I simply want to do this something like this for testing the function: PRINT fnctGeneric([argument]) I've searched around but can't find anything. Tried https://www.google.co.uk/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8#q=SQL+Print+function+return+value -- https://www.google.co.uk/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8#q=SQL+Print+return+value+from+user-defined+function --...

Function Overloading in AS3

actionscript-3,flash,return-value,return-type,function-overloading
I just read online that as3 does not support function overloading. I looked questions related to that here in the website but the answers don't seem clear enough to solve my problem. I tried overloading an event class the following way: public function SelectEvent(type:String, selecteditem:Buyer, bubbles:Boolean=false, cancelable:Boolean=false) { super(type,bubbles,cancelable); selectedbuyer...

How to return references to object created inside a method

c++,pointers,return-value,shared-ptr,return-by-reference
I am reasoning about the best approach to return references to objects created inside a method, like in the following situation: class A{ public: A(){} ~A(){} }; class Foo{ public: Foo(){} ~Foo(){} A& create(int random_arg){ // create object A and return its reference } }; void other_method(){ Foo f; A...

Is it advisable to have a getter that return a different value than that set by the setter?

python,return-value,getter-setter
I feel that this is practical for my purposes but also a bit confusing since one might expect to get the same output as the input. @property def value(self): return next( (option.key for option in self._options if option.id == self._value), None) @value.setter def value(self, value): idoption = None if isinstance(value,...

How can I get gmake to output return codes for all commands without modifying makefile

makefile,make,return-value,gnu-make
How can I get gmake to output exit status codes for all commands without modifying the Makefile? If modifying the Makefile was an option, something like the following is possible: $(CC) -c -o [email protected] $< $(CFLAGS); echo $$? Another way that I've found so far is to wrap the command...

Boolean return value?

python,boolean,return-value
def main(): num = int(input('Please enter an odd number: ')) if False: print('That was not a odd number, please try again.') else: print('Congrats, you know your numbers!') def number(): if (num / 2) == 0: return True,num else: return False,num main() I am trying to make it so that if...

Inconsistent Return Types for Functions in Swift

python,ios,swift,return-value
I have a function in Python with inconsistent return types: def my_function(input): if(condition1): return true if(condition2): return input Now, I want to convert it to swift. Does Swift support inconsistent return types for functions? If yes, how? If swift can do it, then I won't have to go through changing...

Why does a callback method needs to return something? [on hold]

java,interface,callback,return-value
I have never before seen such a thing, so let's say I have such listener object: MyWhateverListener dafuqListener = new MyWhateverListener() { @Override public void onSuccessCall(String s) { // success call } @Override public void onFailCall(boolean b) { // fail call } @Override public boolean onDafuqCall(int i, boolean b) {...

Return id after insert C# using SQL Server

c#,asp.net,sql-server,return-value,scope-identity
I know this question has been on this site many times, but I can't get my code working. I have an Insert statement, and I need the id from that statement on my asp.net page. I'm getting the return value 0. public int newid { get; set; } public void...

C: When to return by value or pass reference

c,pointers,reference,return-value
Although the subject is discussed many times, I haven't found any satisfying answer so far. When to return data from a function by return or to pass a reference to change the data on address? The classic answer is to pass a variable as reference to a function when it...

Return a function from a string variable that contains another function

javascript,jquery,function,return-value
I have a function in a string variable and I would like to perform the onclick of a button: <button onclick="ReturningTrue();">Click!</button> function ReturningTrue() { var stringValue = "var xyz = true; return xyz;"; return stringValue; } How can I get this onclick to work in such a way that it...

How to handle return of Abstract Objects

c++,pointers,reference,abstract-class,return-value
I'm facing the following situation: class Base{ virtual void Stuff() = 0; }; class ConcreteA : public Base{ void Stuff() {}; }; class ConcreteB : public Base{ void Stuff() {}; }; class Context { Base exec() { ConcreteA conc_a(); return a; } }; Of course the compiler gives me an...

How would I utilize a value returned from a method and implement it the main method in java?

java,methods,return-value
Can I pass the return value from a method into the main method then utilize that value in another method? That sounds confusing but let me try to explain it better with some code... public static void main(String[] args){ ArrayList<GeometricObject> geoList = new ArrayList<GeometricObject>(); findPositionLargestObject(geoList); System.out.println("BIGGEST OBJECT AT "+ maxIndex...