Returning Values from Functions (2024)

InstallShield 2018

Like InstallScript’s built-in functions, user-defined functions can be designed to return a value to the caller. 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. (If the function prototype specifies a return type of void, the function cannot return a value.)

Many programmers use return statements to return error codes that indicate the success or failure of a function call. Most of InstallScript’s built-in functions use a return statement for that purpose. The return statement also is used commonly to create functions that return the result of an operation performed on parameters passed to the function, as in the example below, which returns the area of a rectangle:

function RectangleArea (nLength, nWidth)

INT nVal;

begin

nVal = (nLength * nWidth);

return nVal;

end;

The keyword return can be followed by a constant, a variable, a numeric or string expression, or a function call. In the example below, RectangleArea has been modified to eliminate the assignment statement; the arithmetic expression follows the keyword return:

function RectangleArea (nLength, nWidth)

begin

return (nLength * nWidth);

end;

The value returned by a function can be ignored by the calling program or function, tested in a conditional expression, or assigned to a variable. In the following example, the return value from RectangleArea is assigned to the variable nArea:

nArea = RectangleArea (nLong, nWide);

In the next example, the result of RectangleArea is tested in a conditional expression:

if (RectangleArea(nLong, nWide) > nMaxArea) then

MessageBox("Area exceeds maximum allowed.", INFORMATION);

endif;

To return more than one value or non-numeric values, use the BYREF operator to define parameters that are passed by reference.

See Also

BYREF Operator

Declarations

return

InstallShield 2018 Help Library

January 2018

Copyright Information | Flexera

Open topic with navigation

Returning Values from Functions (2024)

FAQs

How do you return a value from a function? ›

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.

How do you check if a function returns a value? ›

The most basic way is to use an if statement:
  1. if function() == value:
  2. print ("function returned ", value)
  3. else:
  4. print ("function did not return ", value)
Jul 20, 2022

How many values can a value returning function return? ›

Even though a function can return only one value but that value can be of pointer type.

How would you return a value from a function 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 a return statement in a function? ›

A return statement ends the execution of a function, and returns control to the calling function. Execution resumes in the calling function at the point immediately following the call. A return statement can return a value to the calling function. For more information, see Return type.

How do you return two values from a function? ›

Using Structures

Structures in C can also return more than one value from a function. In C, a structure is a user-defined datatype that may store multiple data types of the same or different types. The objective is to construct a struct with all essential data types as members and return that struct from our function.

When should a function return a value? ›

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.

What happens when a function returns? ›

The return statement can only be used within function bodies. When a return statement is used in a function body, the execution of the function is stopped. The return statement has different effects when placed in different functions: In a plain function, the call to that function evaluates to the return value.

What is the IF function to return a value? ›

Use the IF function, one of the logical functions, to return one value if a condition is true and another value if it's false. For example: =IF(A2>B2,"Over Budget","OK") =IF(A2=B2,B4-A4,"")

What is an example of return? ›

Examples of return in a Sentence

Verb We waited for you to return. She is returning home tomorrow. I'm leaving but will return at 2 p.m.

Do all functions return a value? ›

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.

How to return a value from a function? ›

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.

How to find the output of a function? ›

If a function is expressed as a graph, the inputs and outputs can be found by looking at the graph. Pick any point on the graph, and find its value along the bottom and left of the graph. The point's value on the bottom of the graph is the input, and the point's value on the left of the graph is the output.

What does values () return in Python? ›

The values() method returns a view object. The view object contains the values of the dictionary, as a list. The view object will reflect any changes done to the dictionary, see example below.

What is the function to return a value in Excel? ›

The INDEX function returns a value or the reference to a value from within a table or range. There are two ways to use the INDEX function: If you want to return the value of a specified cell or array of cells, see Array form.

How do you use the IF function to return a value? ›

Use the IF function, one of the logical functions, to return one value if a condition is true and another value if it's false. For example: =IF(A2>B2,"Over Budget","OK") =IF(A2=B2,B4-A4,"")

How to return values from functions in R? ›

We generally use explicit return() functions to return a value immediately from a function. If it is not the last statement of the function, it will prematurely end the function bringing the control to the place from which it was called.

Can you return a function from a function? ›

Functions are the same data as numbers or strings, so functions can be passed to other functions as arguments, as well as returned from functions. We can even define a function inside another function and return it outside. And this is not surprising.

Top Articles
What is Generic Routing Encapsulation (GRE)?
Glossary:Transport mode
Cpmc Mission Bernal Campus & Orthopedic Institute Photos
Spn 1816 Fmi 9
Brady Hughes Justified
O'reilly's Auto Parts Closest To My Location
Doublelist Paducah Ky
Whiskeytown Camera
Qhc Learning
Detroit Lions 50 50
Socket Exception Dunkin
Identogo Brunswick Ga
6001 Canadian Ct Orlando Fl
Hood County Buy Sell And Trade
Learn2Serve Tabc Answers
Uktulut Pier Ritual Site
Decosmo Industrial Auctions
Cincinnati Adult Search
Teen Vogue Video Series
R. Kelly Net Worth 2024: The King Of R&B's Rise And Fall
Magic Seaweed Daytona
Ecampus Scps Login
Elite Dangerous How To Scan Nav Beacon
The Procurement Acronyms And Abbreviations That You Need To Know Short Forms Used In Procurement
897 W Valley Blvd
Ewg Eucerin
Our Leadership
Allegheny Clinic Primary Care North
Mark Ronchetti Daughters
R/Orangetheory
Best New England Boarding Schools
Mumu Player Pokemon Go
NIST Special Publication (SP) 800-37 Rev. 2 (Withdrawn), Risk Management Framework for Information Systems and Organizations: A System Life Cycle Approach for Security and Privacy
Skroch Funeral Home
Rogers Centre is getting a $300M reno. Here's what the Blue Jays ballpark will look like | CBC News
Dr. John Mathews Jr., MD – Fairfax, VA | Internal Medicine on Doximity
Emerge Ortho Kronos
Myanswers Com Abc Resources
Craigslist Tulsa Ok Farm And Garden
Cranston Sewer Tax
Infinite Campus Parent Portal Hall County
968 woorden beginnen met kruis
Bcy Testing Solution Columbia Sc
2023 Fantasy Football Draft Guide: Rankings, cheat sheets and analysis
Birmingham City Schools Clever Login
Gt500 Forums
Samsung 9C8
Egg Inc Wiki
Acuity Eye Group - La Quinta Photos
Compete My Workforce
Primary Care in Nashville & Southern KY | Tristar Medical Group
Latest Posts
Article information

Author: Frankie Dare

Last Updated:

Views: 6363

Rating: 4.2 / 5 (53 voted)

Reviews: 84% of readers found this page helpful

Author information

Name: Frankie Dare

Birthday: 2000-01-27

Address: Suite 313 45115 Caridad Freeway, Port Barabaraville, MS 66713

Phone: +3769542039359

Job: Sales Manager

Hobby: Baton twirling, Stand-up comedy, Leather crafting, Rugby, tabletop games, Jigsaw puzzles, Air sports

Introduction: My name is Frankie Dare, I am a funny, beautiful, proud, fair, pleasant, cheerful, enthusiastic person who loves writing and wants to share my knowledge and understanding with you.