[Home]  [Edit this page]  [Recent Changes]  [Special Pages]  [Help
DotNet » Curl Content Language » userpage » QbasicFAQ_WhereToGetIt » Calculating and Validating NMEA Checksums » JAD » TurboCppHelloWorld » burst » Alpha » CDataType » QbasicFAQ_Function
What is a function?


Back to QBasic FAQ Main Page.

A FUNCTION is similar to a Declared SUB. It too is DECLAREd, and uses parameters that can be past when it is invoked. The main difference is that the FUNCTION is used more as a way to add to QB's already defined functions/commands. A function (typically), is used to do some mathematical operation. Be it a Boolean choice, or an algebraic function.

Once DECLAREd the FUNCTION can be used much like a command already in QB.

Example:

DECLARE FUNCTION Area (Length, Width)
'
INPUT "Enter the width"; W
INPUT "Enter the length"; L
Total = Area(L,W)
PRINT Total
END
'------------------------------------
FUNCTION Area (Length, Width)
Area = Length * Width
END SUB


Not the best example, after all, you could probably calculate the area, right there inline much faster, but it shows a simple example.

FUNCTIONs need not necessarily be mathematical in nature, the "SUB Center" example could easily have been a function instead. A FUNCTION needs to have at least on value to return when called.

last edited (December 9, 2002) by KDivad Leahcim, Number of views: 3140, Current Rev: 2 (Diff)

[Edit this page]  [Page history]  [What links here]  [Discuss this topic]  [Printer Friendly]  

Members

Username:

Password:


Register
Forgot Password?




Programmers Heaven - for .NET, Java, C/C++ and WEB Developers!
© 1996-2008 Community Networks Ltd. All rights reserved. Reproduction in whole or in part, in any form or medium without express written permission is prohibited. Violators of this policy may be subject to legal action. Please read Terms Of Use and Privacy Statement for more information. Site Management by Lars Hagelin at Kontantkort.se.