[Gambas-user] Problem with .Remove (1.0.14)
Eilert
eilert-sprachen at ...221...
Tue Mar 7 09:34:09 CET 2006
Hi folks,
This is part of my current project. It's supposed to find a line in a
file and kill it (by removing the line from the array and saving the
file again).
PRIVATE SUB DateiTerminLoeschen(monat AS String, jahr AS String,
position AS Integer)
DIM pfad AS String
DIM datei AS String
DIM dtnr AS File
DIM t$ AS String
DIM i AS Integer
DIM termine AS NEW String[]
IF String.Len(monat) = 1 THEN monat = "0" & monat
pfad = system.Home &/ ".kalender/termine" &/ jahr
datei = monat & "-" & jahr & ".termine"
IF NOT Exist(pfad &/ datei) THEN
message.Error(pfad &/ datei & " existiert nicht!", "Abbruch")
RETURN
END IF
OPEN pfad &/ datei FOR READ AS #dtnr
WHILE NOT Eof(dtnr)
LINE INPUT #dtnr, t$
termine.Add(t$)
WEND
CLOSE #dtnr
IF termine.Count > 1 THEN
termine.Remove(position)
OPEN pfad &/ datei FOR WRITE AS #dtnr
FOR i = 0 TO termine.Count - 1
PRINT #dtnr, termine[i]
NEXT
CLOSE #dtnr
ELSE
KILL pfad &/ datei
END IF
END
If it works, it leaves a line of garbage at the end of the file, i. e.
the last line is doubled but not completely.
This is an example:
01 1615 45 1 Fr. Nguyen, Werlte, T06 (kf) (t.best.) (gek. +
angem.)
06 1530 45 1 Fr. Kurzeja, Salzbergen, T06+Übs (p+z-t04
+frd+t-t) (w.k.) (gek. + angem.)
06 1615 45 0 Fr. Hildebrandt, Ochtrup, T06 (m) (n.gek.)
07 1530 45 0 Fr. Bensmann, Hagen, T06+Übs (z)
07 1615 45 0 H. Herden, Steinhagen, T06+Übs (kf)
07 1700 45 1 Fr. Gassmann, Hüllhorst, T06"+Übs" (kf/t) (t.best.)
09 1530 45 0 Fr. Claas, Bissendorf, T06(+Übs) (z)
09 1615 45 0 Fr. Sattelmaier, OS, T06 (kf)
09 1700 45 0 Fr. Faseli, Oldenburg, T06(+Übs) (z)
13 1530 45 0 Fr. Müller, OS, T06(+Übs) (z)
13 1615 45 0 Fr. Bumbic, Marl, T06(+Übs) (z)
13 1700 45 1 Fr. Maier, Uplengen, T06(z) (t.v.v.6.)
14 1615 45 0 H. Genzel, Marl, T06(+Übs) (z)
14 1700 45 1 Fr. Sposito, Hövelhof, T06 (z-t) (w.k.)
15 1615 45 0 Fr. Szymczak, Rothenfelde, T06 (kf)
15 1700 45 0 H. Taskin, Emsdetten, T06(+Übs) (m)
16 1615 45 0 Fr. Kalkmann, Langen, T06+Übs (kf)
16 1700 45 1 Fr. Aulfes, Bramsche, T06+Übs (gs-t) (w.k.)
(t.v.v.27.2.)
20 1700 45 1 Fr. Karle, Oelde, T06+Übs (z-t) (w.k.) (t.v.v.1.)
21 1530 45 1 Fr. Tewes, OS, T06 (frd-t) (w.k.)
21 1700 45 1 Fr. Behrla, Rheine, T06(+Übs) (lz-t) (w.k.)
22 1700 45 1 Fr. Schulte, Lemgo, T06+Übs (t) (w.k.)
23 1700 45 1 Fr. Valchizan, Bohmte, T06 (frd-t) (w.k.)
27 1700 45 1 Fr. Oldiges, Esterwegen, T06(+Übs) (z) (t.v.v.8.)
diges, Esterwegen, T06(+Übs) (z) (t.v.v.8.)
Do you have any explanation for this behaviour?
Thanks for your help!
Rolf
More information about the User
mailing list