Issue 61277 - Basic open file with random access erases all data
Summary: Basic open file with random access erases all data
Status: CLOSED FIXED
Alias: None
Product: App Dev
Classification: Unclassified
Component: scripting (show other issues)
Version: 3.3.0 or older (OOo)
Hardware: PC All
: P3 Trivial
Target Milestone: 4.2.0
Assignee: ab
QA Contact:
URL:
Keywords: data_loss
Depends on:
Blocks:
 
Reported: 2006-01-28 22:38 UTC by Regina Henschel
Modified: 2017-05-20 09:31 UTC (History)
2 users (show)

See Also:
Issue Type: DEFECT
Latest Confirmation in: 4.2.0-dev
Developer Difficulty: ---


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Regina Henschel 2006-01-28 22:38:48 UTC
I use German OOo2.0.1 on German WinXp.

Generate a dummy “daten.txt†file with about 40 times character x with an editor.

Try the following macro on this file

Sub Main
Dim iNumber As Integer
Dim aFile As String
aFile = "c:\daten.txt" REM or where it is on your machine
msgBox "size before opening=" & FileLen(aFile)
iNumber = Freefile
Open aFile For Random As #iNumber len=8
msgBox "size after opening=" & lof(iNumber)
close #iNumber
msgBox "size after closing=" & FileLen(aFile)
End Sub

Notice, that opening the file has erased all data.
Comment 1 thorsten.martens 2006-01-30 09:33:03 UTC
TM->JSK: Please have a look, thanks !
Comment 2 joerg.skottke 2006-05-02 12:31:53 UTC
dataloss makes p2, target 2.0.4, too late for 2.0.3
Comment 3 ab 2006-05-03 13:38:49 UTC
ab -> jsk: Please avoid exaggerated priorities. This is no P2 in the sense of the 
guidelines in  http://www.openoffice.org/scdocs/ddIssues_EnterModify.html#priority
that says "P2 marks severe problems which affect a significant number of customers".
How many customers could have been affected by a problem that has been undetected 
for years (bug still exists in SO 7.0!)? And in this special case the problem will 
be found by the macro programmer when testing his Basic macro before the macro is 
really used. Anyway, if the fix is easy I have no problem to do it for 2.0.4. -> P3
Comment 4 ab 2006-07-18 08:56:35 UTC
-> 2.x due to code freeze and limited resources
Comment 5 Mathias_Bauer 2007-12-04 14:57:36 UTC
basic and scripting issues now should be assigned to component "scripting"
Comment 6 Martin Hollmichel 2007-12-07 12:13:39 UTC
set target to 3.x according to http://wiki.services.openoffice.org/wiki/Target_3x
Comment 7 damjan 2015-11-03 19:11:41 UTC
Fixed by commit 1712377:

#i61277# Basic open file with random access erases all data.
StarBasic tries to emulate truncation of files opened for writing
by deleting them before opening them (if they exist). However there
are exclusion to the truncation behaviour when the file is opened
in append mode or is a binary file. Another exclusion - that was
missing with disasterous consequences - is that the file should
not be truncated when opened in random access mode.