Skip to content

how can one break or stop or return from a script?

3 messages · Stu, Don MacQueen

Stu
#
Hi,

I am using a script to initialize variables in the global workspace.

Based on some condition, I would like to stop evaluation of a script
sourced on the command-line, without issuing an error.

My current solution is the following hack that uses a repeat { }
statement

----------- init.R -----------
#hack to enable setting of breakpoint
repeat {

...
if (condition) {
    break;
}

...

# remember to break !!
break;
} #end repeat
EOF

Thanks,
- Stu
#
I don't know how to do this in the way you describe.

Easy alternatives include:

  - putting the part of the script that is to be executed 
conditionally into a separate file, and then source it or not based 
on some condition.
   - simply wrapping the different parts of the script in if, then, else blocks.

-Don
At 1:37 PM -0800 11/16/09, Stu wrote:

  
    
Stu
#
Thanks ...
It's good to know I'm not missing the obvious.
- Stu
On Nov 16, 8:31?pm, Don MacQueen <m... at llnl.gov> wrote: