# Getting Arguments in Extended Expression Functions

**URL:** <https://forum.inductiveautomation.com/t/getting-arguments-in-extended-expression-functions/7818>\
**Category:** Module Development\
**Created:** [January 13, 2014, 2:19am UTC](https://forum.inductiveautomation.com/t/getting-arguments-in-extended-expression-functions/7818 "2014-01-13T02:19:53Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mlangdon](https://avatars.discourse-cdn.com/v4/letter/m/d9b06d/32.png) [@mlangdon](https://forum.inductiveautomation.com/u/mlangdon)\
**Post date:** [January 13, 2014, 2:19am UTC](https://forum.inductiveautomation.com/t/getting-arguments-in-extended-expression-functions/7818/1 "2014-01-13T02:19:53Z")

</div>

I was able to add a sample expression function by writing this class:

```auto
public class HelloFunction extends AbstractFunction {

	public HelloFunction() {
	}

	@Override
	public QualifiedValue execute(Expression[] args) throws ExpressionException {
		return new BasicQualifiedValue(String.format("Hello World %d", args.length));
	}

	@Override
	public String getArgDocString() {
		return "int";
	}

	@Override
	public Class<?> getType() {
		return String.class;
	}

	@Override
	protected String getFunctionDisplayName() {
		return "helloWorld";
	}
}
```

And adding this to my Designer hook:

```auto
	@Override
	public void configureFunctionFactory(ExpressionFunctionManager factory) {
		factory.getCategories().add("Extended");
		factory.addFunction("helloWorld", "Extended", new HelloFunction());
		super.configureFunctionFactory(factory);
	}
```

However, no amount of SDK and forum scouring will turn up the method for getting the argument passed in through expression.

I’m assuming it’s simple, that I am extending the wrong function class or misreading the Expression class, but how do I get the args?

---

<div class="post-metadata">

**Author:** ![mlangdon](https://avatars.discourse-cdn.com/v4/letter/m/d9b06d/32.png) [@mlangdon](https://forum.inductiveautomation.com/u/mlangdon)\
**Post date:** [January 14, 2014, 2:29pm UTC](https://forum.inductiveautomation.com/t/getting-arguments-in-extended-expression-functions/7818/2 "2014-01-14T14:29:13Z")

</div>

I just figured this out. Simple as predicted:

```auto
	@Override
	public QualifiedValue execute(Expression[] exes) throws ExpressionException {
		Object value = exes[0].execute().getValue();
		return new BasicQualifiedValue(String.format("Hello World: %s", value.toString()));
	}
```

You call execute on the Expression(s) passed in, they return a QualifiedValue, you call getValue() on the QV(s).

Now you have the arg(s) from the Expression.

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [January 14, 2014, 3:59pm UTC](https://forum.inductiveautomation.com/t/getting-arguments-in-extended-expression-functions/7818/3 "2014-01-14T15:59:04Z")

</div>

Glad you figured that out! Meant to answer this yesterday but got sidetracked by something.
