Reading line of text from inside of a txt or doc file by a script

Post Reply
muharremaltintas
Newbie
Posts: 8
Joined: Mon Mar 19, 2012 9:20 am

Reading line of text from inside of a txt or doc file by a script

Post by muharremaltintas »

Hello all,



I've asked this question to Freddy. But i think he's busy now. so he didn't answer my question yet.



After that, i thought to ask my question to the forum.



I'd like to read a line of text or word from inside of a txt to doc file to manage and direct it from a flow in Switch. Last training in Enfocus, Freddy has told me that i con do it with readLine file class' Member Text I/O functions. And i did something with this function. And i've got something with my poor scripting knowledge. As a result, my script doesn't give me a line of text but it shows the font information from the txt file. i have this result using with log. And you ken see the attached screenshot of my Switch scripter window. and the code itself.



At that point, i need some advice how can get the text inside of a txt file which is written inside of it.



For instance:



if the txt or doc file include the text like this:





Muharrem ALTINTAS

WIT Dünya Bilisim Teknolojileri

Te: +902122702052





I would like to read the first line of the text "Muharrem ALTINTAS" with readLine function.



I wrote this script to do this.



function jobArrived( s : Switch, job : Job )

{

var dosya = job.getPath();

var oku = new File(dosya);



oku.open(File.ReadOnly);

oku.readLine();



var satir = oku.readLine();





s.log(1,satir);



oku.close();





job.sendToSingle(job.getPath());





}



when run this script, info gives me this information: " {fonttblf0fswissfcharset0 Helvetica;} "



I didn't have chance to take the text line that i want to.



I'm sure, i'm missing something in this scripting code but i don't aware of it yet.



Could you share your opinions with me? Or you may advice a different way to have this information.





Here is the screenshot of my Switch Scripter window:



http://img62.imageshack.us/img62/9920/r9l9.jpg





Kind Regards..
tz8
Member
Posts: 84
Joined: Mon Aug 13, 2012 12:56 pm

Reading line of text from inside of a txt or doc file by a script

Post by tz8 »

here's a good start on how to cleanup an RTF file to get to the raw text lines:



http://webcheatsheet.com/php/reading_th ... om_rtf.php



PS: remove the following line from your script:

oku.readLine();

that one does nothing...
muharremaltintas
Newbie
Posts: 8
Joined: Mon Mar 19, 2012 9:20 am

Reading line of text from inside of a txt or doc file by a script

Post by muharremaltintas »

Hi tz8,



Thank you for your advice. I'll try it.
muharremaltintas
Newbie
Posts: 8
Joined: Mon Mar 19, 2012 9:20 am

Reading line of text from inside of a txt or doc file by a script

Post by muharremaltintas »

Hi tz8,



After having your link for cleaning text from rtf file. I thought that i can get the text line like "plain text". So, i applied my script to plain text and it worked as expected.



Thank you again for the link that explains cleaning text from rtf file.





http://img819.imageshack.us/img819/5631/g331.jpg





Have a nice evening..
Post Reply