Difference between revisions of "String Variable"

258 bytes added ,  09:50, 21 July 2014
imported>Odessa
(link to string formatting)
imported>Odessa
Line 9: Line 9:
let my_string := "this is my string"
let my_string := "this is my string"


MessageEx $my_string
let my_string += " and this is Sunny's name: " + $SunnyREF


; * note: the MessageEx function requires you to include '$' (short for 'ToString') before the variable name
if eval my_string == "this is my string and this is Sunny's name: Sunny Smiles"
  ; this will evaluate true
endif
</pre>
 
The [[ToString|ToString (shorthand: '$')]] function converts anything to a string. Vanilla and some old NVSE functions also require this to use a string_var instead of a string literal:
<pre>
Print my_string ; * new NVSE function


if eval my_string == "this is another string"
MessageEx $my_string ; * An old NVSE function
  ; do something. Obviously this is false in this case.
endif
</pre>
</pre>


To use [[String Formatting]], you need to use [[Sv_Construct]]:
If you want to use [[String Formatting]] rather than concatanation, you need to use [[Sv_Construct]]:
<pre>
<pre>
string_var my_string
string_var my_string
Line 26: Line 31:
let my_string := Sv_Construct "the value of MyInt is %g", MyInt
let my_string := Sv_Construct "the value of MyInt is %g", MyInt
</pre>
</pre>
==See Also==
==See Also==
*[[Tutorial: String Variables]]
*[[Tutorial: String Variables]]
Anonymous user