[PCOMM SCRIPT HEADER] LANGUAGE=VBSCRIPT DESCRIPTION= [PCOMM SCRIPT SOURCE] OPTION EXPLICIT autECLSession.SetConnectionByName(ThisSessionName) Dim upcs(5000), i, j Dim vendor, session, bUPC, cUPC, cPrice, scr, r, row9, fso, ts ' --- NEW HTTP VARIABLES --- Dim http, url, responseText, lines, lineIndex Dim fileTimestampStr, parsedDate, isFresh, reUPC, currentUPC url = "https://upc.ih8.us/list" ' <-- Update this URL ' Initialize HTTP Object Set http = CreateObject("MSXML2.XMLHTTP") ' MSXML2.ServerXMLHTTP.6.0 http.Open "GET", url, False http.Send i = 0 isFresh = False If http.Status = 200 Then responseText = http.ResponseText ' Strip carriage returns and split by line feed lines = Split(Replace(responseText, vbCr, ""), vbLf) ' --- DATE CHECK LOGIC --- If UBound(lines) >= 0 And Trim(lines(0)) <> "" Then fileTimestampStr = Trim(lines(0)) ' Strip 'T' and 'Z' to allow VBScript CDate to parse strict ISO 8601 fileTimestampStr = Replace(fileTimestampStr, "T", " ") fileTimestampStr = Replace(fileTimestampStr, "Z", "") ' If this fails (not a valid time format), isFresh stays False If IsDate(fileTimestampStr) Then parsedDate = CDate(fileTimestampStr) If Abs(DateDiff("n", parsedDate, Now)) <= 5 Then isFresh = True End If End If End If ' ----------------------------- ' Only process UPCs if the timestamp was valid AND within 5 minutes If isFresh Then ' Initialize Regex to validate UPCs (1 to 13 digits only, no letters/symbols) Set reUPC = CreateObject("VBScript.RegExp") reUPC.Pattern = "^\d{1,13}$" ' Start at lineIndex = 1 to skip the timestamp on line 0 For lineIndex = 1 To UBound(lines) currentUPC = Trim(lines(lineIndex)) If currentUPC <> "" Then ' Vet the UPC: must be exactly 1-13 digits If reUPC.Test(currentUPC) Then upcs(i) = currentUPC i = i + 1 ' Protect against exceeding the Dim upcs(5000) array bounds If i > 4999 Then Exit For End If End If Next End If End If ' Only execute the main macro if the file was fresh If isFresh Then upcs(i) = "" i = 0 subPrintHardcoded End If Sub subPrintHardcoded() Set session = autECLSession For i = 0 To 5000 If upcs(i) = "" Then Exit For Exit Sub End If If autECLSession.autECLPS.GetText(1,2,10) <> "Item entry" Then Exit Sub End If For j = 0 To 13 If left(upcs(i), 1) = 0 Then upcs(i) = mid(upcs(i), 2) Else Exit For End If Next autECLSession.autECLOIA.WaitForAppAvailable autECLSession.autECLOIA.WaitForInputReady autECLSession.autECLPS.SetCursorPos 1,20 autECLSession.autECLPS.WaitForCursor 1,20,10000 autECLSession.autECLPS.SendKeys "[erase eof]" autECLSession.autECLPS.SendKeys upcs(i) If autECLSession.autECLPS.GetText(1,20,len(upcs(i))) <> upcs(i) Then exit sub End If autECLSession.autECLOIA.WaitForInputReady autECLSession.autECLPS.SendKeys "[enter]" autECLSession.autECLOIA.WaitForAppAvailable autECLSession.autECLOIA.WaitForInputReady If autECLSession.autECLPS.GetText(1,(20 + 13 - len(upcs(i))),len(upcs(i))) <> upcs(i) Then exit sub End If subPrint session autECLSession.autECLPS.Wait(4000) Next End Sub Sub subPrint(session) If session.autECLPS.GetText(1,2,10) = "Item entry" Then session.autECLOIA.WaitForAppAvailable session.autECLOIA.WaitForInputReady session.autECLPS.SendKeys "[enter]" session.autECLOIA.WaitForAppAvailable session.autECLOIA.WaitForInputReady If session.autECLPS.GetText(3,2,4) <> "PVA:" Then vendor = session.autECLPS.GetText(1,45,6) session.autECLOIA.WaitForInputReady session.autECLPS.SetCursorPos 1, 45 session.autECLPS.SendKeys "[erase eof]" session.autECLOIA.WaitForInputReady session.autECLPS.SendKeys "8888" session.autECLOIA.WaitForInputReady session.autECLPS.SendKeys "[enter]" session.autECLOIA.WaitForAppAvailable session.autECLPS.WaitForAttrib 3,6,"00","3c",3,10000 session.autECLPS.WaitForCursor 3,7,10000 session.autECLOIA.WaitForInputReady If session.autECLPS.GetText(3,2,4) <> "PVA:" Then exit sub End If End If If session.autECLPS.GetText(3,2,4) = "PVA:" Then session.autECLPS.SendKeys "[pf23]" session.autECLPS.WaitForAttrib 21,19,"00","3c",3,10000 session.autECLPS.WaitForCursor 21,20,10000 session.autECLOIA.WaitForAppAvailable If session.autECLPS.GetText(19,3,16) = "Price. . . . . ." Then session.autECLOIA.WaitForInputReady If session.autECLPS.GetText(7,20,13) = "0000000000000" Then session.autECLPS.SendKeys "[pf3]" Exit Sub End If session.autECLOIA.WaitForInputReady session.autECLPS.SendKeys "[up]" session.autECLOIA.WaitForInputReady session.autECLPS.SendKeys "[up]" session.autECLOIA.WaitForInputReady cPrice = Left(session.autECLPS.GetText(19,20,17) & Space(17), 17) session.autECLOIA.WaitForInputReady session.autECLPS.SendKeys "[pf3]" session.autECLOIA.WaitForAppAvailable session.autECLPS.WaitForAttrib 3,6,"00","3c",3,10000 session.autECLOIA.WaitForInputReady If session.autECLPS.GetText(1,2,10) = "Item entry" Then scr = "" For r = 1 To 24 If r = 9 Then row9 = session.autECLPS.GetText(9,1,80) row9 = Left(row9,42) & cPrice & Mid(row9,60) scr = scr & Left(row9,80) Else scr = scr & session.autECLPS.GetText(r,1,80) End If If r < 24 Then scr = scr & Chr(13) & Chr(10) Next Set fso = CreateObject("Scripting.FileSystemObject") Set ts = fso.CreateTextFile("C:\Users\lawine\Documents\jordan\zpl\print.txt", True) ts.Write scr ts.Close session.autECLOIA.WaitForInputReady session.autECLPS.SendKeys "[pf3]" If vendor <> "" Then session.autECLOIA.WaitForAppAvailable session.autECLPS.WaitForAttrib 1,19,"00","3c",3,10000 session.autECLPS.WaitForCursor 1,20,2000 session.autECLOIA.WaitForInputReady session.autECLPS.SendKeys "[tab]" session.autECLOIA.WaitForInputReady session.autECLPS.SendKeys vendor session.autECLOIA.WaitForInputReady session.autECLPS.SendKeys "[tab]" session.autECLOIA.WaitForInputReady End If If session.autECLPS.GetText(1,2,10) = "Item entry" Then Call CreateObject("Shell.Application").ShellExecute("C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe", "-WindowStyle hidden -noprofile -executionpolicy bypass -file C:\Users\lawine\Documents\jordan\zpl\formatZPL.ps1","","open",2) End If End If End If End If End If End Sub