Jump to content
Sign in to follow this  


Recommended Posts


This is based off of ExpandEnvStrings () which was made by Blindwig. I just modified it with permission from Blindwig.

It expands variables in a string. to use it just put the variable name in between two $ signs if you want to have a literal $ then double it up like $$.

#CS Test (Note this test must be run in scite.)
$A="This is a test"
ConsoleWrite(_ExpandVarStrings("A=$A$ $$"))

Func _ExpandVarStrings($sInput)
    Dim $aPart = StringSplit($sInput,'$')
    If @error Then
        Return $sInput
    Dim $sOut = $aPart[1], $i = 2, $Var = ''
;loop through the parts
    While $i <= $aPart[0]
        $Var = Eval ($aPart[$i])
        If $Var <> '' Then;this part is an expandable Variable
            $sOut = $sOut & $Var
            $i = $i + 1
            If $i <= $aPart[0] Then $sOut = $sOut & $aPart[$i]
        ElseIf $aPart[$i] = '' Then;a double-$ is used to force a single $
            $sOut = $sOut & '$'
            $i = $i + 1
            If $i <= $aPart[0] Then $sOut = $sOut & $aPart[$i]
        Else;this part is to be returned literally
            $sOut = $sOut & '$' & $aPart[$i]
        $i = $i + 1
    Return $sOut


ExpandEnvStrings() can be found here.

Edited by SolidSnake

HKTunes:Softpedia | GoogleCodeLyricToy:Softpedia | GoogleCodeRCTunes:Softpedia | GoogleCodeMichtaToolsProgrammer n. - An ingenious device that turns caffeine into code.

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  


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.