Task

Demonstrate the different syntax and semantics provided for calling a function.



This may include:

   Calling a function that requires no arguments
   Calling a function with a fixed number of arguments
   Calling a function with optional arguments
   Calling a function with a variable number of arguments
   Calling a function with named arguments
   Using a function in statement context
   Using a function in first-class context within an expression
   Obtaining the return value of a function
   Distinguishing built-in functions and user-defined functions
   Distinguishing subroutines and functions
   Stating whether arguments are passed by value or by reference
   Is partial application possible and how


This task is not about defining functions.




Procedure Saludo()
  PrintN("Hola mundo!")
EndProcedure
 
Procedure.s Copialo(txt.s, siNo.b, final.s = "")
  Define nuevaCadena.s, resul.s
 
  For cont.b = 1 To siNo
    nuevaCadena + txt
  Next
 
  Resul = Trim(nuevaCadena) + final
 
  ProcedureReturn resul
EndProcedure
 
Procedure testNumeros(a.i, b.i, c.i = 0)
  PrintN(Str(a) + #TAB$ + Str(b) + #TAB$ + Str(c))
EndProcedure
 
Procedure testCadenas(txt.s)
  For cont.b = 1 To Len(txt)
    Print(Mid(txt,cont,1))
  Next cont
EndProcedure
 
OpenConsole()
Saludo()
PrintN(Copialo("Saludos ", 6))
PrintN(Copialo("Saludos ", 3, "!!"))
PrintN("")
testNumeros(1, 2, 3)
testNumeros(1, 2)
PrintN("")
testCadenas("1, 2, 3, 4, cadena, 6, 7, 8, \'incluye texto\'")
 
Input()
CloseConsole()