Lyee

Save multiple lines into 1 variable

5 posts in this topic

#1 ·  Posted

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)

Share this post


Link to post
Share on other sites



#2 ·  Posted

Do you have a copy of config.cfg we can view

Share this post


Link to post
Share on other sites

#3 ·  Posted

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=

Share this post


Link to post
Share on other sites

#4 ·  Posted

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 !

Share this post


Link to post
Share on other sites

#5 ·  Posted

It would be easier to just read the config file to an Array and then use _ArrayToString inside the combo box, using the "|" delimiter (default).

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