Lyee Posted May 22, 2017 Posted May 22, 2017 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)
anthonyjr2 Posted May 22, 2017 Posted May 22, 2017 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=
Lyee Posted May 22, 2017 Author Posted May 22, 2017 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 !
Subz Posted May 22, 2017 Posted May 22, 2017 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).
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now