czardas Posted May 3, 2012 Share Posted May 3, 2012 (edited) What is this random number of sentences all about? $open= FileOpen('input.txt', 128) If @error Then Exit $update=FileOpen('output.txt',BitOR(128, 8, 1)) If @error Then Exit $text=FileRead($open) StringReplace($text, @CR, "") StringReplace($text, @LF, "") $text = StringStripWS($text, 3) If StringRight($text, 1) = "." Then $text = StringTrimRight($text, 1) $sens = StringSplit($text,".",1) $sString = "" For $i = 1 To $sens[0] For $j = 1 To Random(3,6,1) If $i > $sens[0] Then ExitLoop $sString &= $sens[$i] & "." $i += 1 Next $sString &= @CRLF $i -= 1 Next FileWrite($update, $sString) Edited May 3, 2012 by czardas kegiaumat055 1 operator64 ArrayWorkshop Link to comment Share on other sites More sharing options...
kegiaumat055 Posted May 3, 2012 Author Share Posted May 3, 2012 (edited) What is this random number of sentences all about? $open= FileOpen('input.txt', 128) If @error Then Exit $update=FileOpen('output.txt',BitOR(128, 8, 1)) If @error Then Exit $text=FileRead($open) StringReplace($text, @CR, "") StringReplace($text, @LF, "") $text = StringStripWS($text, 3) If StringRight($text, 1) = "." Then $text = StringTrimRight($text, 1) $sens = StringSplit($text,".",1) $sString = "" For $i = 1 To $sens[0] For $j = 1 To Random(3,6,1) If $i > $sens[0] Then ExitLoop $sString &= $sens[$i] & "." $i += 1 Next $sString &= @CRLF $i -= 1 Next FileWrite($update, $sString) Great ! Thanks But it has a space in the top lines. For Example: Sentence1. Sentence2. Sentence3. Sentence4. Sentence5. Sentence6. Sentence7. Sentence8. Sentence9. Sentence10. Sentence11. Sentence12. Sentence13. Sentence14. Sentence15. Edited May 3, 2012 by kegiaumat055 Link to comment Share on other sites More sharing options...
czardas Posted May 3, 2012 Share Posted May 3, 2012 Isn't life a b***h. Try to fix it and see what happens. If you can't solve it, I'll help, but I need to see you make an effort to solve it first. operator64 ArrayWorkshop Link to comment Share on other sites More sharing options...
kegiaumat055 Posted May 3, 2012 Author Share Posted May 3, 2012 Isn't life a b***h. Try to fix it and see what happens. If you can't solve it, I'll help, but I need to see you make an effort to solve it first. Sorry, It is easy to fix an error $sens = StringSplit($text,".",1) ----> $sens = StringSplit($text,". ",1) Thank you very much ! Link to comment Share on other sites More sharing options...
czardas Posted May 3, 2012 Share Posted May 3, 2012 You found the root of the problem. What you have also strips spaces between all sentences. I came up with a slightly different solution. Anyway, you were definately on the right track $open= FileOpen('input.txt', 128) If @error Then Exit $update=FileOpen('output.txt',BitOR(128, 8, 1)) If @error Then Exit $text=FileRead($open) StringReplace($text, @CR, "") StringReplace($text, @LF, "") $text = StringStripWS($text, 3) If StringRight($text, 1) = "." Then $text = StringTrimRight($text, 1) $sens = StringSplit($text,".",1) $sString = "" For $i = 1 To $sens[0] For $j = 1 To Random(3,6,1) If $i > $sens[0] Then ExitLoop $sString &= StringStripWS($sens[$i], 3) & ". " $i += 1 Next $sString &= @CRLF $i -= 1 Next FileWrite($update, $sString) operator64 ArrayWorkshop 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