exit function with error

Questions about MultiCharts and user contributed studies.
turbofib
Posts: 213
Joined: 11 May 2013
Has thanked: 67 times
Been thanked: 1 time

exit function with error

Postby turbofib » 18 Feb 2020

hi,
see this code:

function :

input:num(numericSeries);

if num=4 then begin
print("input not correct");
break;

.......
.......
end;


it's not possibile to use break to exit function, it give me error

what can i use to exit function?

User avatar
rrams
Posts: 128
Joined: 10 Feb 2011
Location: USA
Has thanked: 7 times
Been thanked: 70 times
Contact:

Re: exit function with error

Postby rrams » 19 Feb 2020

Hello,
If you just want the function to exit without an error, you use the PowerLanguage keyword:

Code: Select all

#return;
If you want the function to abort with an error message you use the PowerLanguage keyword:

Code: Select all

RaiseRunTimeError("Message");

User avatar
Anna MultiCharts
Posts: 560
Joined: 14 Jul 2017
Has thanked: 42 times
Been thanked: 140 times

Re: exit function with error

Postby Anna MultiCharts » 28 Feb 2020

Hello turbofib,

The correct code would be:

Code: Select all

input:num(numericSeries); if num=4 then begin print("input not correct a"); #return; end; print("input is correct");
You may also want to check out ‘RaiseRunTimeError’ or ‘Abort’.


Return to “MultiCharts”