js/calc.js
/**
 * Checks if the string is a valid expression to be accepted by Calc or Spreadsheet and returns an error String.
 * @param exp String that you want to check if it is a valid expression.
 * @return String 'ok' if exp is valid expression, error string if not.
 * */
Checks if the string is a valid expression to be accepted by Calc or Spreadsheet and returns an error String.
@param exp String that you want to check if it is a valid expression.
@return String 'ok' if exp is valid expression, error string if not.
Checks if the string is a valid expression to be accepted by Calc or Spreadsheet and returns an error String . @param exp String that you want to check if it is a valid expression . @return String ' ok ' if exp is valid expression error string if not .
function checkValidExpression(exp)
{
	var err = "ok";
	var rt = /r/g;
	var na = exp.match(rgxNotAllowed) || [];
	console.log(na);
	if (na.length > 0)
	{
		err = "!Error: Illegal characters detected:";
		for (var s in na)
		{
			err += " " + na[s];
		}
	}
	var leftPars = exp.match(/\(/g) || [];
	var rightPars = exp.match(/\)/g) || [];
	if (leftPars.length != rightPars.length)
	{
		err = "!Error: Opening and closing brackets do not match.";
	}
	if (exp.indexOf("=") != -1)
	{
	}
	return err;
}
function checkValidExpression ( exp ) { var err = "ok" ; var rt = / r / g ; var na = exp . match ( rgxNotAllowed ) || [ ] ; console . log ( na ) ; if ( na . length > 0 ) { err = "!Error: Illegal characters detected:" ; for ( var s in na ) { err += " " + na [ s ] ; } } var leftPars = exp . match ( / \( / g ) || [ ] ; var rightPars = exp . match ( / \) / g ) || [ ] ; if ( leftPars . length != rightPars . length ) { err = "!Error: Opening and closing brackets do not match." ; } if ( exp . indexOf ( "=" ) != - 1 ) { } return err ; }
Checks if the string is a valid expression to be accepted by Calc or Spreadsheet and returns an error String.
Checks if the string is a valid expression to be accepted by Calc or Spreadsheet and returns an error String .
//TODO: Only allow = in the beginning and in IF //err = "!Error: '=' can only be used once in the beginning to indicate expression.";