private static Variable handeTextValue(Logic[] cloneLogicOrder, Variable returnVar, Variable afterEqualSign, string originalStringValue, int lineNumber)
        {
            if (cloneLogicOrder [1].word != "+")
            {
                ErrorHandler.ErrorMessage.sendErrorMessage(lineNumber, "När du använder extra operatorer på en text variabel med en annan text kan du endast använda \"+\"");
            }

            returnVar.setValue(originalStringValue + afterEqualSign.getString());
            return(returnVar);
        }
Exemple #2
0
        public bool makeComparison(int lineNumber, bool doChangeValue = true)
        {
            if (counterVariable.variableType != VariableTypes.number)
            {
                ErrorMessage.sendErrorMessage(lineNumber, ErrorType.ForLoop, ForLoopErrorType.counterVariableIsNotNumber.ToString(), new string[1] {
                    counterVariable.name
                });
            }

            if (doChangeValue)
            {
                counterVariable.setValue(counterVariable.getNumber() + incrementValue);
            }
            bool doLoop = ComparisonOperatorParser.makeComparison(counterVariable, base.rightValue, base.theComparisonType, lineNumber);


            getTargetScope().scopeVariables.addVariable(counterVariable, getTargetScope().scopeParser, lineNumber);
            if (doLoop == false && doChangeValue)
            {
                counterVariable.setValue(endValue - incrementValue);
            }

            return(doLoop);
        }
Exemple #3
0
        public void setLoopVariables(string counterName, double startValue, double endValue, double incrementValue)
        {
            this.startValue = startValue;
            this.endValue   = endValue;

            if (incrementValue < 0)
            {
                base.theComparisonType = ComparisonType.greaterThen;
                Print.print("Changing type");
            }

            Variable leftVariable  = new Variable(counterName, startValue);
            Variable checkVariable = new Variable("ForLoopCheckValue", endValue);

            this.counterVariable = leftVariable;

            counterVariable.setValue(startValue);
            counterVariable.isForLoopVariable = true;

            base.leftValue      = counterVariable;
            base.rightValue     = checkVariable;
            this.incrementValue = incrementValue;
        }
        private static Variable handleNumberValue(Logic[] cloneLogicOrder, Variable returnVar, Variable afterEqualSign, string originalStringValue, int lineNumber)
        {
            if (cloneLogicOrder [1].word != "*")
            {
                ErrorHandler.ErrorMessage.sendErrorMessage(lineNumber, "När du använder extra operatorer på en text variabel med en siffra kan du endast använda \"*\"");
            }

            if (afterEqualSign.getNumber() % 1 != 0)
            {
                ErrorHandler.ErrorMessage.sendErrorMessage(lineNumber, "Du kan endast multiplicera strängar med heltal");
            }

            if (afterEqualSign.getNumber() <= 0)
            {
                return(returnVar);
            }

            for (int i = 0; i < afterEqualSign.getNumber(); i++)
            {
                returnVar.setValue(returnVar.getString() + originalStringValue);
            }

            return(returnVar);
        }