Jump to content

Save multiple lines into 1 variable


Recommended Posts

Hello,

Im working on script which can read and write things into txt(cfg in this case) file and well save them.

Now I have done write part and im doin on read part of this script.

Im having a few lines which just find string and I need these lanes save to 1 string and call them in ComboGUI panel.

My code:

FileOpen(@ScriptDir & '\config.cfg', 0)
For $i = 1 To _FileCountLines(@ScriptDir & '\config.cfg')
    $line = FileReadLine(@ScriptDir & '\config.cfg', $i)
    If StringInStr($line, '[_') Then
        $purge1 = StringReplace($line, '[_', '')
        $purge = StringReplace($purge1, ']', '')
        MsgBox(0, '', $purge & ' | Line = ' & $i)
    EndIf
Next

I can see lot of these words which are in $purge via MSGBOX but just last word can be proper saved into $purge and these before are lost.. I actually even dont know how to call it into ComboGUI :/

Thanks for any help guys..

(sorry for my bad eng im not enough good speaker)

Link to comment
Share on other sites

If you want to merge two lines together, you can concatenate them like so:

FileOpen(@ScriptDir & '\config.cfg', 0)
$newString = ""
For $i = 1 To _FileCountLines(@ScriptDir & '\config.cfg')
    $line = FileReadLine(@ScriptDir & '\config.cfg', $i)
    If StringInStr($line, '[_') Then
        $purge1 = StringReplace($line, '[_', '')
        $purge = StringReplace($purge1, ']', '')
        $newString &= $purge
        ;MsgBox(0, '', $purge & ' | Line = ' & $i)
    EndIf
Next

$newString will contain your final string that has every string in your loop added to the end of it.

UHJvZmVzc2lvbmFsIENvbXB1dGVyZXI=

Link to comment
Share on other sites

11 minutes ago, anthonyjr2 said:

If you want to merge two lines together, you can concatenate them like so:

FileOpen(@ScriptDir & '\config.cfg', 0)
$newString = ""
For $i = 1 To _FileCountLines(@ScriptDir & '\config.cfg')
    $line = FileReadLine(@ScriptDir & '\config.cfg', $i)
    If StringInStr($line, '[_') Then
        $purge1 = StringReplace($line, '[_', '')
        $purge = StringReplace($purge1, ']', '')
        $newString &= $purge
        ;MsgBox(0, '', $purge & ' | Line = ' & $i)
    EndIf
Next

$newString will contain your final string that has every string in your loop added to the end of it.

Thanks a lot dude. You helped me a lot.. I spend on this sh*t probably more then hour..

I made this:

$newString &= '|' & $purge

Even like this it can be called in comboUI

Thank you !

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...