Difference between revisions of "Return"
From Hercules Wiki
(Created page with "==Syntax== *'''return''' [<return value>]; ==Description== This command causes the script execution to leave previously called function with callfunc or script with [[cal...") |
Latest revision as of 09:39, 9 June 2013
Syntax
- return [<return value>];
Description
This command causes the script execution to leave previously called function with callfunc or script with callsub and return to the location, where the call originated from. Optionally a return value can be supplied, when the call was done using the function form.
Using this command outside of functions or scripts referenced by callsub will result in error and termination of the script.
Examples
set .@var,callsub(L_myAddition,.@a_val,.@b_val); mes "The result is "+.@var+"."; close; L_myAddition: return getarg(0)+getarg(1);
set .@var,callfunc("MyAddition",.@a_val,.@b_val); mes "The result is "+.@var+"."; close; ... function script MyAddition { return getarg(0)+getarg(1); }
Assuming .@a_val and .@b_val being 1, both examples would yield a message displaying, that the result is 2.
mes "Oh no..."; close2; callsub L_scream; end; L_scream: npctalk "Iiiiiiiiiiiiieeeeeeeeeeeeeeeeeeeeeeeeek!!!"; return;