Message de Johnny Rosenberg  date 2010-01-01 13:58 :
The first thing I did was to look in AndrewMacro.odt, the famous macro
document by Andrew Pitonyak. I found this example, and I actually also
found the same example in the OpenOffice.org BASIC help section, that
seems to be broken though (I added line numbers to it, so I can easier
refer to it later):
00. '?? This is broken!
01. Sub ExampleRandomAccess
02.   Dim iNumber As Integer, aFile As String
03.   Dim sText As Variant REM Must be a variant
04.   aFile = "c:\data1.txt"
05.   iNumber = Freefile
06.   Open aFile For Random As #iNumber Len=5
07.   Seek #iNumber,1 REM Position at beginning
08.   Put #iNumber,, "1234567890" REM Fill line with text
09.   Put #iNumber,, "ABCDEFGHIJ"
10.   Put #iNumber,, "abcdefghij"
11.   REM This is how the file looks now!
12.   REM 08 00 0A 00 31 32 33 34  35 36 37 38 39 30 08 00   ....1234567890..
13.   REM 0A 00 41 42 43 44 45 46  47 48 49 4A 08 00 0A 00   ..ABCDEFGHIJ....
14.   REM 61 62 63 64 65 66 67 68  69 6A 00 00 00 00 00 00   abcdefghij
15.   REM

Hi Johnny,
A Random access file has no real meaning for text.

It would be much simpler to write an ordinary text file with successive lines
using instruction Print, and later read the file line by line using instruction
Line Input. For random access, put the lines in an array of String.

Regards
  Bernard


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to