PC SOFT

FORUMS PROFESSIONNELS
WINDEVWEBDEV et WINDEV Mobile

Accueil → WINDEV 2024 → Delete all records in file
Delete all records in file
Débuté par John Marrone, 19 mai 2005 18:16 - 4 réponses
Posté le 19 mai 2005 - 18:16
Hi All
I just want to delete all the records in a file. Here is my code.
IF HNbRec(PPLines) > 0 AND NOT HOut(PPLines) THEN
FOR i = 1 TO HNbRec(PPLines)
HDelete(PPLines, hCurrentRecNum )
END
END
It fails the if statment. HOut is true so it must be something to do with the HNbRec part. Anyone know a quicker way to delete all records in a HF.
Regards
John
Posté le 20 mai 2005 - 22:20
HCreate(PPLines) ? See help...

Christian Potvin
Beaulieu Canada

Hi All
I just want to delete all the records in a file. Here is my code.
IF HNbRec(PPLines) > 0 AND NOT HOut(PPLines) THEN
FOR i = 1 TO HNbRec(PPLines)
HDelete(PPLines, hCurrentRecNum )
END
END
It fails the if statment. HOut is true so it must be something to do with the HNbRec part. Anyone know a quicker way to delete all records in a HF.
Regards
John
Posté le 21 mai 2005 - 19:27
Dans un message John Marrone disait :

Hi All
I just want to delete all the records in a file. Here is my code.
IF HNbRec(PPLines) > 0 AND NOT HOut(PPLines) THEN
FOR i = 1 TO HNbRec(PPLines)
HDelete(PPLines, hCurrentRecNum )
END
END
It fails the if statment. HOut is true so it must be something to do
with the HNbRec part. Anyone know a quicker way to delete all records
in a HF. Regards


May be it is normal as you do not position the file to the next record to be
deleted,

may be better to do
1) hferme( PPlines) ; Hcreate (pplines) // note that this will reset the
Automatic id if any ;

2) or to keep the autoid continuing its own way:

either

2.1
pour pplines sur idxxx
hdelete(pplines)
fin

or

2.2 or a " requete "
delete * from pplines


Hope this help you

(excuse the mix of french + english...)
--
Michel HERRSCHER CONSULTANT
Président WINDASSO - Association des utilisateurs WxxDEV(c)
Tel : +33450870912 Fax:+33450871741
http://www.windasso.org
Posté le 01 juin 2005 - 14:08
Theoretically HCreation does it. BUT in a mylti-user environment it doesn't work the way you think.

I do the delete on active records. I find this works well -

My file here is called Sage8 and the index I am using is S8A.

HReadFirst(Sage8,S8A)
LOOP
IF HOut(Sage8) THEN BREAK
IF HState(Sage8)= hStateActive THEN
HDelete(Sage8,hCurrentRecNum)
END
HReadNext(Sage8,S8A)
END

(Some of your records you are reading are probably deleted and the Hout is bombing it out). I also tend to write some code in to check the file is not in use, after all it should really be closed and not in use.

Then do this -

Myvar is boolean
Mode is int
Directory is string= datadirectory
WindowHandle is int = Handle()
Mode = hNdxDelete
LogicalFileName is string ="SAGE8"
PhysicalFileName is string="SAGE8"
Myvar= HIndex(LogicalFileName, PhysicalFileName,Directory, Mode, WindowHandle)
IF Myvar = False THEN
Error("Hyper File error: " + HErrorInfo())
END

This gets rid of the space and checks the file at the same time.

Norman
ZiPZAP Computers Limited, Lincoln UK.
Posté le 01 juin 2005 - 19:23
may be faster :

create a request containing something like :

delete * from Sage8

--
Michel HERRSCHER CONSULTANT
Président WINDASSO - Association des utilisateurs WxxDEV(c)
Tel : +33450870912 Fax:+33450871741
http://www.windasso.org

Dans un message Norman disait :

Theoretically HCreation does it. BUT in a mylti-user environment it
doesn't work the way you think.

I do the delete on active records. I find this works well -

My file here is called Sage8 and the index I am using is S8A.

HReadFirst(Sage8,S8A)
LOOP
IF HOut(Sage8) THEN BREAK
IF HState(Sage8)= hStateActive THEN
HDelete(Sage8,hCurrentRecNum)
END
HReadNext(Sage8,S8A)
END

(Some of your records you are reading are probably deleted and the
Hout is bombing it out). I also tend to write some code in to check
the file is not in use, after all it should really be closed and not
in use.

Then do this -

Myvar is boolean
Mode is int
Directory is string= datadirectory
WindowHandle is int = Handle()
Mode = hNdxDelete
LogicalFileName is string ="SAGE8"
PhysicalFileName is string="SAGE8"
Myvar= HIndex(LogicalFileName, PhysicalFileName,Directory, Mode,
WindowHandle) IF Myvar = False THEN
Error("Hyper File error: " + HErrorInfo())
END

This gets rid of the space and checks the file at the same time.

Norman
ZiPZAP Computers Limited, Lincoln UK.