AutoHotkey Community

It is currently May 27th, 2012, 12:54 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 194 posts ]  Go to page Previous  1 ... 3, 4, 5, 6, 7, 8, 9 ... 13  Next
Author Message
 Post subject:
PostPosted: November 30th, 2009, 7:52 pm 
Offline

Joined: August 22nd, 2009, 11:23 pm
Posts: 294
hugov, Wonderful Project
Thanks for sharing
Very useful :!: :lol:
Nice addition to my UltraEdit features/functions

I used both v2 and v3 regularly and recommend to users
who need it's detailed filtering/replacing etc ...

Great documentation too. :idea:

Look forward to use any future work of yours:!: :roll:

_________________
Image
"Man's quest for knowledge is an expanding series whose limit is infinity"


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 30th, 2009, 8:46 pm 
Offline

Joined: May 27th, 2007, 9:41 am
Posts: 4999
@txquestor: thanks, glad to hear you find it useful. I see you are man (or woman) of good taste, you like UltraEdit (I do too) :wink: I've seen you recommending it a few times, thanks for that as well.

The documentation was quite a bit of work and could probably still be improved, I'm not sure if I would want to do it again in the same way.

_________________
AHK FAQ
TF : Text files & strings lib, TF Forum


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 9th, 2009, 6:34 pm 
Offline

Joined: May 27th, 2007, 9:41 am
Posts: 4999
Update v3.1:

- Rewrite of TF_Find. Can now return multiple lines (like TF_Findlines used to), but not only line numbers but the entire line (text) of the found lines so it can be used as a basic grep.

- Now uses RegExMatch and no longer IfInString

- Deprecated: TF_FindLines (see change TF_Find). Kept in for backwards compatibility

TF_Find(Lines) compatibility note:

- Because the old TF_Find(Lines) did not use RegExMatch you may need to rewrite some of your SearchText parameters. This means that if you used "special" characters which have a special meaning in a RegEx: \.*?+[{|()^$ they must be preceded by a backslash to be seen as literal. For example, \. is a literal period and \\ is a literal backslash. Escaping can be avoided by using \Q...\E. For example: \QLiteral Text\E. See http://www.autohotkey.com/docs/commands/RegExMatch.htm for further information.

- The CaseSensitive paramaters has been dropped, if you used that update your call to TF_Find I'm affraid

_________________
AHK FAQ
TF : Text files & strings lib, TF Forum


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 23rd, 2009, 9:42 pm 
Offline

Joined: May 27th, 2007, 9:41 am
Posts: 4999
deleted

_________________
AHK FAQ
TF : Text files & strings lib, TF Forum


Last edited by SoLong&Thx4AllTheFish on January 15th, 2010, 6:01 pm, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
PostPosted: December 28th, 2009, 10:05 pm 
Offline

Joined: December 28th, 2009, 9:57 pm
Posts: 5
Location: Torrance, CA
Thanks for the work on the TF library. It has simplified what I am trying to do. I have hit a snag and hoping someone can help.
I am trying to change dates in a file that are in mm/dd format and I want it in yyyy-mm-dd format.
I have a variable:
year= 2009
Then I try to put the year in front of the month and I can't figure out the syntax. I've tried variations on this:
TF_Replace(f,"01/",%Year% "-01") or
TF_Replace(f,"01/",% %Year% ."-01")
I get errors regarding needing quote or ")" but I can't figure it out.
Any help is greatly appreciated.

_________________
Greg W


Report this post
Top
 Profile  
Reply with quote  
PostPosted: December 28th, 2009, 10:24 pm 
Offline

Joined: May 27th, 2007, 9:41 am
Posts: 4999
So you have this mm/dd and you want it in yyyy-mm-dd

So 01/02 -> 2009-01-02, that means TF_Replace must be
Code:
TF_Replace(f,"01/02","2009-01-02") ; note the use of ! if you want to overwrite the source file

So translating that to variables would be
Code:
TF_Replace(f,"01/", year . "-01-") ; note the use of ! if you want to overwrite the source file


Note: you could also use a regexp, could be something like
Code:
TF_RegExReplace(f,"(\d\d)\\(\d\d)", year . "-$1-$2") ; note the use of ! if you want to overwrite the source file
(fiddling with regex can be difficult so may not be what you want to look into just yet if you start with AHK)

_________________
AHK FAQ
TF : Text files & strings lib, TF Forum


Report this post
Top
 Profile  
Reply with quote  
PostPosted: December 29th, 2009, 4:34 am 
Offline

Joined: December 28th, 2009, 9:57 pm
Posts: 5
Location: Torrance, CA
Thanks for the help. That did the trick.

_________________
Greg W


Report this post
Top
 Profile  
Reply with quote  
 Post subject: Insert Suffix
PostPosted: December 30th, 2009, 6:38 am 
Offline

Joined: December 28th, 2009, 9:57 pm
Posts: 5
Location: Torrance, CA
I'm stuck again.
I have the main file I am working (f) with and a second file (s) with the same number of lines. I want to add line one from the second file to line one of the first file and then repeat for each line.
Code:
f= !first.txt
s= !second.txt

GetLine:=TF_Find(s,"","","",0,1) 
TF_InsertSuffix(f,"","", TF_ReadLines(GetLine,"","",0) . "@")


I also tried this:
Code:
GetLine:=TF_Find(s,"","","",0,1) ;
Line= % TF_ReadLines(GetLine,"","",0) ;
TF_InsertSuffix(f,"","", %line% . "@") ;


I get the desired results for the first line but all other lines only contain lines from the second file.

Thanks for your help

_________________
Greg W


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 30th, 2009, 7:43 am 
Offline

Joined: May 27th, 2007, 9:41 am
Posts: 4999
Doesn't TF_ConCat fit the bill here:
http://www.autohotkey.net/~hugov/tf-lib.htm#TF_ConCat

Output wrote:
Line 1 file 1 Line 1 File 2
Line 2 file 1 Line 2 File 2
Line 3 file 1 Line 3 File 2
etc

_________________
AHK FAQ
TF : Text files & strings lib, TF Forum


Report this post
Top
 Profile  
Reply with quote  
 Post subject: Insert Suffix
PostPosted: December 30th, 2009, 8:38 am 
Offline

Joined: December 28th, 2009, 9:57 pm
Posts: 5
Location: Torrance, CA
I feel real stupid :oops: I read through the list several times and over looked that one. Thanks for the quick reply and the great work on the library.

_________________
Greg W


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 30th, 2009, 8:49 am 
Offline

Joined: May 27th, 2007, 9:41 am
Posts: 4999
Don't feel bad, I'm glad someone is using it :wink: The names are a bit peculiar at times, ConCat it probably doesn't ring a bell with many people. If you think there is something missing I'm always open for suggestions so feel free to ask.

_________________
AHK FAQ
TF : Text files & strings lib, TF Forum


Report this post
Top
 Profile  
Reply with quote  
PostPosted: January 2nd, 2010, 6:51 am 
Offline

Joined: December 28th, 2009, 9:57 pm
Posts: 5
Location: Torrance, CA
I'm stuck again...Just when I thought I was finished :D
I have a file with dates in the yyyymmddhhmmss format like this and that is all the file contains.
20100103080000
20100103090000
20100103210000
20100104025800
20100103080000

I want to subtract 2 minutes from each line. I have tried various options using EnvSub but I just don't get it. I need help with setting up the varaibles and which TF_ command would be best.

Thanks for your help.
Greg

_________________
Greg W


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 2nd, 2010, 9:19 am 
Try this. The first bit is an example how math with time works, the second bit is a possible solution. In this case I wouldn't use any TF functions in particular but you could use TF_Save
Code:
;  yyyymmddhhmmss
t=20100103210000 ; original
x=20100103205800 ; should be become
t += -2, Minutes
MsgBox % t "`n" x

; so if you have a file with only times, I suggest not to use TF as such
; but rather a fileread, loop and TF_Save (or filedelete and a fileappend)

FileRead, original, file.txt
Loop, parse, original, `n, `r
   {
    if (A_LoopField <> "")
      {
       NewTime:=A_LoopField
       NewTime += -2, Minutes
            Output .= NewTime "`n"
      }
    NewTime= ; just to be sure
   }
StringTrimRight, Output, Output, 1 ; trim trailing newline
TF_Save(Output, "file.txt", 0) ; will make file_copy.txt so you can test, remove 0 if OK and it will overwrite


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: January 3rd, 2010, 3:17 pm 
Offline

Joined: December 20th, 2009, 10:58 am
Posts: 15
Hi

I have what I hope are 2 simple questions about TF.ahk

I'm currently using this to read the first line that matches my value 'disengage':
Code:
GetLine:=TF_Find(ReceivedData,"","","disengage",1,1)

This works well and outputs the first matching line to GetLine. I then filter that line and no problems with this :)

I'm now looking to do some thing similar but instead of matching just one line I need it to match on multiple lines and, if possible, join the results together.

The data I receive is similar to this:
Code:
aMode,,0000003e,4
aMode,,0000003e,A
aMode,,0000003e,C
aMode,,0000003e,3

The command at the beginning stays the same (aMode) there is usually the double commas followed by an ID field and finally the values I want to capture..

The example shows 4 lines, but it could be upto 12 lines.

How would I capture this and return the values to a variable.
eg: var = 4AC3


Last one:
Currently I'm only using "TF_Find", what can I strip from TF.ahk to reduce the size of the file included in my script ?

Many Thanks


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 3rd, 2010, 9:28 pm 
Offline

Joined: May 27th, 2007, 9:41 am
Posts: 4999
1) If you strip TF_Find to its bare mininum for YOUR purposes, e.g. just return the first found line it is this, note the new name so it doesn't conflict with the TF lib
Code:
test=
(
1 a
2 b
3 c
4 d
)

MsgBox % XTF_Find(test,"b")

XTF_Find(Text, SearchText = "")
   {
    If (RegExMatch(Text, SearchText) < 1)
       Return "0" ; SearchText not in file or error, do nothing
    Loop, Parse, Text, `n
      {
          If (RegExMatch(A_LoopField, SearchText) > 0)
             {
               Return A_LoopField
               Break
            }   
      }
   }


2) you're probably better of writing your own function to get that data it would be faster and easier, UNLESS the final columns always has the same position e.g. it is always column 15, if that is the case you can use TF_ColGet and simply to a stringreplace `n to remove the newline chars.

_________________
AHK FAQ
TF : Text files & strings lib, TF Forum


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 194 posts ]  Go to page Previous  1 ... 3, 4, 5, 6, 7, 8, 9 ... 13  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: Cristi® and 10 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group