Skip to content

Format Specifiers

Events like "Format" and "Display (With Variables)" allow you to embed variable values into a string. To tell WinScript which variables and in which format, you use 'format specifiers'. This is similar to using format specifiers in functions like sprintf in the C programming language.

For example, your format string might look like:

"Scene Name: %s, Vehicle ID: %d"

This example has two format specifiers, so the user need to list two variables in the parameters of the event. The first variable would be converted to a string and inserted in place of the "%s". The second variable would be converted to an integer and inserted in place of the "%d".

The result might look like:

"Scene Name: Big Beluga, Vehicle ID: 230"

The same example in a script:

Format example

The following format specifiers are available for use:

Variable Type Placeholder Description
String or LCD String %s Inserts the text in string format. Hex characters are converted into ASCII printable characters like "h0D".
Timecode %s Inserts time in the format "00:00:02.01"
Timecode %d Inserts the number of frames, ie: 61
Integer %d Inserts number without leading zeros or spaces. To add leading zeros, use %0nD where "0" indicates to pad with zeros and "n" is the total number of digits. For example, "%02d" means 'integer variable, force 2-digits, pad with 0's if it's less than 2 digits'.
Integer %X Inserts the number as a hex string. For example, the number 11 would be inserted as "0B".
Integer %p The ascii value represented by the integer will be inserted into the string. For example, the number 13 will be inserted as a carriage return (0x0d).
Decimal %f Writes the Decimal value as a string. Inserts one decimal place OR number of places specified after "." preceding "f". For the number 1.12345: "%.1f" inserts 1.1, "%.2f" inserts 1.12, and "%.4f" inserts 1.1234.
Boolean %s The boolean variable will be converted to "true" or "false" strings.
Boolean %d The boolean variable will be convert to 1 or 0.
Date/Time %s Inserts the date time in the format: month/day/year/hours:minutes.
Percent %s Inserts the percent value as a string, including the % character. For example, "100%".
Percent %f Inserts the percent value as a decimal, For example, 25% would show as ".25".