[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

writing into buffer

Posted on 1998-08-11
1
Medium Priority
?
292 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 9

Accepted Solution

by:
cymbolic earned 40 total points
ID: 1468556
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…
Suggested Courses

650 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