Class KmgFormelInterpreter


  • public class KmgFormelInterpreter
    extends Object
    Main class of JXN. In jxn the KmgFormelInterpreter instance is accessible via the predefined variable $this which allows to inspect and control internal aspects using the public methods of this class.
    • Constructor Detail

      • KmgFormelInterpreter

        public KmgFormelInterpreter()
      • KmgFormelInterpreter

        public KmgFormelInterpreter​(boolean strSave)
      • KmgFormelInterpreter

        public KmgFormelInterpreter​(boolean strSave,
                                    boolean reinit)
      • KmgFormelInterpreter

        public KmgFormelInterpreter​(KmgFormelInterpreter.NullValueHashtable varListe,
                                    boolean strSave)
      • KmgFormelInterpreter

        public KmgFormelInterpreter​(KmgFormelInterpreter.NullValueHashtable varListe)
      • KmgFormelInterpreter

        public KmgFormelInterpreter​(KmgFormelInterpreter.NullValueHashtable varListe,
                                    Hashtable<String,String> strListe)
      • KmgFormelInterpreter

        public KmgFormelInterpreter​(Object owner)
    • Method Detail

      • main

        public static void main​(String[] args)
        Runs JxnPortable from the command line (shell) (Recommended: Start GUI using  JxnPortable/JxnStart.bat).
      • getIconImageList

        public static ArrayList<Image> getIconImageList()
        Used internally.
      • setAbort

        public int setAbort​(boolean abbortOnException)
        Controls if to abort after an Exception (default).
        Example: oldDebug = $this.setAbort( false ) ! => continues script after Exception.
        Dupplicates setDebug(boolean)
        Returns:
        old value of iDebug
      • setDebug

        public int setDebug​(boolean abbortOnException)
        Controls if to abort after an Exception (default).
        Example: oldDebug = $this.setDebug( false ) ! => continues script after Exception
        Returns:
        old value of iDebug
      • setDebug

        public int setDebug​(int iDbgNew)
        Sets the debug level. The debug level controls additional log output to the console window. The debug level is defined as a combination (sum) of the following values:
        •   0 : default ⇒ abort on Exception
        •   1 : continue after Exception
        •   2 : execute (filename): shows file includes
        •   4 : sets show conditional commands (#if, #ifdef, #ifndef, #else if, #else, #return) for the current jxn file,
                 see also setStaticShowConditional(boolean) and JxnFunction.setShowConditional(boolean)
        • 16 : shows findClass
        • 32 : shows findMethod by name
        • 64 : shows findMethod for operator

        Example: oldDebug = $this.setDebug(4+64)
        Parameters:
        iDbgNew - sum of the above values. iDbgNew > 0 continues after an Exception.
        Returns:
        old value
      • addDebug

        public int addDebug​(int mask)
        Sets debug bits given in mask.
        Returns:
        old value
        See Also:
        setDebug(int)
      • clrDebug

        public int clrDebug​(int mask)
        Clears debug bits given in mask.
        Returns:
        old value
        See Also:
        setDebug(int)
      • getDebug

        public int getDebug()
        Returns the debug level.
        See Also:
        setDebug(int)
      • setVersion

        public static int setVersion​(int newVersion)
        Deprecated.
        Currently not used.
      • getVersion

        public static int getVersion()
        Returns iVersion.
      • setStaticShowConditional

        public static boolean setStaticShowConditional​(boolean showConditional)
        Sets show conditional uniformly for all jxn files.
        Usage: KmgFormelInterpreter.setStaticShowConditional(true)
        To set show conditional individually only for the current jxn file use: $this.addDebug(4)
        Returns:
        old value
        See Also:
        setDebug(int)
      • getStaticShowConditional

        public static boolean getStaticShowConditional()
        Returns staticShowConditional.
      • setHideTypeOutput

        public static int setHideTypeOutput​(int hide)
        Controls output of type info in the result output.
        Example: KmgFormelInterpreter.setHideTypeOutput(1)
        Parameters:
        hide -
            0 : show all type info (default)
            1 : no type info for java primitives
            2 : no class name for algebra objects
            3 : class name without package path
            4 : type info only for arrays
            5 : hide all type info

        Returns:
        old value
      • getHideTypeOutput

        public static int getHideTypeOutput()
        Returns staticHideTypeOutput.
      • isDefined

        public boolean isDefined​(String varName)
        Returns true if varName is known.
        Usage: $this.isDefined( "varName" )
      • remove

        public Object remove​(String varName)
        Removes variable varName.
        Usage: $this.remove( "varName" ) or  #remove varName
      • formatVariables

        public String[] formatVariables()
        Shows all known variables (same as menu: View > Variables in JxnSession window).
        Usage: #edit $this.formatVariables()
      • formatVariables

        public String[] formatVariables​(String startsWith)
        Shows variable names starting with ….
      • formatPackageSearchList

        public static String[] formatPackageSearchList()
        Shows the packages searched for classes (same as menu: View > PackageSearchList in JxnSession window).
        Usage: #edit KmgFormelInterpreter.formatPackageSearchList()
      • formatStaticMethodClassList

        public static String[] formatStaticMethodClassList()
        Shows the classes searched for static methods (same as menu: View > StaticMethodClasses in JxnSession window).
        Usage: #edit KmgFormelInterpreter.formatStaticMethodClassList()
      • getPath

        public String getPath​(String filepath)
        Returns relative filepath for parameter filepath. Method getPath is required for file access, if the current jxn file folder differs from the current default folder (user.dir) (→ @File("").getAbsolutePath() or → System.getProperty("user.dir") )

        Note: The default folder (user.dir) is determined at start of jxn as follows: If jxn is started without a file and the file is then selected with JxnSession Menu: Load… the default folder for jxn is and remains JxnPortable/user. If jxn is started with a jxn file (e.g. double-click on the file) the default folder is the folder of that (first) file. To apply a file path relative to a jxn script file folder (rather than relative to the default folder) use fn = $this.getPath("path_relative_to_jxn_file").
        Returns:
        filepath relative to the folder of the current jxn file, if argument filepath is relative
        filepath relative to the JxnPortable folder, if filepath.startsWith("JXN:") e.g. $this.getPath("JXN:user/myFile.txt")
        else (absolute) filepath as passed as argument
      • test

        public Object test​(String cmd)
        Executes command cmd (used for JxnUnitTest).
        Usage: $this.test( command )
        Parameters:
        cmd - statement_sequence (one or more statements separated by ';') or #filename[.jxn].
        Returns:
        the result of the command or the Exception object, if the command fails.
      • sw

        public Object sw​(String condition,
                         String thenCmd,
                         String elseCmd)
        Executes  thenCmd  if  condition  is  true or not  0 or not  null or a char from  1TtYy else  elseCmd.
        Usage: $this.sw( condition, thenCmd, elseCmd )
        Parameters:
        condition - single statement
        thenCmd - statement_sequence (one or more statements separated by ';') or #filename[.jxn]
        elseCmd - statement_sequence (one or more statements separated by ';') or #filename[.jxn]
      • sw

        public Object sw​(String condition,
                         String thenCmd)
        Executes  thenCmd  if  condition  is  true or not  0 or not  null or a char from  1TtYy.
        Usage: $this.sw( condition, thenCmd )
        Parameters:
        condition - single statement
        thenCmd - statement_sequence (one or more statements separated by ';') or #filename[.jxn]
      • exec

        public Object exec​(String cmd)
        Executes cmd.
        Usage: $this.exec( command )
        Parameters:
        cmd - statement_sequence (one or more statements separated by ';') or #filename[.jxn].
        Returns:
        the result of the cmd. A script terminates if cmd throws an Exception