evalstr(cmd::String)
Let GAP execute the command(s) given by cmd
; if an error occurs then report this error, otherwise if the last command has a result then return it, otherwise return nothing
.
Examples
julia> GAP.evalstr( "1+2" )
3
julia> GAP.evalstr( "x:= []" )
@@ -32,7 +32,7 @@
julia> GAP.evalstr( "x" )
GAP: [ 2 ]
-julia> GAP.evalstr( "Print( x )" )
Note that screen outputs caused by evaluating cmd
are not shown by evalstr
; use evalstr_ex
for accessing both the outputs and the return values of the command(s).
In general we recommend to avoid using evalstr
, but it sometimes can be a useful escape hatch to access GAP functionality that is otherwise impossible to difficult to reach. But in most typical scenarios it should not be necessary to use it at all.
Instead, use GAP.GapObj
or GAP.Obj
for constructing GAP objects that correspond to given Julia objects, and call GAP functions directly in the Julia session. For example, executing GAP.evalstr( "x:= []; Add( x, 2 )" )
can be replaced by the Julia code x = GAP.GapObj([]); GAP.Globals.Add(x, 2)
. Note that the variable x
in the former example lives in the GAP session, i.e., it can be accessed as GAP.Globals.x
after the call of GAP.evalstr
, whereas x
in the latter example lives in the Julia session.