Example #1
0
 public override InstructionReturnValue RunInstruction()
 {
     EvaluateArgumentList();
     indexVal      = (int)index.GetValue();
     arrValAtIndex = arr?.GetValueAtIndex(indexVal);
     if (arr?.GetArrayType() == typeof(IntDataType))
     {
         return(new InstructionReturnValue(new IntDataType(null, (int)arrValAtIndex), null));
     }
     else if (arr.GetArrayType() == typeof(FloatDataType))
     {
         return(new InstructionReturnValue(new FloatDataType((float)arrValAtIndex), null));
     }
     else if (arr.GetArrayType() == typeof(StringDataType))
     {
         return(new InstructionReturnValue(new StringDataType(null, (string)arrValAtIndex), null));
     }
     else if (arr.GetArrayType() == typeof(CharDataType))
     {
         char c = Convert.ToChar(arrValAtIndex);
         return(new InstructionReturnValue(new CharDataType(null, c), null));
     }
     else
     {
         bool b = Convert.ToBoolean(arrValAtIndex);
         return(new InstructionReturnValue(new BoolDataType(null, b), null));
     }
 }
Example #2
0
        public override void EvaluateArgumentsOfInstruction()
        {
            Variable           iteratorVar      = GetArgument(CommonSCKeys.Variable) as Variable;
            ArrayDataStructure dataStructureVar = GetArgument(CommonSCKeys.Array) as ArrayDataStructure;

            if (dataStructureVar != null && currIdxInArray < dataStructureVar.GetSize())
            {
                iteratorVar.SetValue(dataStructureVar.GetValueAtIndex(currIdxInArray));
            }
        }