Solved

writing into buffer

Posted on 1998-08-11
1
275 Views
Last Modified: 2010-04-30
I want to read a file in binary mode byte by byte using get and later I want to write the entire file into a buffer so that I can fill the content of the buffer to a variable which I can make use to transfer the file through some protocol.

Briefly I want to read the file and write the content using put to a buffer instead of writing to a disk file.

Can anybody help me out with some sample code.
0
Comment
Question by:lesa
1 Comment
 
LVL 9

Accepted Solution

by:
cymbolic earned 10 total points
Comment Utility
Basic binary file i/o to read a file would be:
dim x$, l&,y$
open "SomeFileName" for binary as #1
x$=space$(1)  'set input buffer
l&=lof(1)   'get length of file in l&
do
 get #1,,x$   'get one byte
 l&=l&-1
 if <some condition you check for> then
   y$=y$+x$  'make big buffer
 endif
loop until <some condition you need> or l&=0
close #1

Of course if you know how much you need ahead of time, just set x$ to be space$(??) and one get will bring it all in.  If the file is small, you can set x$ to be space$(lof(1)) and read it all in in one big gulp.   Then you can interate through the input buffer x$ and check each character using either the asc or mid$ functions to check for values, then truncate x$ where ever you desire.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now