Task

Show how to return more than one value from a function.




 
include "ConsoleWindow"
 
local fn ReturnMultipleValues( strIn as Str255, strOut as ^Str255, letterCount as ^long )
dim as Str255 s
 
// Test if incoming string is empty, and exit function if it is
if strIn[0] == 0 then exit fn
 
// Prepend this string to incoming string and return it
s = "Here is your original string: "
strOut.nil$ = s + strIn
 
// Get length of combined string and return it
// Note: In FutureBasic string[0] is interchangeable with Len(string)
letterCount.nil& = strIn[0] + s[0]
end fn
 
dim as Str255 outStr
dim as long   outCount
 
fn ReturnMultipleValues( "Hello, World!", @outStr, @outCount )
print outStr; ". The combined strings have"; outCount; " letters in them."
 