Jump to content

Recommended Posts

Posted (edited)

Hello, I needed your help with a code I wrote.
The problem is; based on the data read and the date and time of the file to be opened. There is a difference of 1 second (very rarely 2 seconds) between the data read and the file to be opened. Let me exemplify like this.
The problem "0010171588\07.08.2023_17.32.40.jpg" pops up. but sometimes the file name to be opened can be "0010171588\07.08.2023_17.32.41.jpg" due to the network write delay, then the file cannot be opened. (although very rarely it can be 010171588\07.08.2023_17.32.42.jpg)
 

GUICtrlCreateGroup("QUIT PHOTO", 455, 280, 330, 260)
GUICtrlSetFont(-1, 10, 800, 0, "Righteous")
$Tim02a = StringRegExpReplace($Read24, "\A(\d*):(\d*):(\d*)", "$1.$2.$3")
$Tim02b = $Read21 & "\" & $Read22 & "_" & $Tim02a & ".jpg"

If FileExists($Tim02b) Then
    $Pict02 = GUICtrlCreatePic($Tim02b, 460, 295, 320, 240)
    ConsoleWrite($Tim02b & @CR)
Else
    Local $Tim03a = StringRegExpReplace($Tim02a, "_(\d+)\.", "_" & IncrementSecond("$1") & ".")
    $Tim03b = $Read21 & "\" & $Read22 & "_" & $Tim03a & ".jpg"
    $Pict02 = GUICtrlCreatePic($Tim03b, 460, 295, 320, 240)
    ConsoleWrite($Tim03b & @CR)
EndIf

Func IncrementSecond($match)
    Return "_" & (Int($match) + 1) & "."
EndFunc

:ILA2:

Edited by mucitbey
Posted

To get help you really need to ask for help in a better way. We can't simulate anything with your code in this state neither to understand what is your actual issue.

Posted

How often are the files written? If it's greater than a few seconds, maybe build in a few seconds of leeway for the filenames, like +-2 sec?

Posted (edited)
24 minutes ago, rsn said:

How often are the files written? If it's greater than a few seconds, maybe build in a few seconds of leeway for the filenames, like +-2 sec?

     Data is not generated in an orderly fashion. The data is recorded in an ini file with date and time data, and when this process is completed, a jpg file taken with the webcam is recorded. However, when I want to match the ini file with the jpg data, I cannot match because of the difference in the file name between the read data and the data to be retrieved, since the jpg file is usually written with a 1-2 second delay, although not always. I hope I was able to explain the problem.

Edited by mucitbey
Posted

For me it's not clear at all. I got the part where you get some screen captures from your webcam and save them as jpg files and the name of each file contains date/time information. Where does this +- delay come from?

Posted (edited)
11 minutes ago, Andreik said:

For me it's not clear at all. I got the part where you get some screen captures from your webcam and save them as jpg files and the name of each file contains date/time information. Where does this +- delay come from?

When the record is entered, it first writes the data as Date (07.08.2023) and Time (17.32.40) in an ini file, and takes a picture of the document with a webcam after saving it (07.08.2023_17.32.41.jpg). When the webcam creates a file, it records with a delay of 1 second. therefore, while matching the image file with the data in the ini program (07.08.2023) and Clock (17.32.40) it tries to merge and open the jpg file. But it can't find the file because of the delay.

I also save the image with this udf.

Webcam UDF

Edited by mucitbey
Posted

Convert the date in .ini into a sortable format (y-m-d h:m:s) use _FileListToArray to list files then convert similarly dates in filenames into the same sortable format. Then it's easy to find a file dated within few seconds of the ini date.

Things would be much simpler if a standard (sortable) datetime stamp were used!

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Posted

Hello,
First of all, thank you all for your help and guidance. I solved the problem in a different way. I went back to the codes I wrote first, there was something I missed at first, when I fixed it, the problems were solved. Therefore, this procedure is no longer necessary. In short, my mistake was that I tried to write the ":" character in the filename. :thumbsup:

Posted (edited)
3 hours ago, mucitbey said:

I tried to write the ":" character in the filename

That creates an ADS (Alternate Data Stream) "under" the main filename (provided the file system of the device is NTFS). https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-fscc/e2b19412-a925-4360-b009-86e3b8a020c8

 

Edited by jchd

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...