Re: Functions? I'm Lost!!

new topic     » goto parent     » topic index » view thread      » older message » newer message

The following code defines a function that returns the number 5 and uses
it:

integer a          -- Define an integer named "a"
function return5() -- Define the function "return5"
    return 5       -- Return 5
end function
a=return5()        -- Get return5() to return its value and assign it to "a"
? a                -- Print the integer "a", just to test it out

The following code defines a function that returns the absolute value of a
number and uses it:

function abs(atom number) -- Defines abs().
    return sqrt( number * number ) -- Behold the magic formula!
end function
? abs(-54)                -- Should say 54

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu