home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / lang / pascal / 8429 < prev    next >
Encoding:
Internet Message Format  |  1993-01-22  |  1.5 KB

  1. Path: sparky!uunet!mcsun!sunic!aun.uninett.no!nuug!falcon!lfosdal
  2. From: lfosdal@falcon.no (Lars Fosdal)
  3. Newsgroups: comp.lang.pascal
  4. Subject: Streams mixed with Files - FileMode problems
  5. Message-ID: <mw2RXB4w165w@falcon.no>
  6. Date: Fri, 22 Jan 93 14:01:09 MET
  7. Organization: Falcon Information Services AS, Oslo, Norway
  8. Lines: 42
  9.  
  10. Problem: Streams mixed with files in BP7.0 (under Windows).
  11.  
  12. The app uses several external files (data/indexes, etc.), of which some 
  13. are binary files, and others are streams.
  14.  
  15. Scenario:
  16. My app first stores some data on a stream (TBufStream, mode stCreate).
  17. If I then try to open another file with assign/reset/blockread, using
  18. filemode ReadOnly + DenyNone, I get a "can't open for output" error 
  19. message.  If I retry, it works (!), ie the file is opened for read.
  20.  
  21. Pseudocode:
  22.  
  23. VAR
  24.   Stream : TBufStream;
  25.   Data   : MyData;
  26.   fil    : File;
  27. BEGIN
  28.   Stream.Init(stCreate);
  29.   Data.Store(Stream);
  30.   Stream.Done;
  31.  
  32.   oldmode:=filemode;
  33.   filemode:=ReadOnly + denyNone;     {$40}
  34. Retry:  
  35.  Assign(File
  36.   Reset(Fil,1);      -> Gives File not open for output (RTE:105)
  37.                       the first time
  38.   IF (IOresult<>0)
  39.   THEN Retry
  40.   .
  41.   :
  42.   filemode:=oldmode;
  43.     
  44. Clues, anyone ?
  45.  
  46. Lars F.
  47. --
  48. / Mr.Lars Fosdal, Software Developer, Financial Analysis Systems  /
  49. / Falcon Information Services AS, Stranden 1, N-0250 Oslo, Norway /
  50. / E-mail:lfosdal@falcon.no  Tel:(47-2) 831310  Fax:(47-2) 831290  /
  51. -- All opinions are personal and does not reflect company policy --
  52.