diff --git a/README.md b/README.md index ad78edd..5a42e10 100644 --- a/README.md +++ b/README.md @@ -37,6 +37,10 @@ Installing `singular`: gap> LoadPackage("singular"); true + To check whether GAP can already find the Singular executable, run + + gap> IsSingularExecutableAvailable(); + 4. The documentation is in the `doc` subdirectory: it is more up-to-date than this README file. diff --git a/doc/singular.xml b/doc/singular.xml index ed06f45..eb95956 100644 --- a/doc/singular.xml +++ b/doc/singular.xml @@ -464,7 +464,36 @@ In this case, with a standard installation of Cygwin and - + + + + + + + +The function IsSingularExecutableAvailable checks whether the +current value of already points to an executable +file, and otherwise tries to resolve it automatically. In particular, if + names only a directory, then the file +Singular inside that directory is tried; if it contains no +directory separator, then it is searched in the system program path; and +if is not set or cannot be used, then the program +name Singular is searched in the system program path. + + +gap> IsSingularExecutableAvailable(); +true + + +If the function returns true, then has been +normalized to a usable executable path. If it returns false, then +the package still does not know how to start Singular, +and should be set explicitly before calling +. + + + + @@ -488,6 +517,8 @@ After the package singular has been loaded, Singular is started automatically when one of the functions of the interface is called. Alternatively, one can start Singular with the command StartSingular. +To check beforehand whether the executable can be found, use +. gap> StartSingular(); diff --git a/gap/singular.g b/gap/singular.g index 59f849b..959e4fa 100644 --- a/gap/singular.g +++ b/gap/singular.g @@ -231,8 +231,8 @@ end ); -BindGlobal( "CheckSingularExecutableAndTempDir", function ( ) - local i, IsExec; +BindGlobal( "IsSingularExecutableAvailable", function ( ) + local IsExec; # check the Singular executable file, and if needed try to # autodetermine, or print an appropriate error message @@ -260,8 +260,15 @@ BindGlobal( "CheckSingularExecutableAndTempDir", function ( ) fi; fi; + return IsBound( sing_exec ) and IsExec( sing_exec ); +end ); + + +BindGlobal( "CheckSingularExecutableAndTempDir", function ( ) + local i; + # check the executable file, if failed print an error message - while not IsBound( sing_exec ) or not IsExec( sing_exec ) do + while not IsSingularExecutableAvailable() do Print( " Type 'sing_exec:=\"\"; return;' where \n" ); Print( " is the path of the Singular executable file on your \ system.\n" );