All Downloads are FREE. Search and download functionalities are using the official Maven repository.

simple3.examples.Functions.txt Maven / Gradle / Ivy

/*----------------------------------------------------
 * Demonstration of user-defined functions and scoping
 *--------------------------------------------------*/

// Define global variables to show that scoping works
a = 99
b = 22
 
// Function/Procedure that doesn't return a value
function SignOn() begin
  print "Functions - Demonstrates function calls"  
  print ""
end
 
// Function/Procedure with parameters that doesn't a value
function ShowCalculation(a, b) begin
  c = a + b
  print a + " + " + b + " = " + c 
  print ""
end

// Function that returns a value
function DoCalculation(a, b) begin
  return a + b 
end

i = SignOn()

i = ShowCalculation(3, 7)
 
print "DoCalculation(11, 13) = " + DoCalculation(11, 13) 
print ""
 
print "Validating that globals still are 99,22: " + a + "," + b




© 2015 - 2025 Weber Informatics LLC | Privacy Policy