AutoHotkey Community

It is currently May 27th, 2012, 11:23 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 194 posts ]  Go to page Previous  1 ... 9, 10, 11, 12, 13
Author Message
 Post subject:
PostPosted: December 17th, 2011, 6:09 pm 
Offline

Joined: December 26th, 2010, 7:40 pm
Posts: 4172
Location: Awesometown, USA
Hmm... why post as a guest? Forgot your password?

_________________
Autofire, AutoClick, Toggle, SpamWindow Control Tools
Recommended: AutoHotkey_L


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 18th, 2011, 10:49 pm 
nimda wrote:
Hmm... why post as a guest? Forgot your password?
"Guest" is a registred nickname (so a member). If you look under my nickname, you'll see "Guest". That mean that i'm not registred under that nickname. For me a question : where is the 3.4 version ?


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: December 18th, 2011, 10:53 pm 
Offline

Joined: December 26th, 2010, 7:40 pm
Posts: 4172
Location: Awesometown, USA
I meant why does hugov post as a guest.

_________________
Autofire, AutoClick, Toggle, SpamWindow Control Tools
Recommended: AutoHotkey_L


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 18th, 2011, 10:56 pm 
On my HDD, DropBox and USB drive for safety ;-)
(see the "still experimenting ..." in the previous post. I'm not entirely convinced it is foolproof yet (although atm the current behaviour is actually a bug (sortof) in TF3.3, TF_Find and some others could have false negatives if you use the ^ in the SearchText parameter, the solution is not to actually use ^ :lol: ))


Report this post
Top
  
Reply with quote  
PostPosted: April 16th, 2012, 10:17 pm 
Offline

Joined: June 7th, 2007, 1:33 pm
Posts: 1019
I am trying to use this library for some specific functions

1) I want to check if a specific line, contains a specific text
2) I want to check is a specific line, is a specific text

how can I do these?

I tried:

#Include tf.ahk

Code:
If TF_Find(Clipboard,1,1, SearchText = "   Tot Mic ",1,1)
{
msgbox ok!
}


with no luck

thanks


Report this post
Top
 Profile  
Reply with quote  
PostPosted: April 16th, 2012, 10:23 pm 
SearchText is a parameter, you can't call it the way you do

Code:
TF_Find(Text, StartLine = 1, EndLine = 0, SearchText = "", ReturnFirst = 1, ReturnText = 0)

would translate to
Code:
TF_Find(Text, 1, 1, "    Tot Mic ", 1, 1)
or
Code:
 SearchText:="     Tot Mic "
TF_Find(Text, 1, 1, SearchText, 1, 1) ; as variable


Note that TF_Find uses RE by default so you may need to use "\Q Tot Mic \E" see the RE docs "... Escaping can be avoided by using \Q...\E. For example: \QLiteral Text\E." http://www.autohotkey.com/docs/misc/RegEx-QuickRef.htm


Report this post
Top
  
Reply with quote  
PostPosted: April 16th, 2012, 10:47 pm 
Offline

Joined: June 7th, 2007, 1:33 pm
Posts: 1019
okay, it seems to work now, thanks

but I get a warning about an uninitialized variable in tf.ahk, why do I get this and how do I fix that?

(I use AHK_L)


Report this post
Top
 Profile  
Reply with quote  
PostPosted: April 17th, 2012, 7:37 am 
Comment #warn, there is no error or something to fix as such.


Report this post
Top
  
Reply with quote  
PostPosted: May 18th, 2012, 4:29 pm 
Offline

Joined: September 2nd, 2008, 4:20 pm
Posts: 50
I'm trying to search a text file for a specific line, and subtract one value from another value that is on the end of the line so I thought I'd try to use tf_replace against a stored variable, not even sure if that's possible though:

Code:
#include tf.ahk
bosstaline:=tf_find("Daily Check subtraction.txt","","","Maximum Stations: 4490",0,1)
tf_replace("!bosstaline","Maximum Stations: 4490","")
var3:=4490-bosstaline
MsgBox, 4490 - %bosstaline% = %var3%


the var bosstaline works right, it copies the whole line that has Maximum Stations: 4490 into it, but I'm not able to trim the beginning of the line to get just the value that is at the end of the line by itself.

TIA


Report this post
Top
 Profile  
Reply with quote  
PostPosted: May 18th, 2012, 6:35 pm 
You can with a step in between:
Code:
text=  ; just for testing purpose using a variable here to show you how it works
(join`r`n
1
2
Maximum Stations: 4490
4
5
)
BosstaLine:=TF_Find(text,"","","Maximum Stations:",0,1)
RegExMatch(BosstaLine,"Maximum Stations: (\d+)",CurrentValue)
NewValue := CurrentValue1 - 1 ; note the 1 here see RegExMatch docs for  info
Text:=TF_Replace(text,bosstaline,"Maximum Stations: " NewValue)
MsgBox % CurrentValue1 "---" Text

/* for your file it would become:

BosstaLine:=tf_find("Daily Check subtraction.txt","","","Maximum Stations:",0,1)
RegExMatch(bosstaline,"Maximum Stations: (\d+)",CurrentValue)
NewValue := CurrentValue1 - 1
TF_Replace("!Daily Check subtraction.txt",bosstaline,"Maximum Stations: " NewValue)


Report this post
Top
  
Reply with quote  
PostPosted: May 24th, 2012, 7:52 pm 
How do I check a logfile that is constantly uppdating for the 14 last lines? The log looks like this:

Code:
Item      :30105901
UOM       :TH
Qty       :14
From Sub  :DJ
From Loc  :DJ.34..
To LPN    >STO222135008
To Sub    :UTLAST
To Loc    :UTLAST...
<Drop/Next>
<Drop>
<Discrepancy>
<Skip Task>
<Cancel>
 
Item      :30105901
UOM       :TH
Qty       :14
From Sub  :DJ
From Loc  :DJ.34..
To LPN    >STO222135008
To Sub    :UTLAST
To Loc    :UTLAST...
 
<Drop>
<Discrepancy>
<Skip Task>
<Cancel>
 
Item      :30112608
UOM       :TH
Qty       :2
From Sub  :DJ
From Loc  :DJ.38..
To LPN    >
To Sub    :UTLAST
To Loc    :UTLAST...
<Drop/Next>
<Drop>
<Discrepancy>
<Skip Task>
<Cancel>


And I want a gui to show up with different info depending on what the last Item number is.


Report this post
Top
  
Reply with quote  
PostPosted: May 24th, 2012, 8:58 pm 
Assuming you just want the Item number marked red below you don't need tail or tf
Code:
text=
(join`r`n
Item      :30105901
1
Item      :30105901
2
Item      :40112608
3
)
StringGetPos, Pos, Text, Item, R%Lines% ; this code is taken from TF_Tail ;-)
Pos+=10 ; lengt of letters of item+spaces+: so you may need to fiddle with it if is actually a tab vs spaces or vice versa
StringTrimLeft, Text, Text, % ++Pos
StringGetPos, Pos, Text, `r`n
StringLeft, Text, Text, % Pos
MsgBox % "|" Text "|"

you can figure out the loop and fileread to get the text (don't reply post here - do so in your original topic as this has nothing to do with TF viewtopic.php?f=1&t=86771 - thanks.


Report this post
Top
  
Reply with quote  
PostPosted: Yesterday, 6:25 am 
does (StartLine, Endline) Syntax accept variables? I am having trouble with TF_ReplaceLine because the line numbers are variables.


Report this post
Top
  
Reply with quote  
PostPosted: Yesterday, 7:26 am 
Yes it does, you probably are using %% around your variable name which is not correct when calling functions, do it like so
Code:
Start=5 ; start can also be 5+5 (every fifth line) 5-10 (lines 5 to 10)
End=6
TF_ReplaceLine("file.txt", Start, End, "New Text")


Report this post
Top
  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 194 posts ]  Go to page Previous  1 ... 9, 10, 11, 12, 13

All times are UTC [ DST ]


Who is online

Users browsing this forum: MSN [Bot], nomissenrojb, Rajat and 57 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