You are not logged in.

Blue Blazes

Beginner

  • "Blue Blazes" started this thread

Posts: 15

Date of registration: Aug 14th 2009

  • Send private message

1

Tuesday, August 18th 2009, 6:52pm

Sequential file example

Greetings,
I have learned that disk file operations on Jabaco are different than VB6. So I have studied some examples on the Community. I have tried a number of different code examples. The one below is intended to be a sequential write, then read, but doesn't work as intended. What is wrong with this code?


Public Sub cmdTest_Click()

Dim myFile As VBFileHandler
' write
myFile = Open("C:\About\Test\Test.txt",Output)
Call Write(myFile, "1")
Call Write(myFile, "2")
Call Write(myFile, "3")
Call Close ()
'read
myFile = Open("C:\About\Test\Test.txt", Input)
MsgBox readline(myFile) ' displays "3" ?
MsgBox readline(myFile) ' displays nothing ?
MsgBox readline(myFile) ' displays nothing ?
Call Close()

End Sub

One final question: Is it possible that a single Write or Read can process more than one data variable, for example? write ... "1", "2", "3"

birosys

Trainee

  • "birosys" is male

Posts: 48

Date of registration: Feb 9th 2009

Location: Mladenovac, Serbia

Occupation: Programming

Hobbies: Programming

  • Send private message

2

Tuesday, August 18th 2009, 10:44pm

Hi Blue Blazes

Here is answer

Jabaco Source

1
2
3
4
5
6
7
8
9
10
11
Dim fh As VBFileHandler 
   fh=Open ("c:\test",append )
   fh.appendString ("1" & Chr(13))
   fh.appendString ("2" & Chr(13))
   fh.appendString ("3")
   fh.close 
   fh=Open ("c:\test",Input)
   MsgBox fh.readLine 
   MsgBox fh.readLine 
   MsgBox fh.readLine 
   fh.close


All read and write operations is done via stream. Stream don't know anything about any special character.
So, you must add it manually.

Milan

klctal

Trainee

  • "klctal" is male

Posts: 70

Date of registration: Jul 13th 2009

Location: Shanghai

Hobbies: Developing software

  • Send private message

3

Wednesday, September 9th 2009, 12:14pm

Chr(13)

The Chr(13) Function doesn't work that good in Jabaco. It doesn't "enter". Use Chr(10) instead.
:D

amitmarkel

Beginner

  • "amitmarkel" is male

Posts: 17

Date of registration: Jul 17th 2009

  • Send private message

4

Thursday, September 10th 2009, 12:20am

Alternatively VBCr or VBCrlf can be used.

Rate this thread
WoltLab Burning Board