next | previous | forward | backward | up | top | index | toc | Macaulay2 web site
Macaulay2Doc :: value(String)

value(String) -- evaluate a string



The contents of s are treated as code in the Macaulay2 language, parsed it in its own scope (the same way a file is) and evaluated. The string may contain multiple lines.
i1 : value "2 + 2"

o1 = 4
i2 : value "a := 33

o2 = 66
i3 : a

o3 = a

o3 : Symbol
Since the local assignment to a above occurred in a new scope, the value of the global variable a is unaffected.

During evaluation of the string, error messages will refer to the location of the error as currentString with a line number and a column number, and the value of the variable currentString is set to the string, to aid in debugging.

i4 : debuggingMode = stopIfError = false;
i5 : value "1/0"
currentString:1:2:(3):[1]: error: division by zero
i6 : debuggingMode = true;
i7 : value "1/0"
currentString:1:2:(3):[1]: error: division by zero
currentString:1:2:(3):[1]: --entering debugger (type help to see debugger commands)
currentString:1:1-1:3: --source code:
ii8 : break

See also