 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
txquestor
Joined: 22 Aug 2009 Posts: 294
|
Posted: Mon Nov 30, 2009 6:52 pm Post subject: |
|
|
hugov, Wonderful Project
Thanks for sharing
Very useful
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.
Look forward to use any future work of yours:!:  _________________
"Man's quest for knowledge is an expanding series whose limit is infinity" |
|
| Back to top |
|
 |
SoLong&Thx4AllTheFish
Joined: 27 May 2007 Posts: 4999
|
Posted: Mon Nov 30, 2009 7:46 pm Post subject: |
|
|
@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) 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 Wiki FAQ
TF : Text files & strings lib, TF Forum |
|
| Back to top |
|
 |
SoLong&Thx4AllTheFish
Joined: 27 May 2007 Posts: 4999
|
Posted: Wed Dec 09, 2009 5:34 pm Post subject: |
|
|
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 Wiki FAQ
TF : Text files & strings lib, TF Forum |
|
| Back to top |
|
 |
SoLong&Thx4AllTheFish
Joined: 27 May 2007 Posts: 4999
|
|
| Back to top |
|
 |
gregW5865
Joined: 28 Dec 2009 Posts: 5 Location: Torrance, CA
|
Posted: Mon Dec 28, 2009 9:05 pm Post subject: TF_Replace with variables |
|
|
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 |
|
| Back to top |
|
 |
SoLong&Thx4AllTheFish
Joined: 27 May 2007 Posts: 4999
|
Posted: Mon Dec 28, 2009 9:24 pm Post subject: Re: TF_Replace with variables |
|
|
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 Wiki FAQ
TF : Text files & strings lib, TF Forum |
|
| Back to top |
|
 |
gregW5865
Joined: 28 Dec 2009 Posts: 5 Location: Torrance, CA
|
Posted: Tue Dec 29, 2009 3:34 am Post subject: Re: TF_Replace with variables |
|
|
Thanks for the help. That did the trick. _________________ Greg W |
|
| Back to top |
|
 |
gregW5865
Joined: 28 Dec 2009 Posts: 5 Location: Torrance, CA
|
Posted: Wed Dec 30, 2009 5:38 am Post subject: Insert Suffix |
|
|
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 |
|
| Back to top |
|
 |
SoLong&Thx4AllTheFish
Joined: 27 May 2007 Posts: 4999
|
|
| Back to top |
|
 |
gregW5865
Joined: 28 Dec 2009 Posts: 5 Location: Torrance, CA
|
Posted: Wed Dec 30, 2009 7:38 am Post subject: Insert Suffix |
|
|
I feel real stupid 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 |
|
| Back to top |
|
 |
SoLong&Thx4AllTheFish
Joined: 27 May 2007 Posts: 4999
|
Posted: Wed Dec 30, 2009 7:49 am Post subject: |
|
|
Don't feel bad, I'm glad someone is using it 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 Wiki FAQ
TF : Text files & strings lib, TF Forum |
|
| Back to top |
|
 |
gregW5865
Joined: 28 Dec 2009 Posts: 5 Location: Torrance, CA
|
Posted: Sat Jan 02, 2010 5:51 am Post subject: Problem subtracting dates in a file |
|
|
I'm stuck again...Just when I thought I was finished
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 |
|
| Back to top |
|
 |
Guest
|
Posted: Sat Jan 02, 2010 8:19 am Post subject: |
|
|
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 |
|
|
| Back to top |
|
 |
Tom
Joined: 20 Dec 2009 Posts: 15
|
Posted: Sun Jan 03, 2010 2:17 pm Post subject: |
|
|
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 |
|
| Back to top |
|
 |
SoLong&Thx4AllTheFish
Joined: 27 May 2007 Posts: 4999
|
Posted: Sun Jan 03, 2010 8:28 pm Post subject: |
|
|
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 Wiki FAQ
TF : Text files & strings lib, TF Forum |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|