string default set by tcl expression

In the Presentation part I’d like to be able to set the default of a string to the contents of a variable.

I’ve read that the default can ether be set to a literal.

eg.

string port default “80”

or by a tcl expression instead of the “80”

So I’m imagining something like,

set fred “80”

Section blah

string port default $fred

… but this and many variations on it I’ve tried get template Import errors.

Any help would be appreciated, please.

Hi,

Looking at the following links I’m not entirely sure if this is possible in APL. What are you trying to achieve?

https://devcentral.f5.com/wiki/iApp.APL.ashx

https://devcentral.f5.com/wiki/iApp.string.ashx

Depending on an earlier choice which the person will make from a drop-down menu, different defaults would appear - I hope.

Mark-

I’m afraid that is not possible. I described why in a prior post (DevCentral - An F5 Technical Community). The problem is that when Tcl is included in an APL statement, for example to construct the contents of a dropdown, the code is run prior to the web page rendering. In other words, by the time you see the page and are able to made a dropdown choice above, the code below has already been run.

It is possible to change theapparentdefault value of a field according to choices made above it in a template, but the method is a bit messy. You must create 2 APL fields and surround them with optionals, ie.:

choice use_https default “no” { “yes”,“no” }

optional ( use_https == “yes” ) {

string port_1 default 443

}

optional (use_https == “no” ) {

string port_2 default 80

}

-Fred

Thanks very much Fred.