Forum Discussion
Formating issue: default value for undefined variable
- Aug 13, 2019
You need to make sure you use the expr syntax when using a ternary operator within a variable.
For example:
% set colour [expr {"1" ? "red" : "blue"}] red % set colour [expr {"0" ? "red" : "blue"}] blue
So looking at your example, you'd need to change it to be something like this.. (note that I have changed the from single to double quotation marks for the hyphen)
set message [format \ "%s - %s \[%s\]..." \ ... \ [expr {[info exists [HTTP::username]] ? [HTTP::username] : "-" }] ]
You need to make sure you use the expr syntax when using a ternary operator within a variable.
For example:
% set colour [expr {"1" ? "red" : "blue"}]
red
% set colour [expr {"0" ? "red" : "blue"}]
blue
So looking at your example, you'd need to change it to be something like this.. (note that I have changed the from single to double quotation marks for the hyphen)
set message [format \
"%s - %s \[%s\]..." \
... \
[expr {[info exists [HTTP::username]] ? [HTTP::username] : "-" }]
]
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