Calling functions without the return


Is it possible to call a function that returns a value but disregard the return?

For example,

function test
  <do something>
  return true
end test

and then calling it but not being concerned with the return:
do test

this ultimately causes an exception as the “true” return confuses the “do” call.

STUnknownMessage - ERROR: No Such Command: ‘true’


Hi Paul,
just one of possible solutions, using “passing parameters by reference”
do test(@res)
put res

to test testresult
put “do something”
set testresult to “something was done”
end test


It woudl be nice if there was a cleaner way to call the function as defined:

void Test()

as an example

You shouldn’t really be using the do command, it can cause the code to run slower and will bypass the compiler so can let weird, unintended errors slip through.

I would use the “put” command:

put test()

This will run the function but then not do anything with the output. You will see the output in the log, but the return value will otherwise be ignored.

You can also change the function to a handler instead .

to handle test
  <do something>
end test

Then to call it:

1 Like

Thanks, this is interesting… what would be a ready reconer in the decision to use function over to?

I find the documentation doesn’t really come down on a hard preference or advisory “do it this way if…”

In our case we sue the functions to supply a return of success and additional info, but on some cases we are not worried about the return on that call the function



If you use a to handler, it can be called as either a command or as a function. The handler can return a value, which will be ignored if you call it as a command:
test // any return value is ignored
Or you can call it as a function and use the return value:
put test() into theAnswer

If you don’t want to change your function to a generic to handler, you can ignore the result in 3 different ways:

  • put test() – as Anne suggested, although this will display the value in the output
  • get test() – this will store the value in the variable it
  • put test() into void – store the value in the variable void (or any other dummy variable name you choose)
1 Like