| |

VerySource

 Forgot password?
 Register
Search
View: 3272|Reply: 11

After reading the file, I found that one byte is missing. What is going on?

[Copy link]

1

Threads

4

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-12-10 09:30:01
| Show all posts |Read mode
I customize as follows:
Type fle_2
  aa(23) As Integer
  bb(23) As Integer
  cc(23) As Integer
  dd(23) As Integer
. . . . .
. . . .
End Type
                         Note: 352 bytes above'''''''''''''''''''''
Type str_Message
  strMessage As String
End Type

Public FleThr As fle_2
Public FleThrO As str_Message


Then read the file:
    Open strfPaht For Binary As #1
         Get #1, 1, FleThr
         Get #1, 352, FleThrO
    Close #1


The problem is that the first bit of the data accessed in FleThrO.strMessage is gone and gone.


Excuse me, why is this?

Thanks in advance
Reply

Use magic Report

1

Threads

11

Posts

8.00

Credits

Newbie

Rank: 1

Credits
8.00

 China

Post time: 2020-12-10 09:45:01
| Show all posts
Get #1, 1, FleThr
Change to
Get #1, 0, FleThr
Reply

Use magic Report

1

Threads

4

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

 Author| Post time: 2020-12-10 11:00:02
| Show all posts
upstairs:
   Same effect as before
Reply

Use magic Report

1

Threads

11

Posts

8.00

Credits

Newbie

Rank: 1

Credits
8.00

 China

Post time: 2020-12-10 11:15:02
| Show all posts
What's your first byte
Is it empty?
Reply

Use magic Report

1

Threads

4

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

 Author| Post time: 2020-12-10 11:30:01
| Show all posts
The first byte in FleThrO.strMessage converted into a character type is "M" and not empty
Reply

Use magic Report

0

Threads

8

Posts

7.00

Credits

Newbie

Rank: 1

Credits
7.00

 China

Post time: 2020-12-10 11:45:01
| Show all posts
Open strfPaht For Binary As #1
         Get #1, 1, FleThr''Since 352 bytes have been read, then
         Get #1, 352, FleThrO''Is it supposed to start from 353?
    Close #1
Reply

Use magic Report

1

Threads

4

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

 Author| Post time: 2020-12-10 12:00:01
| Show all posts
upstairs:
   At the beginning, I also started reading from 353, but after that, it was 2 bytes less.
   Starting from 352, there is 1 byte less.
   Starting from 351, there is nothing
Reply

Use magic Report

0

Threads

8

Posts

7.00

Credits

Newbie

Rank: 1

Credits
7.00

 China

Post time: 2020-12-10 12:15:02
| Show all posts
You don't have to try anything at all. If this is a problem, you may have made an error while writing the data.

Open strfPaht For Binary As #1
         Get #1,, FleThr''Since 352 bytes have been read, then
         Get #1,, FleThrO''Is it supposed to start from 353?
    Close #1
Reply

Use magic Report

0

Threads

9

Posts

10.00

Credits

Newbie

Rank: 1

Credits
10.00

 China

Post time: 2020-12-10 12:30:01
| Show all posts
Type str_Message
  strMessage As String
End Type
It should be related to this definition. If strMessage is a fixed-length string, this problem should not occur
Using variable length strings, it is possible to interpret the first character as a length descriptor, so the first character will be lost
Reply

Use magic Report

0

Threads

18

Posts

12.00

Credits

Newbie

Rank: 1

Credits
12.00

 China

Post time: 2020-12-10 12:45:01
| Show all posts
Type str_Message
  strMessage() As byte
End Type

Public FleThr As fle_2
Public FleThrO As str_Message


Then read the file:
    Open strfPaht For Binary As #1
         Get #1, 1, FleThr
         Get #1, 1+len(FleThr), FleThrO.strMessage
    Close #1
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list