ALERT: Some images may not load properly within the Knowledge Base Article. If you see a broken image, please right-click and select 'Open image in a new tab'. We apologize for this inconvenience.

FORMAT function for float variable does not remove zeroes or +/-

book

Article ID: 236944

calendar_today

Updated On:

Products

CA Automic Workload Automation - Automation Engine CA Automic One Automation

Issue/Introduction

When using the FORMAT function for a float variable like the following:

:define &threshold#, float
:SET &THRESHOLD# = 0.1
:set &threshold# = format(&threshold#, '00.0')
:p 'formatted float: &threshold#'

the result does not remove the leading + or -, nor does it remove the leading and trailing zero (0).  Result:

U00020408 formatted float: +0000000000000000.1000000000000000

The documentation as of March 1, 2022 does not indicate any other special instructions on how to get this to format correctly.

Cause

This is as designed

Environment

Release : 12.3

Component : AUTOMATION ENGINE

Resolution

A formatted float variable value can only be assigned to a string variable.  So something like the below must be used:

:define &threshold#, float
:set &threshold# = 0.1
:set &formatted_threshold# = format(&threshold#, "00.0")
:p 'string with formatted float &formatted_threshold#'

result:

U00020408 string with formatted float 00.1

The documentation will be updated to include the note:

A formatted float variable value must be assigned to a variable of type string.

Additional Information

Documentation for formatting float variables can be found here: https://docs.automic.com/documentation/webhelp/english/AA/12.3/DOCU/12.3/Automic%20Automation%20Guides/help.htm#Script/Reference/FORMAT.htm