How to resolve the algorithm Return multiple values step by step in the Visual FoxPro programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Return multiple values step by step in the Visual FoxPro programming language

Table of Contents

Problem Statement

Show how to return more than one value from a function.

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Return multiple values step by step in the Visual FoxPro programming language

Source code in the visual programming language

*!* Return multiple values from a function
*!* The simplest way is to pass the parameters by reference
*!* either by SET UDFPARMS TO REFERENCE, or prefix the variables with @.
LOCAL a, b
a = 5
b = 6
? "Sum =", AddUp(@a, @b)    && Displays 11
? "a =", a, "b =", b        && Displays 4, 5
? "Sum =", AddUp(@a, @b)    && Displays 9

FUNCTION AddUp(n1, n2)
LOCAL n 
n = n1 + n2
n1 = n1 - 1
n2 = n2 - 1 
RETURN n
ENDFUNC

  

You may also check:How to resolve the algorithm Apply a digital filter (direct form II transposed) step by step in the Python programming language
You may also check:How to resolve the algorithm Floyd's triangle step by step in the ERRE programming language
You may also check:How to resolve the algorithm Polymorphic copy step by step in the Factor programming language
You may also check:How to resolve the algorithm Generic swap step by step in the JavaScript programming language
You may also check:How to resolve the algorithm Web scraping step by step in the FunL programming language