formatText: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
mNo edit summary
mNo edit summary
 
(52 intermediate revisions by 11 users not shown)
Line 1: Line 1:
[[Category:Scripting Commands|FORMATTEXT]]
{{RV|type=command
[[Category:Scripting Commands OFP Elite |FORMATTEXT]]
[[Category:Scripting Commands ArmA|FORMATTEXT]]


|game1= arma1
|version1= 1.00


|game2= arma2
|version2= 1.00


<h2 style="color:#000066">''''' formatText ''''' ''[format, arg1, arg2, ...]''</h2>
|game3= arma2oa
|version3= 1.50


|game4= tkoh
|version4= 1.00


'''Operand types:'''
|game5= arma3
|version5= 0.50


'''[format, arg1, arg2, ...]''': [[Array]]
|gr1= Strings


'''Type of returned value:'''
|gr2= Structured Text


[[Structured Text]]
|descr= Creates a [[Structured Text]] similar to [[format]] command.


'''Compatibility:'''
|s1= [[formatText]] [format, argument1, argument2, ...]


Version 2.01 required.
|p1= format: [[String]] - a string containing text and/or references to the variables listed below in the array. The references appear in the form of %1, %2 etc.


'''Description:'''
|p2= argumentN: [[Anything]] - use [[Structured Text]] where necessary (see [[#Example|Example 2]])


Creates a structured text by replacing %1, %2, etc. in format by plain or structured texts given as arguments.
|r1= [[Structured Text]]


'''Example:'''
|x1= <sqf>hint formatText ["Image: %1", image "\a3\Data_f\Flags\flag_Altis_co.paa"];</sqf>


txt = '''formatText'''' ["Image: %1", [[image]] "data\isniper.paa"]
|x2= <sqf>
hint formatText ["%1%2%3", "line1", "<br/>", "line2"]; // result displayed in one line
hint formatText ["%1%2%3", "line1", lineBreak, "line2"]; // result displayed in two lines
</sqf>
 
|seealso= [[Structured Text]] [[format]] [[composeText]] [[text]] [[parseText]]
}}

Latest revision as of 04:21, 27 November 2023

Hover & click on the images for description

Description

Description:
Creates a Structured Text similar to format command.
Groups:
StringsStructured Text

Syntax

Syntax:
formatText [format, argument1, argument2, ...]
Parameters:
format: String - a string containing text and/or references to the variables listed below in the array. The references appear in the form of %1, %2 etc.
argumentN: Anything - use Structured Text where necessary (see Example 2)
Return Value:
Structured Text

Examples

Example 1:
hint formatText ["Image: %1", image "\a3\Data_f\Flags\flag_Altis_co.paa"];
Example 2:
hint formatText ["%1%2%3", "line1", "<br/>", "line2"]; // result displayed in one line hint formatText ["%1%2%3", "line1", lineBreak, "line2"]; // result displayed in two lines

Additional Information

See also:
Structured Text format composeText text parseText

Notes

Report bugs on the Feedback Tracker and/or discuss them on the Arma Discord or on the Forums.
Only post proven facts here! Add Note