Quick Noob Question - Printable Version

+- Qbasicnews.com (http://qbasicnews.com/newforum)
+-- Forum: Qbasic "like" compilers/interpreters (http://qbasicnews.com/newforum/forum-5.html)
+--- Forum: FB Discussion & Programming Help (http://qbasicnews.com/newforum/forum-15.html)
+--- Thread: Quick Noob Question (/thread-10206.html)

Quick Noob Question - wolfturn - 03-16-2009

Lets say i made a function something like this.

Function name
End function

How would i go about calling it later on?

If i'm not mistaken its the call command? But i can't seem to 'Call name'

Re: Quick Noob Question - Clippy - 03-17-2009

Functions are normally not called. They are referred to in program statements and the return is used by the program just like any other function. There is not a CALL like SUB's use!

Re: Quick Noob Question - wolfturn - 03-17-2009

So Functions arent used to display text? If thats the case, then how would i go about making a sub that can return a value? Or just hold a Global Variable and change it?

Re: Quick Noob Question - Clippy - 03-17-2009

Well, they could display PRINTs of text, but usually you use a SUB for that. Functions receive parameters passed to them and return ONE result normally. I have seen functions return more than one value by using a parameter also.

SUBs can return multiple values and must be called.

A Function can use INPUT, PRINT, etc. It can also fill an array. The Function name returns the value desired. It can pass strings or any type of number.

FUNCTION Average!(num1%, num2%, num3%)
       sum% = num1% + num2% + num3%
       Average! = sum% / 3

PRINT "The average is:"; Average!(one%, two%, tre%)