The As operator performs two functions - conversion and formatting.

Conversion: varname As type

Converts the variable varname to the specified type. Valid types are:

boolboolean (true or false)
intsigned 32-bit integer
uintunsigned 32-bit integer
int64signed 64-bit integer
uint64unsigned 64-bit integer
doubledouble-precision floating point
datedate/time
strstring
pathpath

When converting from a string to a date, valid input formats are:

Times must be in 24-hour format, minutes and seconds are optional. If a time is specified on its own, today's date is assumed.

Formatting: varname As format

Formats the variable varname using the specified formatting code.

Various formatting operations are available.

Where it makes sense the above codes can be combined, e.g. %_+8 would internal-justify a number to 8 places whether it was positive or negative.

File size format

Use value as size to automatically format a number as a file size using the default settings. You can also use the following keywords to control the units:

sizeAutomatic (bytes/KB/MB etc) with user-configured decimal/binary unit option
sztAutomatic with traditional units (1 KB = 1024 bytes)
sziAutomatic with binary units (1 KiB = 1024 bytes)
szdAutomatic with decimal units (1 KB = 1000 bytes)
bytesBytes
kbKilobytes, traditional units
mbMegabytes, traditional units
gbGigabytes, traditional units
tbTerabytes, traditional units
pbPetabytes, traditional units
kibKilobytes, binary units
mibMegabytes, binary units
gibGigabytes, binary units
tibTerabytes, binary units
pibPetabytes, binary units
kbdKilobytes, decimal units
mbdMegabytes, decimal units
gbdGigabytes, decimal units
tbdTerabytes, decimal units
pbdPetabytes, decimal units


Example:

d = "2023-09-23" as date;
Output(d as "D#dd-MMM-yyyy");
--> 23-Sep-2023

i = 1 as double / 3;
Output(i as "%-.3");
--> 0.333

i = 183743933;
output(i as "%.3kb");
--> 179,437.435 KB

See also: Format