help with read 
Author Message
 help with read

This is a multi-part message in MIME format.
--------------0FFDB3EBD22E5E3B76575493
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

    I have a problem. I am making a program that will read whatever you
type in and then save it to a file. I use read(char) to input to it but
I have a problem that it will only let me type in about 200 char's and
then stop and the computer starts beeping, untill you hit enter. I have
attached my program so if you could run it and then you will see that
you can only type in about 200 char's. Please E-Mail me for more
information or if you have a solution. It was written in Turbo Pascal 7.

Thanks
Sheldon

--------------0FFDB3EBD22E5E3B76575493
Content-Type: text/plain; charset=us-ascii; name="Notes.pas"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline; filename="Notes.pas"

var

file1:text;
x,q,s:integer;
ch,k:char;
sttr:string;
sttrme:array[1..4000] of char;

begin
  assign(file1,'c:\test.sbm');
  rewrite(file1);
  writeln('Press ^ when done');
  writeln('The ^ is shift 6 on the keyboard');
  writeln('Please enter you notes now and press ^ then enter when done');
  x:=0;
  ch:=' ';
  x:=0;
  q:=9;
  s:=0;
    while (q = 9) do
     begin
      x:=x+1;
      read(ch);
      sttrme[x]:=' ';
      sttrme[x]:=ch;
      if ch  = '^' then
         q:=8;
      if x = 80 then
        begin
        writeln(file1,sttrme[x]);
        x:=0;
        end
      else
        write(file1,sttrme[x]);
     end;
     readln;
     close(file1);
end.

--------------0FFDB3EBD22E5E3B76575493--



Wed, 18 Jun 1902 08:00:00 GMT  
 help with read

Quote:

>     I have a problem. I am making a program that will read whatever
/snip/
> Sheldon

/snip/

Here's my whack at it:

Program Notes;
Var F:Text;
Var Ch:Char;
Begin
   Assign(F,'C:\test.sbm');
   ReWrite(F);
   WriteLn('Please enter your notes. Press ^ when you are done.');
   Counter:=0;
   Repeat
        Ch:=ReadKey;
        If (Ch<>'^') And (Ch<>#0) Then Write(F,Ch);
   Until Ch='^';
   Close(F);
End.

What was the "(x+1) until x=80" for? Newlines? It seemed to only write
the same character.

--
AIBrain Home Page -"Artificially Intelligent Brain"
http://www.geocities.com/CapeCanaveral/Lab/7677/index.html




Wed, 18 Jun 1902 08:00:00 GMT  
 help with read

What I would recommend is:

VAR
    CH : CHAR;
    TEXT : STRING[255];

begin
TEXT:='';
WHILE CH<>#27 DO        {IF ESCAPE KEY IS PRESSED THEN BUST OUT OF THE
LOOP}
    BEGIN;
        CH:=READKEY;        {READ ONE CHARACTER FROM THE KEYBOARD
BUFFER}
        TEXT:=TEXT+CH;    {DEPOSIT THE CHARACTER INTO THE TEXT
LINE(LIMITED TO 255)}
{IF TEXT EQUAL 255 CHARACTERS OR CH=#13(ENTER) THEN WRITE TEXT TO A
FILE}
        IF (LENGTH(TEXT)=255) OR (CH=#13)THEN
        BEGIN;
            *-**CARRY OUT ANY FILE FUNCTIONS HERE**-*
            TEXT:='';
        END;
    END;

Hope this helps!

Good luck.

Chris

Quote:

>     I have a problem. I am making a program that will read whatever
> you
> type in and then save it to a file. I use read(char) to input to it
> but
> I have a problem that it will only let me type in about 200 char's and

> then stop and the computer starts beeping, untill you hit enter. I
> have
> attached my program so if you could run it and then you will see that
> you can only type in about 200 char's. Please E-Mail me for more
> information or if you have a solution. It was written in Turbo Pascal
> 7.

> Thanks
> Sheldon

> -------------------------------------------------------------------------------------------------------------

> var

> file1:text;
> x,q,s:integer;
> ch,k:char;
> sttr:string;
> sttrme:array[1..4000] of char;

> begin
>   assign(file1,'c:\test.sbm');
>   rewrite(file1);
>   writeln('Press ^ when done');
>   writeln('The ^ is shift 6 on the keyboard');
>   writeln('Please enter you notes now and press ^ then enter when
> done');
>   x:=0;
>   ch:=' ';
>   x:=0;
>   q:=9;
>   s:=0;
>     while (q = 9) do
>      begin
>       x:=x+1;
>       read(ch);
>       sttrme[x]:=' ';
>       sttrme[x]:=ch;
>       if ch  = '^' then
>          q:=8;
>       if x = 80 then
>         begin
>         writeln(file1,sttrme[x]);
>         x:=0;
>         end
>       else
>         write(file1,sttrme[x]);
>      end;
>      readln;
>      close(file1);
> end.



Wed, 18 Jun 1902 08:00:00 GMT  
 help with read

This is a quick example, use the readkey function and possibly
save the information into an array before doing one huge save
to a external file.  This means you can alter the text line
or search it etc before saving it to a file....#

================================

Program QuickExample;

Uses Crt,Dos;

Type

      TextArray = Array[1..64000] of Char;

Var

      TextLine : TextArray;
      Count    : LongInt;

Procedure GetImputFromUser;
Var
    Ch : Char;

Begin
  Count := 0;
  Repeat
    Inc(Count);
    TextLine[Count]:=ReadKey;
    Write(TextLine[Count]);
  Until (Count=64000) or (Ch=#27);
End;

Procedure WriteToFile;
Var
    TextFile : File;

Begin
  {$I-}
   Assign( TextFile, 'SomeFileName.AAA' );
   Rewrite( TextFile, 1 );
  {$I+}
   if IOResult <> 0 then Halt(1);
   BlockWrite( TextFile, TextLine, SizeOf(TextLine) );
   Close( TextFile );
End;  

Thanks, Jim.



Wed, 18 Jun 1902 08:00:00 GMT  
 help with read

Newsgroup:comp.lang.pascal,comp.lang.pascal.misc,comp.lang.pascal.borland
Subject: help with read


Date: Sun, 05 Oct 1997 14:41:05 -0400 post the followings:

Quote:

>     I have a problem. I am making a program that will read whatever you
> type in and then save it to a file. I use read(char) to input to it but
> I have a problem that it will only let me type in about 200 char's and
> then stop and the computer starts beeping, untill you hit enter. I have
> attached my program so if you could run it and then you will see that
> you can only type in about 200 char's. Please E-Mail me for more
> information or if you have a solution. It was written in Turbo Pascal 7.

read(char) would first store whatever you hit the keyboard to a buffer
until you hit enter, like this:

         step:    START     1       2       3       4
         input:            'a'     'b'     'c'    'enter'
         buffer: <empty>   'a'     'ab'    'abc'  <empty>
         read(): <pause> <pause> <pause> <pause> <process>

however, in your case, the keyboard buffer has a limit around 200
chars depending on the BIOS of your PC.  That's why your program
cannot accept more than 200 chars without a hit of enter.

you should try readkey ( must use unit CRT )

Quote:
>   ..                                    uses CRT;
>   ch:=' ';                              ..
>     while (q = 9) do                    while ch <> '^' do
>      begin                              begin
>       ..                                  ..
>       read(ch);                           ch := readkey; write(ch);
>       ..                                  ..
>       ..                                  ..
>      end;                               end;
>   ..                                    ..

e e e e e e e e e e e e e e e e e e e e                              

e URL:   http://w6.dj.net.tw/~tw-life e                              
e e e e e e e e e e e e e e e e e e e e                              


Wed, 18 Jun 1902 08:00:00 GMT  
 help with read


Quote:
>What I would recommend is:

[Snip]

Do you usually program with caps pressed? I'm just giving friendly
advice here.. Unless it is a asm statement, you should get used to
programming without capitalized words.

Quote:
>Chris



Wed, 18 Jun 1902 08:00:00 GMT  
 help with read

Quote:


> As long as we are on this topic, the other main peeve is people who use
> "_" everywhere. Sometimes, they get so carried away that I wonder if they
> sign their names with it.

I use "_" in my programming because it is one of the few characters
which TP allows in variables and procedures; improves legibility.

--
AIBrain Home Page -"Artificially Intelligent Brain"
http://www.geocities.com/CapeCanaveral/Lab/7677/index.html

"Warning, keyboard not found. Press ENTER to continue."

I may or may not have written what I meant or did not mean.
What I meant or did not mean might or might not have been what
I was or wasn't thinking at that moment.



Wed, 18 Jun 1902 08:00:00 GMT  
 help with read

Quote:




> >>What I would recommend is:
> >[Snip]
> >Do you usually program with caps pressed? I'm just giving friendly
> >advice here.. Unless it is a asm statement, you should get used to
> >programming without capitalized words.
> Even with asm there is no need to use caps. CAPS SUCK. One knows a
> BASIC programmer for his use of CAPS.
> OSMO :-)

or fortran.

I agree completely - caps really throw you off when you are trying to
read code.

There is no need to use caps, especially for Pascal reserved words. If
someone doesn't get to know them, they might run into trouble picking
names for their routines and variables.

The Borland Help TSR is loaded on my computer at all times. If I have any
doubt when naming something, I just put the cursor on it and press
Ctrl-Pad5 (the hotkey is reassigned to something nobody else uses.)

If the main Help Menu pops up, I know I'm safe.

If something else comes up, I realize I have something more to learn
about Pascal.

Except if it's OOP {*filter*}- I rename that stuff with relish :)

Best Regards,

Mike
CEO, Analog & Digital Design
Automated Production Test
  http://www.*-*-*.com/ ~add/home.htm

Hosting Jonathan Ramsey's Pascal TCP/IP for DOS:
  http://www.*-*-*.com/ ~add/zips/tcp.htm



Wed, 18 Jun 1902 08:00:00 GMT  
 help with read

Quote:

> > I use "_" in my programming because it is one of the few characters
> > which TP allows in variables and procedures; improves legibility.
> This wastes space and contributes nothing to legibility. Instead of
> "One_More_Time", what's wrong with just "OneMoreTime"?

> However vague, there is a slight confusion between name separators using
> "_" and record separators using "."

> For example, One.More.Time has significant meaning. One_More_Time just
> throws you off and adds to the possiblity of confusion and error.

> Ugh!

  Also, when you looking at your code in a DOS editor, "_"
  blends in with characters in the same column in the line below
  it. It disappears, which really adds to the confusion. Instead of
  improving legibility, it destroys it.

Best Regards,

Mike
CEO, Analog & Digital Design
Automated Production Test
  http://www.csolve.net/~add/home.htm

Hosting Jonathan Ramsey's Pascal TCP/IP for DOS:
  http://www.csolve.net/~add/zips/tcp.htm



Wed, 18 Jun 1902 08:00:00 GMT  
 help with read

Quote:
> As long as we are on this topic, the other main peeve is people who use
> "_" everywhere. Sometimes, they get so carried away that I wonder if they
> sign their names with it.

> This has to be one of the most jarring visual experiences possible. It's
> like throwing sand in someone's eyes.

   As one of those who does this a lot, I'll try to explain:  in e-mail
communications, it's my way to _underline_ (emphasize) information - I
feel it's better than the *emphasize* technique some use, because it
looks more like what it is and is easier to read.
    In my Pascal code, it's a good technique to enhance the readability
of "meaningful names" (if you believe in such a thing).   It's something
which often works for me in my coding experience - and not having
anything but UPPERCASE letters for the 1st 25 years of my programming
career (almost 38 years now), I appreciate the enhanced readability in my
code it offers.  This, of course, is purely a matter of style, but such
things matter to everyone, to some degree, right?  (Just look at some of
the really troubled code posted here by those who have no coding style
whatsoever to see...)

Quote:
> I always do a global search and replace and eliminate them. Of course, I
> keep a backup copy of the original in case the author named things with
> and without them.

   That's a shame, IMHO, since it eliminates virtually all emphasis some
people use, and that can have value...

Quote:
> When that happens, Pascal complains because there are duplicate routines
> or variables. Then, it's a mess to go through the code and decide what to
> rename to something else, but it's worth it.

   Too bad.  Sure seems you're "tilting at windmills" on this one...8<}}


Wed, 18 Jun 1902 08:00:00 GMT  
 help with read

Quote:


> [...]

> As long as we are on this topic, the other main peeve is people who use
> "_" everywhere. Sometimes, they get so carried away that I wonder if they
> sign their names with it.

Personally, I use _ to improve readability in various places.  Since
it's common to use more English-like variable names in Pascal, I find
something like Entire_Array more readable sometimes than EntireArray or
entirearray (when I might be lax on capitalization consistency).  I
don't use it all the time and I rarely use it in function headers.  I
also try to keep variable names and function names from being too
similar.  Not keeping some distance in naming helps make code a bit
cleaner, IMHO.

BTW, no I don't usually sign my name with it, but my nick on EFnet IRC
is usually either _Scott or __Scott.  ;-)

Quote:
> This has to be one of the most jarring visual experiences possible. It's
> like throwing sand in someone's eyes.

Your opinion . . . maybe_you've_only_seen_code_that_abuses_underscore.
;-)

Quote:
> I always do a global search and replace and eliminate them. Of course, I
> keep a backup copy of the original in case the author named things with
> and without them.

Hope you keep that mind if you ever decide you want to share that code
with somebody.  Comment, comment, comment!

Quote:
> When that happens, Pascal complains because there are duplicate routines
> or variables. Then, it's a mess to go through the code and decide what to
> rename to something else, but it's worth it.

That in itself suggests sloppy work to me in the first place.

Quote:
> Best Regards,

> Mike
> CEO, Analog & Digital Design
> Automated Production Test
>   http://www.csolve.net/~add/home.htm

> Hosting Jonathan Ramsey's Pascal TCP/IP for DOS:
>   http://www.csolve.net/~add/zips/tcp.htm

--
Scott Earnest        | We now return you to our regularly |



Wed, 18 Jun 1902 08:00:00 GMT  
 help with read


Quote:
>Even with asm there is no need to use caps. CAPS SUCK. One knows a
>BASIC programmer for his use of CAPS.

It might just be my personal preferance but I have always used caps if
I program in asm only. A habbit I got on the amiga I belive. If its an
asm statement found inside pascal I wont do it though..
Quote:
>OSMO :-)



Wed, 18 Jun 1902 08:00:00 GMT  
 help with read

Quote:

> > As long as we are on this topic, the other main peeve is people who use
> > "_" everywhere. Sometimes, they get so carried away that I wonder if they
> > sign their names with it.

> > This has to be one of the most jarring visual experiences possible. It's
> > like throwing sand in someone's eyes.
>    As one of those who does this a lot, I'll try to explain:  in e-mail
> communications, it's my way to _underline_ (emphasize) information - I
> feel it's better than the *emphasize* technique some use, because it
> looks more like what it is and is easier to read.
>     In my Pascal code, it's a good technique to enhance the readability
> of "meaningful names" (if you believe in such a thing).   It's something
> which often works for me in my coding experience - and not having
> anything but UPPERCASE letters for the 1st 25 years of my programming
> career (almost 38 years now), I appreciate the enhanced readability in my
> code it offers.  This, of course, is purely a matter of style, but such
> things matter to everyone, to some degree, right?  (Just look at some of
> the really troubled code posted here by those who have no coding style
> whatsoever to see...)
> > I always do a global search and replace and eliminate them. Of course, I
> > keep a backup copy of the original in case the author named things with
> > and without them.
>    That's a shame, IMHO, since it eliminates virtually all emphasis some
> people use, and that can have value...
> > When that happens, Pascal complains because there are duplicate routines
> > or variables. Then, it's a mess to go through the code and decide what to
> > rename to something else, but it's worth it.
>    Too bad.  Sure seems you're "tilting at windmills" on this one...8<}}

Hi Mike,

Not really - if you use a 50-line editor in DOS so you can have multiple
windows, the '_' character merges with the character in the same column
immediately below it.

This produces strange effects that depend on the combination.

For example, "_" and "T" cause the "_" to disappear.

"_" and many other lower-case characters such as "l", "1", "i", tend to
turn the result into "T".

"_" and "," or "." make the comma or period disappear.

Other combinations produce wierd, unrecognizable characters. These slow
you down, contribute to errors and confusion, and are hard to
troubleshoot.

I always do a global search and destroy on these "_" characters.

Since this newsgroup seems to be primarily DOS-oriented, and many DOS
editors are capable of 50-line displays, it would seem many more people
are affected by this than just me.

Also, I happen to save important email and newsgroup postings, and browse
them off-line (in a 50-line DOS browser.) Then, the only "_" I keep are
part of someone's email address.

Perhaps I should write them about this - they really need to change their
address :)

Best Regards,

Mike
CEO, Analog & Digital Design
Automated Production Test
  http://www.csolve.net/~add/home.htm

Hosting Jonathan Ramsey's Pascal TCP/IP for DOS:
  http://www.csolve.net/~add/zips/tcp.htm



Wed, 18 Jun 1902 08:00:00 GMT  
 help with read

Quote:



> > [...]
> > As long as we are on this topic, the other main peeve is people who use
> > "_" everywhere. Sometimes, they get so carried away that I wonder if they
> > sign their names with it.
> Personally, I use _ to improve readability in various places.  Since
> it's common to use more English-like variable names in Pascal, I find
> something like Entire_Array more readable sometimes than EntireArray or
> entirearray (when I might be lax on capitalization consistency).  I
> don't use it all the time and I rarely use it in function headers.  I
> also try to keep variable names and function names from being too
> similar.  Not keeping some distance in naming helps make code a bit
> cleaner, IMHO.
> BTW, no I don't usually sign my name with it, but my nick on EFnet IRC
> is usually either _Scott or __Scott.  ;-)
> > This has to be one of the most jarring visual experiences possible. It's
> > like throwing sand in someone's eyes.
> Your opinion . . . maybe_you've_only_seen_code_that_abuses_underscore.
> ;-)
> > I always do a global search and replace and eliminate them. Of course, I
> > keep a backup copy of the original in case the author named things with
> > and without them.
> Hope you keep that mind if you ever decide you want to share that code
> with somebody.  Comment, comment, comment!
> > When that happens, Pascal complains because there are duplicate routines
> > or variables. Then, it's a mess to go through the code and decide what to
> > rename to something else, but it's worth it.
> That in itself suggests sloppy work to me in the first place.

[...]

Quote:
> Scott Earnest        | We now return you to our regularly |


Hi Scott,

I saw your posting after replying to Mike Copeland on this same thread.

In the reply to Mike's posting, I mention the problems that "_" causes in
50-line DOS editors with characters in the same column just below it. The
combination causes some characters to disappear, or the result merges
into something unrecognizable.

That is the reason for the reference to "sand in your eyes".

This causes confusion and silly mistakes when trying to understand what
the other person is saying.

While the "_" character is intended to increase readability and add
emphasis, it often has completely unpredictable side effects that are not
what the author intended.

I just go through and eliminate them.

Best Regards,

Mike
CEO, Analog & Digital Design
Automated Production Test
  http://www.csolve.net/~add/home.htm

Hosting Jonathan Ramsey's Pascal TCP/IP for DOS:
  http://www.csolve.net/~add/zips/tcp.htm



Wed, 18 Jun 1902 08:00:00 GMT  
 
 [ 29 post ]  Go to page: [1] [2]

 Relevant Pages 

1. Help variable reads too far THANX to anyone who tries to help

2. delphi/help: ERROR READING FORM

3. HELP : VGA read plane register.

4. Help with reading file

5. Help with reading file...

6. Need help on reading charcodes!

7. help with reading textfiles

8. !Help needed reading a delimited text table

9. SIMPLE ANIMATION HELP...please read

10. help with reading data from file

11. help with read

12. Need help...Password reading function acts strange...please examine

 

 
Powered by phpBB® Forum Software