PC SOFT

PROFESSIONAL NEWSGROUPS
WINDEVWEBDEV and WINDEV Mobile

Home → WINDEV 2024 → Strange behavior when adding data records
Strange behavior when adding data records
Started by Volker Gericke, Jan., 06 2024 10:29 AM - 3 replies
Posted on January, 06 2024 - 10:29 AM
Hello,

I am creating a photo database. The records are created automatically when the directories are read (basically a "dir /s" is performed). This works impressively fast and well.

In order to be able to run evaluations, there is a directory structure:
Drive:\photography\Topic\Series\Picture.jpg

"Drive:\photography\" is defined.
"Topic" can be "Cars", "Portrait", "Landscape", ... or whatever you like
"Series" can be "New York 5.11.2022", for example.
A typical directory could therefore be
"Drive:\photography\Landscape\New York 5.11.2022\Picture0001.jpg".

The program now reads in the files and directories.
sFileList is string
sFile is string

sFileList = fListFile("Drive:\photography\*.jpg")FOR EACH STRING sFile OF sFileList SEPARATED BY CR Pictures.Topic = ExtractString(sFile,3,"\",FromBeginning)
Pictures.Series = ExtractString(sFile,4,"\",FromBeginning) Pictures.Filename = ExtractString(sFile,5,"\",FromBeginning) Pictures.Picture = sFile IF Pictures..NewRecord THEN Pictures.Add()
END

Series.Topic = Pictures.Topic
Sets.Series = Pictures.Series
IF Series..NewRecord THEN
Series.Add()
END

Topic.Topic = Pictures.Topic
IF Topic..NewRecord THEN
Topic.Add()
END
END
Unfortunately, the Add() commands for "Series" and "Topic" persistently generate duplicate errors.

The database "Pictures" has a unique index via the fields "Topic + Series + Filename".

The "Series" database has a unique index on the "Topic + Series" fields.

The "Topic" database has a unique index via the "Topic" field.

How do I get rid of the duplicate errors?

Regards

Volker
Registered member
31 messages
Posted on January, 08 2024 - 3:39 PM
I have found ..NewRecord to be unreliable.
Use if not HReadSeekFirst (something,index) then
HAdd(e.g. Topic)
end

--
Garry
Posted on January, 08 2024 - 4:58 PM
Hi Garry,

I will try that. I also saw something about the unreliability of Newrecord. But that was 2018, and still newrecord is in the tutorials. Well, anyway. Thank you, I will check that out. 😊

Kind regards,

Volker
Posted on January, 20 2024 - 11:43 AM
Hi Garry and all,

HReadSeekFirst fires the same errors:

sGDirList is string
sGDir is string
sGDirList = fListDirectory("D:\Photographs\",frNotRecursive)

FOR EACH STRING sGDir OF sGDirList SEPARATED BY CR
Topics.Name = ExtractString(sGDir,3,"\",FromBeginning)
IF NOT HReadSeekFirst(Topics,Name,ExtractString(sGDir,3,"\",FromBeginning)) THEN
HAdd(Topics)
END
END

It seems not to be possible to implement a "CASE ERROR:"-procedure that does nothing more than silently jumping to the next entry in the list.

Kind regards,

Volker