[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:
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.
[Edit this page] [Page history] [What links here] [Discuss this topic] [Printer Friendly]
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.
[Edit this page] [Page history] [What links here] [Discuss this topic] [Printer Friendly]
