Getting a single char, Putting a single char. 
Author Message
 Getting a single char, Putting a single char.

Hi,
        I am new at VB but I wanted to write a program that extracted
e-mail addresses out of a text file.  I tried to 'get' a single character
out of a text file and put a single character into another text file.  I
used random files and made each character a record but I had problems.  
To use sequential there must be a delimiter.  If anybody can help, I sure
would appreciate it.  Is there a library with these functions?  How do I
use this library of functions with my program?  How can I feel more
secure about my inner child?  Just kidding on that last one.  Thanx!
                                                Mark Infantino
                                                Grad. Assistant
                                                Wheeling Jesuit University



Sat, 05 Jun 1999 03:00:00 GMT  
 Getting a single char, Putting a single char.

Quote:

> Hi,
>         I am new at VB but I wanted to write a program that extracted
> e-mail addresses out of a text file.  I tried to 'get' a single character
> out of a text file and put a single character into another text file.  I
> used random files and made each character a record but I had problems.
> To use sequential there must be a delimiter.  If anybody can help, I sure
> would appreciate it.  Is there a library with these functions?  How do I
> use this library of functions with my program?  How can I feel more
> secure about my inner child?  Just kidding on that last one.  Thanx!
> ...

Hint: Scanning a string for characters is just as easy as scanning a file.
      They're both effectively byte streams. Read a chunk of stuff from your
      file, however you choose to delimit or otherwise limit it, and ...

--

Vox (0|+44)1642 216 200  }*|*{  *o|o*  }o|o{ Zetland Buildings, Exchange Square
Fax (0|+44)1642 216 201    o      o      *   Middlesbrough, Cleveland.  TS1 1DE
--------- "Estimate how many people in the UK can make this estimate" ---------



Sun, 06 Jun 1999 03:00:00 GMT  
 Getting a single char, Putting a single char.

Quote:

>Hi,
>    I am new at VB but I wanted to write a program that extracted
>e-mail addresses out of a text file.  I tried to 'get' a single character
>out of a text file and put a single character into another text file.  I
>used random files and made each character a record but I had problems.  
>To use sequential there must be a delimiter.  If anybody can help, I sure
>would appreciate it.  Is there a library with these functions?  How do I
>use this library of functions with my program?  How can I feel more
>secure about my inner child?  Just kidding on that last one.  Thanx!

Here is an untested example:

Dim Temp as String * 1
dim i as long

Temp = "*"

open "InFile.Dat" for random as #1
open "OutFile.Dat" for random as #2
  for i = 1 to lof(1)
    get #1,,Temp
    put #2,,Temp
  next
close
end



Sun, 06 Jun 1999 03:00:00 GMT  
 Getting a single char, Putting a single char.

In VB, I don't think you want to do it this way -- but I could be wrong.
I just think it would be faster to read full lines of text into a buffer
and use Mid$ to extract individual characters.  Maybe you could create a
function that would keep track of an index ("pointer") into the buffer
(use a Static integer), input new lines (use a "Line Input #" command)
when necessary, etc.  You could test for end-of-line by comparing the
index against the length of the text in the buffer (use "Len" function).



: >  I am new at VB but I wanted to write a program that extracted
: >e-mail addresses out of a text file.  I tried to 'get' a single character
: >out of a text file and put a single character into another text file.  I
: >used random files and made each character a record but I had problems.  
: >To use sequential there must be a delimiter.

: Dim Temp as String * 1
: dim i as long

: Temp = "*"

: open "InFile.Dat" for random as #1
: open "OutFile.Dat" for random as #2
:   for i = 1 to lof(1)
:     get #1,,Temp
:     put #2,,Temp
:   next
: close
: end



Sun, 06 Jun 1999 03:00:00 GMT  
 Getting a single char, Putting a single char.

Quote:

>Hi,
>    I am new at VB but I wanted to write a program that extracted
>e-mail addresses out of a text file.  I tried to 'get' a single character
>out of a text file and put a single character into another text file.  I
>used random files and made each character a record but I had problems.  

"Putting" a single char is easy. Just use

        print #handle, "A";

Don't forget the semicolon!

For "getting" one char, use

        a$ = input$(1,#handle)

See help.

One snag: "The Input[$] function can only be used with files opened in
Input or Binary mode.". No Random mode.

Gent (Ghent, Gand), Belgium,
Europe,
3rd planet from the sun.



Mon, 07 Jun 1999 03:00:00 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Putting a single char in a text box.

2. Replacing single Chars

3. How to send a single Char to the LPT-port

4. ASCII Chars -> large chars

5. char after each 2 chars in a string.

6. Reading a text file char by char.

7. Char by Char file input?

8. REPOST: Want mask chars but not prompt chars in MaskEdBox (from Aug 22)

9. Want mask chars but not prompt chars in MaskEdBox

10. problem with char field and special ascii char

11. Help required for Unicode Chars(greek chars)

12. Search Char By Char Like MS Index Searches

 

 
Powered by phpBB® Forum Software