core/src/commands.cpp
changeset 51 3ad902ef5222
parent 42 e81b4e28b3e2
child 54 ea6622dea85a
child 56 9c352d34f5aa
equal deleted inserted replaced
50:db96d73779bc 51:3ad902ef5222
  3426 				Complete(env.GetAsDesL(*iVar1) == *iArg);
  3426 				Complete(env.GetAsDesL(*iVar1) == *iArg);
  3427 				}
  3427 				}
  3428 			break;
  3428 			break;
  3429 		case EAdd:
  3429 		case EAdd:
  3430 		case ESubtract:
  3430 		case ESubtract:
  3431 			{
  3431 		case EMultiply:
  3432 			if (iArg == NULL) LeaveIfErr(KErrArgument, _L("Argument must be specified for add and subtract operations"));
  3432 			{
       
  3433 			if (iArg == NULL) LeaveIfErr(KErrArgument, _L("Argument must be specified for add, subtract and multiply operations"));
  3433 			TLex lex(*iArg);
  3434 			TLex lex(*iArg);
  3434 			TInt operand;
  3435 			TInt operand;
  3435 			TInt err = lex.Val(operand);
  3436 			TInt err = lex.Val(operand);
  3436 			LeaveIfErr(err, _L("Couldn't parse an integer from argument '%S'"), iArg);
  3437 			LeaveIfErr(err, _L("Couldn't parse an integer from argument '%S'"), iArg);
  3437 			if (iOperation == ESubtract) operand = -operand;
  3438 			TInt value = 0;
  3438 			TInt current = 0;
  3439 			TRAP_IGNORE(value = env.GetAsIntL(*iVar1)); // If it doesn't yet exist or isn't an int, we'll treat it as if it was zero
  3439 			TRAP_IGNORE(current = env.GetAsIntL(*iVar1)); // If it doesn't yet exist or isn't an int, we'll treat it as if it was zero
  3440 			if (iOperation == ESubtract) value = value - operand;
  3440 			env.SetL(*iVar1, current + operand);
  3441 			else if (iOperation == EMultiply) value = value * operand;
       
  3442 			else value = value + operand;
       
  3443 			env.SetL(*iVar1, value);
  3441 			break;
  3444 			break;
  3442 			}
  3445 			}
  3443 		default:
  3446 		default:
  3444 			User::Leave(KErrNotSupported);
  3447 			User::Leave(KErrNotSupported);
  3445 		}
  3448 		}