⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 addpath.java

📁 JAVA 数学程序库 提供常规的数值计算程序包
💻 JAVA
字号:
package jmathlib.toolbox.jmathlib.system;

import java.io.File;
import jmathlib.core.functions.FileFunctionLoader;
import jmathlib.core.functions.FunctionLoader;
import jmathlib.core.functions.ExternalFunction;
import jmathlib.core.tokens.Token;
import jmathlib.core.tokens.CharToken;
import jmathlib.core.tokens.OperandToken;
import jmathlib.core.tokens.numbertokens.DoubleNumberToken;


/**External function to add an item to the search path*/
public class addpath extends ExternalFunction
{
    /**adds an item to the search path
    @param operands[0] = item to add*/
    public OperandToken evaluate(Token[] operands)
    {
        if (getNArgIn(operands)!=1)
            throwMathLibException("addpath: number of arguments != 1");

        boolean prepend = true;
        
		for(int index = 0; index < operands.length; index++)
		{
            
            // check if operand is of type char token
            if (!(operands[index] instanceof CharToken))
                throwMathLibException("addpath: parameter "+index+" is not a char array");
            
            String path = operands[index].toString();
            
            if(path.equalsIgnoreCase("end") || path.equals("1"))
                prepend = false;
            else if(path.equalsIgnoreCase("begin") || path.equals("0"))
                prepend = true;
        }
               
		for(int index = 0; index < operands.length; index++)
		{
            String path = operands[index].toString();
            if(!(path.equalsIgnoreCase("end") || path.equals("1") || path.equalsIgnoreCase("begin") || path.equals("0")))
            {
                FunctionLoader loader = new FileFunctionLoader(new File(path), true);
                if (!prepend)
                  getFunctionManager().addFunctionLoader(loader);
                else getFunctionManager().addFunctionLoaderAt(0, loader);
            }
        }
            
        return DoubleNumberToken.one;
    }
}

/*
@GROUP
system
@SYNTAX
addpath(path)
@DOC
Adds path to the current search path.
@NOTES
@EXAMPLES
addpath("../newpath")
@SEE
path, rmpath
*/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -