Qbasicnews.com
April 21, 2018, 02:37:46 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: Back to Qbasicnews.com | QB Online Help | FAQ | Chat | All Basic Code | QB Knowledge Base
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Quick Noob Question  (Read 5487 times)
wolfturn
New Member

Posts: 2


« on: March 16, 2009, 01:30:01 PM »

Lets say i made a function something like this.

Function name
         blah
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'

Logged
Clippy
Member
*
Posts: 84



« Reply #1 on: March 16, 2009, 04:07:01 PM »

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!
Logged

wolfturn
New Member

Posts: 2


« Reply #2 on: March 17, 2009, 10:07:23 AM »

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?
Logged
Clippy
Member
*
Posts: 84



« Reply #3 on: March 17, 2009, 11:30:13 AM »

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.

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

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

Ted



Logged

Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!