Scilab Website | Contribute with GitLab | Mailing list archives | ATOMS toolboxes
Scilab Online Help
2025.0.0 - English


predef

variable protection

Syntax

n = predef()
oldnew = predef(n)
oldnew = predef('all')
oldnew = predef('clear')
variables_name = predef('names')

Description

Utility function used for defining "oldest" variables as "protected". Protected variables cannot be killed. They are not saved by the save command. The "oldest" are those appearing last in the who('get').

predef() gets the number of protected variables.

predef('a[ll]') sets all the variables protected, it also return the old and new value of protected variables number.

predef('c[lear]') unprotect all but the last 7 variables, it also return the old and new value of protected variables number.

predef(n) sets the max(n,7) last defined variables as protected, it also return the old and new value of protected variables number.

predef('names') returns a vector of strings with the name of protected variables.

predef('clear') removes the predefined variables from the list.

Remarks

Variable ans created automatically when expressions are not assigned is never protected by predef('all').

A number of protected variables are set in the start-up file SCI/etc/scilab.start. User may in particular set its own predefined variables in user's startup files SCIHOME/.scilab or SCIHOME/scilab.ini

Note that it is not possible to protect a new defined variable by using predef(1). This means that to protect a variable, Scilab needs to protect all the variables that have been defined before it. This limitation may disappear with Scilab 6, which will not be stack-designed.

Examples

a = 1;
predef("all");
clear a // fails
predef("clear")
clear a // works

See also

  • clear — kills variables
  • save — Saves some chosen variables in a binary data file
  • ans — answer
  • startup — startup files
Report an issue
<< names Variables who >>

Copyright (c) 2022-2024 (Dassault Systèmes)
Copyright (c) 2017-2022 (ESI Group)
Copyright (c) 2011-2017 (Scilab Enterprises)
Copyright (c) 1989-2012 (INRIA)
Copyright (c) 1989-2007 (ENPC)
with contributors
Last updated:
Thu Oct 24 11:13:06 CEST 2024