GodForsakenSoul Posted December 17, 2009 Share Posted December 17, 2009 (edited) wow... i've been away for SO long... anyway, let's move to business. Due to fact i can't find a proggy i need to practice my Japanese, my brain told me "f*** this crap! you can make it yourself!" so now it's my little project... problem number one is probably pretty simple. i'm going to have alot of files .txt files with the following format <verb> base1: <form> base2: <form> base3: <form> base4: <form> base5: <form> base6: <form> base7: <form> the fact i can't do an actual word means i need alot of practice with this... so the first thing i'm looking for is a way to read the words AFTER the base tag. or, as always, a better alternative would be awesome. edit: apparently, FileRead() does the job nicely. i can't figure out how to use it though. Edited December 17, 2009 by GodForsakenSoul Link to comment Share on other sites More sharing options...
MerkurAlex Posted December 17, 2009 Share Posted December 17, 2009 You, should look for StringRegExp in the Help File. I am not very good with regular expressions yet so I do not know if this will work but here is my attempt:#include <array.au3> $stringInput="base1: <form>"&@CRLF&"base2: <form>"&@CRLF&"base3: <form>"&@CRLF&"base4: <form>"&@CRLF&"base5: <form>"&@CRLF&"base6: <form>"&@CRLF&"base7: <form>" $reg=StringRegExp($stringInput,"(.*?): (.*?)"&@CRLF,3) _ArrayDisplay($reg)This probably works but I do not think you should use it. You, should either attempt to do it yourself with a different Expression or wait for someone else to come along with a better Expression. [quote name='PsaltyDS' post='635433' date='Jan 27 2009, 07:04 AM']Larry is a mass murderer?! It's always the quiet, clean cut, bald guys... [/quote] Link to comment Share on other sites More sharing options...
GodForsakenSoul Posted December 17, 2009 Author Share Posted December 17, 2009 #include <array.au3> $stringInput="base1: <form>"&@CRLF&"base2: <form>"&@CRLF&"base3: <form>"&@CRLF&"base4: <form>"&@CRLF&"base5: <form>"&@CRLF&"base6: <form>"&@CRLF&"base7: <form>" $reg=StringRegExp($stringInput,"(.*?): (.*?)"&@CRLF,3) _ArrayDisplay($reg) I'm sorry, i'm having trouble understanding your piece of code... My original plan means making a new file for each word, however if you explain your bit of code i'll be more then happy to use it. Link to comment Share on other sites More sharing options...
MerkurAlex Posted December 17, 2009 Share Posted December 17, 2009 I'm sorry, i'm having trouble understanding your piece of code... My original plan means making a new file for each word, however if you explain your bit of code i'll be more then happy to use it. You, would simply loop through the array my code provides ($reg), and write a new file with the contents. Something like this: #include <array.au3> $stringInput = "base1: <form>" & @CRLF & "base2: <form>" & @CRLF & "base3: <form>" & @CRLF & "base4: <form>" & @CRLF & "base5: <form>" & @CRLF & "base6: <form>" & @CRLF & "base7: <form>" $reg = StringRegExp($stringInput, "(.*?): (.*?)" & @CRLF, 3) _ArrayDisplay($reg) For $i = 0 To UBound($reg) - 1 Step 2 $fh = FileOpen(@ScriptDir & "\" & $reg[$i] & ".txt", 2) FileWrite($fh, $reg[$i + 1]) FileClose($fh) Next I have not tested the code above, but in theory it should work. [quote name='PsaltyDS' post='635433' date='Jan 27 2009, 07:04 AM']Larry is a mass murderer?! It's always the quiet, clean cut, bald guys... [/quote] Link to comment Share on other sites More sharing options...
GodForsakenSoul Posted December 17, 2009 Author Share Posted December 17, 2009 you seem to have misunderstood me... i ALREADY (theoretically) have the files... problem is i don't know how to read a specific line from a specific file which will be chosen by a random number gen =D Link to comment Share on other sites More sharing options...
playlet Posted December 17, 2009 Share Posted December 17, 2009 (edited) --- Edited August 18, 2016 by playlet Link to comment Share on other sites More sharing options...
Mison Posted December 21, 2009 Share Posted December 21, 2009 $data1 = FileRead("test.txt") $forms = StringRegExp($data1,":(.+)",3) $random = Round(Random(0,UBound($forms)-1)) MsgBox(0,"Random base",$forms[$random])Reading_text.zip Hi ;) 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