Sign in to follow this  
Followers 0
GodForsakenSoul

Reading text [not solved]

7 posts in this topic

#1 ·  Posted (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. :evil:

Edited by GodForsakenSoul

Share this post


Link to post
Share on other sites



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]

Share this post


Link to post
Share on other sites

#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. ;)

Share this post


Link to post
Share on other sites

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]

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

---

Edited by playlet

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
Sign in to follow this  
Followers 0