boiler wrote: ↑01 Jul 2021, 21:03
The first script works as long as you define the input variable and use the correct output variable like the script I posted does.
You are doing something different in the second script. You have it needing to match a space (
\s) following the price in that script, which isn’t the case in the input string. If you change it to needing to match a letter after the price, it works:
Code: Select all
firstline := "1 F2 K3341 RTLO149-20918 SPL O-RING KIT 19.94EA 19.94"
foundvarprice := RegExMatch(firstline, "(\d+\.\d+)\w", pprice)
MsgBox, % pprice1
Yeah, sorry I should of explained more -
The input variable gets defined when the user presses ` in front of the item line, it copies the line and saves it as that variable
the second script was just the last vendor I added, it worked great, each vendor has a different format for listing their items:
sometimes quantity is listed first before the part number or sometimes it is listed after the description etc..
so I have to make a template for each vendor to get their Invoice / PO / Cost of item, description etc ..
and then I can just inject that into their DB instead of typing out each invoice by hand
Code: Select all
If (KenworthFlag = 1)
{
Click, Left, 1
Sleep, 25
Send, {Shift Down}{End}{Shift Up}
Sleep, 25
Send, {Control Down}{c}{Control Up}
Sleep, 25
Send, {Home}
Sleep, 25
firstline := clipboard
wholeline := StrReplace(firstline, "$" , "")
linearray := StrSplit(wholeline, A_Space)
FoundvarEOD := RegExMatch(wholeline, "\s[A-Z][A-Z]\s\d*\d*\d", EOD)
descriptionA := StrSplit(wholeline, [linearray[2] , EOD])
secondhalf := StrSplit(wholeline, descriptionA[2])
secondstring := secondhalf[2]
secondlist := StrSplit(secondstring, A_Space)
partnumber := linearray[2]
partdescription := descriptionA[2]
UOM := secondlist[2]
partquantity := secondlist[3]
partprice := secondlist[4]
linetotal := secondlist[5]
}
If (FleetbrakeFlag = 1)
{
Click, Left, 1
Sleep, 25
Send, {Shift Down}{End}{Shift Up}
Sleep, 25
Send, {Control Down}{c}{Control Up}
Sleep, 25
Send, {Home}
Sleep, 25
firstline := clipboard
parray := StrSplit(firstline, A_Space)
partnumber := parray[1]
fouindvaruom := RegExMatch(firstline, "\s([A-Z]+)\s\d+\s", UOM)
descriptionA := StrSplit(firstline, [parray[1] , UOM1])
partdescription := descriptionA[2]
foundvarqty := RegExMatch(firstline, "\w+\s(\d+)\s\$", pqty)
foundvarprice := RegExMatch(firstline, "\$(.+\..+)\s", pprice)
partquantity := pqty1
partprice := pprice1
}
If (FortgarryFlag = 1)
{
Click, Left, 1
Sleep, 10
Send, {Shift Down}{Down 2}{Shift Up}
Sleep, 25
Send, {Control Down}{c}{Control Up}
Sleep, 100
Send, {Home}
Sleep, 10
firstline := clipboard
linearray := StrSplit(firstline, A_Space)
secondhalf := StrSplit(firstline, descriptionA[2])
partnumber := linearray[2]
foundvarprice := RegExMatch(firstline, "(\d+\.\d+)\s", pprice)
foundvardesc := RegExMatch(firstline, "\n(.+)\s", pdesc)
partdescription := pdesc1
partquantity := linearray[4]
partprice := pprice1
UOM := linearray[3]
}
If (GreggFlag = 1)
{
Click, Left, 1
Sleep, 10
Send, {Shift Down}{Down 2}{Shift Up}
Sleep, 25
Send, {Control Down}{c}{Control Up}
Sleep, 100
Send, {Home}
Sleep, 10
line1 := clipboard
firstline := RegExReplace(line1, "−", "-")
firstline := RegExReplace(firstline, "\s+", A_Space)
parray := StrSplit(firstline, A_Space)
partnumber := parray[4]
foundvarprice := RegExMatch(firstline, "(\d+\.\d+)\s", pprice)
foundvardesc := RegExMatch(firstline, "\n(.+)\s", pdesc)
partdescription := pdesc1
partquantity := linearray[2]
partprice := pprice1
MsgBox, 0, ,
(LTrim
Part Number = %partnumber%
Part Description = %partdescription%
Part Quantity = %partquantity%
Part Price = %partprice%
)
}
I am just trying to add all our vendors and the newest vendor I am trying to add is just returning the blank message box when I try and grab the line item, the ( %foundvarpartprice% gives me the location of the find but %pprice1% and even %pprice% still is returning a blank message box)
you said you tried the regex with the string I posted, and it returned the result, Regex101 is showing me that it is valid as well so I am going to try and removing all \s and replacing them with A_Space because I think it is a formatting issue when I am grabbing the line directly from the PDF - maybe it's picking up a return line and not regexing that out properly in ahk
I dont have access to that exact script or invoice today so when I get back to work on Monday I will try entering that string as
Code: Select all
firstline := "1 F2 K3341 RTLO149-20918 SPL O-RING KIT 19.94EA 19.94"
and if it displays the price maybe it will be an easy fix by simply replacing all white space (\s) with ' A_Space ' ?
thank you so much for your insight and help so far - you are so wonderful roaming around the forums helping people it's just so great to see.