Queener Posted March 14, 2016 Share Posted March 14, 2016 (edited) I have a text file as [start] This is a test [/start] How do I implement the fileread to read after [start] and before [/start]? I have not try it because I don't know where to begin with this. Edited March 14, 2016 by Queener Msgbox(0, "Hate", "Just hate it when I post a question and find my own answer after a couple tries. But if I don't post the question, I can't seem to resolve it at all.") Link to comment Share on other sites More sharing options...
UEZ Posted March 14, 2016 Share Posted March 14, 2016 StringRegExp* or _StringBetween are your friends. Please provide a more specific text file to adapt a solution. Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
Queener Posted March 14, 2016 Author Share Posted March 14, 2016 (edited) I have some exam question/answers and are not allow to post or share... I'm just creating a question/answer problems for my own practice instead of wasting paper to print out. So it would look something like this: [Question1] Name: Q Salary: $40 hourly / Bi Weekly Status: Single Debt: $250,000 Question 1: Will Q manage to afford a million dollar house? [/Question1] [Answer1] A1=No A2=Yes A3=None of the above [/Answer1] Because there are return spaces, iniread is no longer a choice for me. Edited March 14, 2016 by Queener Msgbox(0, "Hate", "Just hate it when I post a question and find my own answer after a couple tries. But if I don't post the question, I can't seem to resolve it at all.") Link to comment Share on other sites More sharing options...
UEZ Posted March 14, 2016 Share Posted March 14, 2016 You mean something like this here? $sFileread = "[Question1]" & @CRLF & @CRLF & _ "Name: Q" & @CRLF & @CRLF & _ "Salary: $40 hourly / Bi Weekly" & @CRLF & @CRLF & _ "Status: Single" & @CRLF & @CRLF & _ "Debt: $250,000" & @CRLF & @CRLF & @CRLF & _ "Question 1: Will Q manage to afford a million dollar house?" & @CRLF & @CRLF & _ "[/Question1]" & @CRLF & @CRLF & _ "[Answer1]" & @CRLF & @CRLF & _ "A1=No" & @CRLF & @CRLF & _ "A2=Yes" & @CRLF & @CRLF & _ "A3=None of the above" & @CRLF & @CRLF & _ "[/Answer1]" ConsoleWrite(StringRegExpReplace($sFileread, "[^\S]*[\[.*\]].*", "") & @CRLF) Queener 1 Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
Queener Posted March 14, 2016 Author Share Posted March 14, 2016 (edited) I was hoping for something easier like read anything below [Question1] and stop reading before [/Question1] like so. So the outcome should spit only Name: Q Salary: $40 hourly / Bi Weekly Status: Single Debt: $250,000 Question 1: Will Q manage to afford a million dollar house? onto an editbox. Edited March 14, 2016 by Queener Msgbox(0, "Hate", "Just hate it when I post a question and find my own answer after a couple tries. But if I don't post the question, I can't seem to resolve it at all.") Link to comment Share on other sites More sharing options...
mikell Posted March 14, 2016 Share Posted March 14, 2016 You could use this concept to build the needed func $sFileread = "[Question1]" & @CRLF & @CRLF & _ "Name: Q" & @CRLF & @CRLF & _ "Salary: $40 hourly / Bi Weekly" & @CRLF & @CRLF & _ "Status: Single" & @CRLF & @CRLF & _ "Debt: $250,000" & @CRLF & @CRLF & @CRLF & _ "Question 1: Will Q manage to afford a million dollar house?" & @CRLF & @CRLF & _ "[/Question1]" & @CRLF & @CRLF & _ "[Answer1]" & @CRLF & @CRLF & _ "A1=No" & @CRLF & @CRLF & _ "A2=Yes" & @CRLF & @CRLF & _ "A3=None of the above" & @CRLF & @CRLF & _ "[/Answer1]" $var1 = "Question1" $res = StringStripWS(StringRegExp($sFileread, '\[' & $var1 & '\]\R+([^[]+)', 3)[0], 4) Msgbox(0, $var1, $res) $var2 = "Answer1" $res = StringStripWS(StringRegExp($sFileread, '\[' & $var2 & '\]\R+([^[]+)', 3)[0], 4) Msgbox(0, $var2, $res) Queener 1 Link to comment Share on other sites More sharing options...
Queener Posted March 14, 2016 Author Share Posted March 14, 2016 Excuse my fart-mind. Thats exactly what I'm looking for. Thanks UEZ and mikell. Msgbox(0, "Hate", "Just hate it when I post a question and find my own answer after a couple tries. But if I don't post the question, I can't seem to resolve it at all.") Link to comment Share on other sites More sharing options...
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