terminating ALL m-scripts

hi all,
I'm currently working on TargetLink Code generation and I am facing problem to terminate the whole process if a problem is found:
>tl_generate_code.m
> tl_eval_hook.m
> pre_codegen_hook.m
"*pre_codegen_hook*.m" is called by "tl_eval_hook.m", which is likewise called by "tl_generate_code.m".
The problem I'm facing now is that I don't know how to terminate the WHOLE process if i find problem in the called script "*pre_codegen_hook*.m". I tried using the command "return" but it only brings me to the caller and it doesn't terminate the whole process. Although this is actually about TargetLink but I guess this is applicable in normal MATLAB script.

답변 (1개)

Robert Cumming
Robert Cumming 2011년 5월 5일

0 개 추천

use error
help error

댓글 수: 6

Qi Hao Goh
Qi Hao Goh 2011년 5월 5일
ahh I left out another script: In "pre_codegen_hook.m" another script "extrainfo.m" is called. :S
i just tried:
error('Terminated by user!')
in "extrainfo.m" but it continued to process the rest of the contents of "pre_codegen_hook.m".
any idea?
Robert Cumming
Robert Cumming 2011년 5월 5일
is it in a try catch block?
Qi Hao Goh
Qi Hao Goh 2011년 5월 5일
yea. but it didn't return the "catch" result though. And I don't expect that to be the case too :)
so error doesnt work with try catch block?
Robert Cumming
Robert Cumming 2011년 5월 5일
It will go into the catch part and then continue with the calling function. If you want it to throw an error use rethrow or similar
Qi Hao Goh
Qi Hao Goh 2011년 5월 5일
good one. Just that I can only edit "pre_codegen_hook.m" and "extrainfo.m". The rest are default script from TargetLink. :/
any other idea?
Robert Cumming
Robert Cumming 2011년 5월 5일
afraid not - apart from exit! Which will ofcourse close matlab itself...

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Language Support에 대해 자세히 알아보기

제품

태그

질문:

2011년 5월 5일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by