Since you're passing the variable into the function it will be initialized automatically inthe beginning and destroyed automatically at the end. Basically, the function is self-contained. Aditionally, any variable DIMmed inside the function will be destroyed upon exiting the function.

The main issue with functions versus GOSUB is that the function is self-contained. It's it's own entity. youc ould also say a user-defined function is similar in behavior as a build-in KiXtart function. This is why we try to mimick a UDF as close as possible to the build-in functions with regards to input parameters and error handling.

Try this:
code:
dim $richard

$richard='value 1'
? 'Initial value : '+$richard
$return=fnExample($richard)
? 'Return value : '+$return
? 'Richard variable : '+$richard

Function fnExample($richard)
? 'entering function : '+$richard
$richard='value 2'
? 'exiting function : '+$richard
$fnExample=$richard
Endfunction



[ 07. March 2003, 14:47: Message edited by: sealeopard ]
_________________________
There are two types of vessels, submarines and targets.