A return is a value that a function returns to the calling script orfunction when it completes its task. A return value can be any one of the fourvariable types: handle, integer, object, or string. The type of value yourfunction returns depends largely on the task it performs.

You use the Function Returns edit combo box in the General page of the NewScript dialog to tell JAWS the type of value the function returns. You alsotype the description of the return in the Return description edit box. Adding adescription for the return, helps you and anyone else using your function todetermine exactly what the value should be used for within the calling script orfunction.

When you create a new function that returns a string value, the ScriptManager places the following function beginning line into your script file:

String Function MyFunction ()

The "string" key word that precedes the "function" keyword tells you that the MyFunction function returns a string value to thecalling script or user-defined function.

## The Return Statement

You use the return statement to send a value back to the calling script oruser-defined function. This key word tells JAWS to return the specified valueto the calling script or function. You can return the value as a literal valueor within a variable. The syntax of a return statement that sends a stringvalue stored in a variable called sText back to the calling script or user-definedfunction follows:

Return sText

A return statement that returns a string of text, "This is astring", as a literal follows:

Return "this is a string"

When a function returns a value to the calling script or user-definedfunction, you must store that value in either a local or global variable. Youcan then use that variable to make decisions on what the calling script oruser-defined function should do next. An example of storing a string valuereturned by a function called MyFunction in a local variable follows:

### Example 1: Assigning the Output of a Function to a Variable

Script MyScript ()

Var

String sText

Let sText = MyFunction (); store the return value of MyFunction in sText

If sText != "" Then; the function actually returned a value other than null or nothing

SayFormattedMessage (OT_MESSAGE, sText)

EndIf

EndScript

You can also use the return value of one function as the parameter foranother. Using the previous example, the return value from MyFunction could bepassed directly to the SayFormattedMessage function without storing it in alocal variable first. The only disadvantage to this approach is that theMyFunction function may not retrieve any text. Therefore, theSayFormattedMessage function won't cause JAWS to speak anything. The examplereworked to use the return value of MyFunction as the parameter forSayFormattedMessage follows:

### Example 2: Using a Function as a Parameter For Another Function

Script MyScript ()

SayFormattedMessage (OT_MESSAGE, MyFunction()); use the return value from MyFunction as the message text for SayFormattedMessage

EndScript

Another example of a user-defined function that returns a value follows:

string function VerbosityLevelToggle(int iRetCurVal)

Var

int Verbosity

if not iRetCurVal then

; update it

VerbosityLevel ()

endIf

let Verbosity = GetVerbosity ()

if Verbosity == 0 then

return cmsg12_L; Beginner

elif Verbosity == 1 then

return cmsg13_L; Intermediate

elif Verbosity == 2 then

return cmsg14_L; Advanced

endIf

EndFunction

You can find the function shown above in the default script file. JAWSperforms this function each time you press **SPACEBAR** on the "UserVerbosity" entry in the Adjust JAWS Options dialog. The function begins bydetermining the value of the iRetCurVal parameter. If the value of theparameter is 0 or false, then JAWS performs the VerbosityLevel function tochange the verbosity level from its current value to the next value. Forexample, if you are using the beginner verbosity level, the VerbosityLevelfunction changes your verbosity level to intermediate. Next, the GetVerbosityfunction retrieves the verbosity setting now being used and stores it in theVerbosity local variable. The If statement then determines the value stored inthe Verbosity variable and returns the appropriate string of text to indicatethe new verbosity level. The actual text is stored in the Common.jsm JAWSmessage file found in your JAWS settings folder.

Back |

## FAQs

### How do you write a function that returns a value? ›

To return a value from a function, you must **include a return statement, followed by the value to be returned, before the function's end statement**. If you do not include a return statement or if you do not specify a value after the keyword return, the value returned by the function is unpredictable.

**What is a function that returns a value called? ›**

Functions that return values are sometimes called **fruitful functions**. In many other languages, a function that doesn't return a value is called a procedure, but we will stick here with the Python way of also calling it a function, or if we want to stress it, a non-fruitful function.

**What can value returning functions return? ›**

By definition, a value-returning function returns **a single value**; this value is returned via the return statement. Use void functions with reference parameters to return (modify) more than one value.

**How many return values are allowed in a function? ›**

A function can only return **a single object**.

**What is a function that returns a function? ›**

Functions that return a function aren't usually thought of as creating a function, but as **supplying parts of the arguments to a function at different times**. In languages that support a curried function argument syntax, you almost always use that instead of the way you wrote it.

**How can a function return two values? ›**

**By creating objects and labeling every return value**, multiple values from a function can be returned. Let us rewrite the above program of the user that has two variables name and age and return them by creating objects and labeling the return values. The different objects can be merged using the ... operator.

**Can a function return only ___ value? ›**

Based on what we have learned so far, functions can only return **a single value**, using the "return" mechanism.

**Which type of function returns the same value? ›**

A function that always returns the same result when called with the same arguments, and does not change any global data, is referred to as a **pure function**.

**What is the return type of a function? ›**

The result of a function is called its return value and **the data type of the return value** is called the return type. If a function declaration does not specify a return type, the compiler assumes an implicit return type of int .

**Why do we return a value in a function? ›**

Generally, a return value is used **where the function is an intermediate step in a calculation of some kind**. You want to get to a final result, which involves some values that need to be calculated by a function.

### Can a function return two times? ›

**We can return more than one values from a function by using the method called “call by address”, or “call by reference”**. In the invoker function, we will use two variables to store the results, and the function will take pointer type data. So we have to pass the address of the data.

**Which functions may return multiple values? ›**

You can return multiple values from a function using either a dictionary, a tuple, or a list. These data types all let you store multiple values. There is no specific syntax for returning multiple values, but these methods act as a good substitute.

**Can functions return any type of value? ›**

**A function may be defined to return any type of value, except an array type or a function type**; these exclusions must be handled by returning a pointer to the array or function. When a function does not return a value, void is the type specifier in the function declaration and definition.

**Do all functions have a return? ›**

Answer. **NO, a function does not always have to have an explicit return statement**. If the function doesn't need to provide any results to the calling point, then the return is not needed.

**When should a function return a function? ›**

A function should return **the value you want to return to the caller**. What that value is depends on the function's purpose. Often 0 and 1 are used to indicate success and failure, or failure and success, or false and true. Often a function returns a value that is computed from its parameters.

**What if a function returns something? ›**

When a return statement is used in a function body, **the execution of the function is stopped**. If specified, a given value is returned to the function caller. For example, the following function returns the square of its argument, x , where x is a number. If the value is omitted, undefined is returned instead.

**How many values can a return statement return? ›**

You can return only **one value** in Java. If needed you can return multiple values using array or an object.

**Is it possible for a function to return multiple values in go? ›**

**Go has built-in support for multiple return values**. This feature is used often in idiomatic Go, for example to return both result and error values from a function. The (int, int) in this function signature shows that the function returns 2 int s.

**When a function returns 2 or more values it is actually returning? ›**

In Python, when returning multiple values separated by commas, **all the values listed are actually wrapped inside a data type known as a tuple** , which looks like (1, 2, 3) . That tuple is returned, containing each value.

**Which functions do not return values? ›**

A function that does not return a value is called a **non-value returning function** (or a void function). A void function will automatically return to the caller at the end of the function. No return statement is required.

### Which functions Cannot return values? ›

The **void functions** are called void because they do not return anything. “A void function cannot return anything” this statement is not always true. From a void function, we cannot return any values, but we can return something other than values.

**Does every function must return a value? ›**

**If a function is defined as having a return type of void , it should not return a value**. In C++, a function which is defined as having a return type of void , or is a constructor or destructor, must not return a value. If a function is defined as having a return type other than void , it should return a value.

**Can a function print and return a value? ›**

Printing has no effect on the ongoing execution of a program. It doesn't assign a value to a variable. **It doesn't return a value from a function call**.

**Which functions return true or false values in Excel? ›**

The TRUE and FALSE functions

There are TRUE and FALSE functions in Excel as well. For instance, if you type “**=TRUE()” into a cell, it will return the value TRUE.** If you type “=FALSE()” it will return FALSE. There is no need to use these functions in standard situations.

**What function can return the value in Excel? ›**

The **INDEX function** returns a value or the reference to a value from within a table or range.

**What is an example of a value function? ›**

The VALUE function in Excel gives the value of a text representing a number. For example, **if we have a text as $5, this is a number format in a text**. Therefore, using the VALUE formula on this data will give us 5. So, we can see how this function gives us the numerical value represented by a text in Excel.

**Is there a formula for functions? ›**

This relationship is commonly symbolized as **y = f(x)**—which is said “f of x”—and y and x are related such that for every x, there is a unique value of y. That is, f(x) can not have more than one value for the same x. To use the language of set theory, a function relates an element x to an element f(x) in another set.

**What is an example of solving a function? ›**

Example: Solving Functions

**Given the function h(p)=p2+2p h ( p ) = p 2 + 2 p , solve for h(p)=3 h ( p ) = 3** . h(p)=3p2+2p=3Substitute the original function h(p)=p2+2p. p2+2p−3=0Subtract 3 from each side.

**What are the 4 types of functions? ›**

Constant Function: The polynomial function of degree zero. Linear Function: The polynomial function of degree one. Quadratic Function: The polynomial function of degree two. Cubic Function: The polynomial function of degree three.

**What is an example of a return type? ›**

A return type may be a primitive type like **int, float, double, a reference type or void type**(returns nothing). The type of data returned by a method must be compatible with the return type specified by the method. For instance, if the return type of some method is boolean, we can not return an integer.

### Which function returns the type of a variable? ›

The **gettype()** function returns the type of a variable.

**Does a method return a value? ›**

You declare a method's return type in its method declaration. **Within the body of the method, you use the return statement to return the value**. Any method declared void doesn't return a value and cannot contain a return statement.

**Which of the following are true about function return values? ›**

Explanation: True, **A function cannot return more than one value at a time**. Because after returning a value the control is given back to calling function.

**Where is the return value of a function stored? ›**

Where is it stored? Well, **it isn't stored**. It actually gets erased from memory. When we call a function, the function executes its code and after the return, that particular function call gets wiped out from working memory ( the browser is in charge of the cleanup task).

**Can a function continue after return? ›**

**No**. The reason is that after return the value your data type then next statement not work. The compiler ignore it.

**What type is returned by a function without a return statement? ›**

If no return statement appears in a function definition, control automatically returns to the **calling function** after the last statement of the called function is executed. In this case, the return value of the called function is undefined.

**Can a function return one value at a time? ›**

Explanation: True, **A function cannot return more than one value at a time**. because after returning a value the control is given back to calling function.

**Can a function return multiple values justify giving example? ›**

**You can return multiple values from a function in Python**. To do so, return a data structure that contains multiple values, like a list containing the number of miles to run each week. Data structures in Python are used to store collections of data, which can be returned from functions.

**Can a function return multiple values True or false? ›**

Explanation: **True, A function cannot return more than one value at a time**. because after returning a value the control is given back to calling function.

**What function returns multiple values in C++? ›**

While C++ does not have an official way to return multiple values from a function, one can make use of the **std::pair , std::tuple , or a local struct** to return multiple values.

### Can a function return a variable? ›

As you already know **a function can return a single variable, but it can also return multiple variables**.

**Can a function return a character? ›**

**Yes you can**. if the return type of main function is int or char in both case you can return either int or char.

**How do you write a function that returns a value in Python? ›**

The Python return statement is a special statement that you can use inside a function or method to send the function's result back to the caller. **A return statement consists of the return keyword followed by an optional return value**. The return value of a Python function can be any Python object.

**What is the function for returning value in Excel? ›**

The **INDEX function** returns a value or the reference to a value from within a table or range.

**How do you enter a formula in a cell to return a value? ›**

Enter a formula that refers to values in other cells

**In a sheet that contains columns of numbers, click the cell where you want the formula results to appear.** Click the first cell that you want to include in your calculation. Press RETURN. The result of the calculation appears in the cell.

**How do you write a function example? ›**

An example of a simple function is **f(x) = x ^{2}**. In this function, the function f(x) takes the value of “x” and then squares it. For instance, if x = 3, then f(3) = 9. A few more examples of functions are: f(x) = sin x, f(x) = x

^{2}+ 3, f(x) = 1/x, f(x) = 2x + 3, etc.

**What is an example of a function equation? ›**

Each functional equation provides some information about a function or about multiple functions. For example, **f ( x ) − f ( y ) = x − y** f(x)-f(y)=x-y f(x)−f(y)=x−y is a functional equation.

**How do I print a return value? ›**

If you just want to execute a simple function that returns a value, the return statement will be enough. In case you want to return a value but also have to print it to the terminal, you need to **use the print() method**. The print() method can be easily used for displaying the result of a function call to the user.

**Can you return a function in a function? ›**

**A function can return a function in Python because functions are treated as first-class objects**. This means that you can assign a function to a variable, pass it as an argument to another function, or use it as a return value in a function. Defining functions in other functions and returning functions are all possible.

**How do you convert a return value to a string in Python? ›**

Python has a built-in function **str()** which converts the passed argument into a string format. The str() function returns a string version of an object. The object can be int , char , or a string . If the object is not passed as an argument, then it returns an empty string.

### What does =$ D $44 mean? ›

$D$21:$D$44 is the **column of numbers to add, the amount column**. $B$21:$B$44 is the first criteria range, the region column. B10 is the first criteria value, the region. $C$21:$C$44 is the second criteria range, the department column.

**How do you return a value from a range of cells? ›**

**Use INDEX to Get the Value from a Cell by Referring to a Range**. If you have a range of cells and you want to get the value of the cell from a particular cell from that range. With the INDEX function, you can specify a range and use the index number and the function will return the value.

**How do I return a value from a table in Excel? ›**

**=INDEX() returns the value of a cell in a table based on the column and row number**. =MATCH() returns the position of a cell in a row or column. Combined, the two formulas can look up and return the value of a cell in a table based on vertical and horizontal criteria.

**How do I return a value from a cell that contains a number in Excel? ›**

To check if a cell contains a number or date, select the output cell, and use the following formula: **=IF(ISNUMBER(cell), value_to_return, "")**. For our example, the cell we want to check is D2, and the return value will be Yes. In this scenario, you'd change the formula to =IF(ISNUMBER(D2), "Yes", "").

**What is the value function in Excel? ›**

The VALUE function in Excel is **used to convert a text string that represents a number into a numeric value**. For example, if you have a cell that contains the text "123" and you want to use it in a calculation, you can use the VALUE function to convert it into the numeric value 123.