/* * pynest-init.sli * * This file is part of NEST. * * Copyright (C) 2004 The NEST Initiative * * NEST is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 2 of the License, or * (at your option) any later version. * * NEST is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with NEST. If not, see <http://www.gnu.org/licenses/>. * */ /* Name: sli_func - execute sli code on array of arguments Synopsis: [arg1 arg2 ... argN] (function code) sli_func -> [res1 res2 ...] Arguments: The first arg is an array containing arguments to the function. The array contents is pushed onto the stack. The second arg is SLI code that is a string containing SLI code that is executed. Anything left on the stack is stored in an array as result. Note: This function is for use by the python sli_func(). SeeAlso: sli_func_litconv */ /sli_func [/arraytype /stringtype] { << >> begin % work in local dictionary to avoid side effects /mark rollu cvx % convert string to SLI procedure {arrayload pop} prepend % code prepare arguments exec counttomark % count number of return values arraystore exch pop % remove the mark end } def /* Name: sli_func_litconv - execute sli code on array of arguments Synopsis: [arg1 arg2 ... argN] (function code) sli_func_litconv -> [res1 res2 ...] Arguments: If argn is a string and its first char is /, it is converted to a literal before loaded onto the stack. Note: same as sli_func, but string args beginnig with / are converted to literals SeeAlso: sli_func_litconv */ /sli_func_litconv [/arraytype /stringtype] { << >> begin % work in local dictionary to avoid side effects /mark rollu cvx % convert string to SLI procedure { { StringQ { dup First 47 eq { Rest cvlit } if } if } Map arrayload pop } prepend % code prepare arguments exec counttomark % count number of return values arraystore exch pop % remove the mark end } def /pywelcome { cout endl statusdict begin ( -- N E S T --) <- endl endl ( Copyright (C) 2004 The NEST Initiative) <- endl ( Version ) <- prgmajor <- (.) <- prgminor <- (.) <- prgpatch <- ( ) <- built <- endl endl ; end warranty cout (Problems or suggestions?) <- endl ( Website : http://www.nest-initiative.org) <- endl ( Mailing list: nest_user@nest-initiative.org) <- endl endl (Type 'nest.help()' to find out more about NEST.) <- endl ; :warnings } def /runprotected { stopped dup { errordict /newerror get { errordict /message known { (: ) errordict /message get join errordict /message undef} { () } ifelse errordict /errorname get cvs 3 2 roll % get the error flag to the top again errordict /newerror false put % Tell NEST that the error is handled already } { (Software Interrupt) } ifelse } if not % invert the return value of stopped } bind def