Forum Discussion
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.
4 Replies
- ccb
Employee
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 - Mark_H_58087
Nimbostratus
Depending on an earlier choice which the person will make from a drop-down menu, different defaults would appear - I hope.
- Fred_Slater_856Historic F5 Account
Mark-
I'm afraid that is not possible. I described why in a prior post (https://devcentral.f5.com/community/group/aft/2166295/asg/2032). 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 the apparent default 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
- Mark_H_58087
Nimbostratus
Thanks very much Fred.
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com