Sign in to follow this  
Followers 0
qwertylol

variable in a string

3 posts in this topic

$array = winlist ("title")

Do

$counter = $counter + 1

iniwrite ( "handles.ini", 0, "number", $array[0][0])

iniwrite ( "handles.ini", 1, "key, $array[$counter][1])

Until $counter = $array[0][0]

it's about iniwrite:

for "key" I need to put in a variable, how do I put a variable in the middle of a string?

Share this post


Link to post
Share on other sites



$string = "text stuff" & $variable & "some more text stuff"

Share this post


Link to post
Share on other sites

$string = "text stuff" & $variable & "some more text stuff"

Or, in some cases also very useful, use the following:

Opt("ExpandVarStrings", 1)
$test = "hello"
msgbox(0,"test","The test variable contains $test$ and in this way you don't need to break up the string!")

The disadvantage of this is that it is easier to experience runtime errors because the variables will not be checked before compiling. The advantage of this for me was that this made it very easy for people without programming skills to translate my strings into languages I don't speak...

Breaking strings like "Adding a value " & $test & "in the middle." is more elegant and less prone to errors; you should use that unless the ExpandVarStrings has explicit advantages like it did for me.


Roses are FF0000, violets are 0000FF... All my base are belong to you.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0