seperating text

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
Jmac2501
Pro Scripter
Posts: 76
Joined: Tue Nov 15, 2005 8:11 pm

seperating text

Post by Jmac2501 » Tue Feb 27, 2007 12:09 pm

I would like to find a way to seperate text from a line. I am using a scrip that returns the a value of:

6_lotid_V703585G

The "6_lotid_ " is always the same and i don't need that part. I need the V703585G part of this value. Is there a way to do this?

I was thinking of
let>6_lotid_=

but this didn't work

Any help Thanks

Jmac2501
Pro Scripter
Posts: 76
Joined: Tue Nov 15, 2005 8:11 pm

Post by Jmac2501 » Tue Feb 27, 2007 12:19 pm

Never mind i found a way using:

let>line=6_lotid_V703585G

MidStr>line,9,8,somevalue

message>somevalue

Thanks

User avatar
Marcus Tettmar
Site Admin
Posts: 7380
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Tue Feb 27, 2007 12:22 pm

Or if the position of 6_lotid_ is not predetermined you can use:

let>line=6_lotid_V703585G
Separate>line,6_lotid_,values
MessageModal>values_2

Or

let>line=6_lotid_V703585G
Pos>6_lotid_,line,1,p
Let>s=p+8
Length>line,l
MidStr>line,s,l,value
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

User avatar
Rain
Automation Wizard
Posts: 550
Joined: Tue Aug 09, 2005 5:02 pm
Contact:

Post by Rain » Tue Feb 27, 2007 1:07 pm

You could also do this since the first part is always the same

Code: Select all

let>line=6_lotid_V703585G
StringReplace>line,6_lotid_,,Result
MessageModal>Result
Last edited by Rain on Tue Feb 27, 2007 1:10 pm, edited 1 time in total.

User avatar
Marcus Tettmar
Site Admin
Posts: 7380
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Tue Feb 27, 2007 1:09 pm

Macro Scheduler is like a cat - there are lots of ways to swing it :-)
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

User avatar
Rain
Automation Wizard
Posts: 550
Joined: Tue Aug 09, 2005 5:02 pm
Contact:

Post by Rain » Tue Feb 27, 2007 1:10 pm

Yep, that's what's so great about this product!

Jmac2501
Pro Scripter
Posts: 76
Joined: Tue Nov 15, 2005 8:11 pm

Post by Jmac2501 » Tue Feb 27, 2007 1:49 pm

Great ideas here. But here is another test for you lol.

ok in the text files i am searching there are any where from 50 to 10,000 lines of text. I know that my last value i want to retreave is only 5 away from the bottom. is there a way for it to jump to the bottom of the page and work up.

any Ideas lol. :lol:

User avatar
Marcus Tettmar
Site Admin
Posts: 7380
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Tue Feb 27, 2007 2:04 pm

Yes, but there's not really a performance gain compared with reading from the top, since you have to determine the number of lines first. You can do it like this:

Code: Select all

Let>file=c:\test.txt

ReadFile>file,fileText
Separate>fileText,CRLF,lines

Let>5th_From_Bottom=lines_count-5
Let>theline=lines_%5th_From_Bottom%

MessageModal>theLine
But I wouldn't recommend this for large files - it could be quite slow because it reads the entire file into memory. In this case you'd actually be better off reading one line at a time.

You can do it with lower level programming languages by setting the file pointer to the end and reading backwards, counting the line terminators as you go. MacroScript can't do this. Actually you can probably do this in VBScript, but it will require more advanced code.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

Jmac2501
Pro Scripter
Posts: 76
Joined: Tue Nov 15, 2005 8:11 pm

Post by Jmac2501 » Tue Feb 27, 2007 2:45 pm

Yeah that takes to long but to search all 10,000 lines. Thanks anyways

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts