Inputing strings. ARRRRGGGGG! 
Author Message
 Inputing strings. ARRRRGGGGG!

i'm having touble with inputing a string.  I read somewhere that
after inputing chars/srings/etc that a carraige return is left over or
something.  How do I get rid of this carraige return?

thanks...

if at all possible, please reply via email...

--
Keith Jennings

Yes, Mississippi...



Wed, 18 Jun 1902 08:00:00 GMT  
 Inputing strings. ARRRRGGGGG!

Quote:
>i'm having touble with inputing a string.  I read somewhere that
>after inputing chars/srings/etc that a carraige return is left over or
>something.  How do I get rid of this carraige return?

     I'm not sure, but it sounds like you might be confused about the
difference between "read ()" and "readln ()".  Both procedures "fill"
their arguments from the specified file.  However, the readln procedure
then skips merrily along the input file until it "swallows" an
end-of-line (which, in many implementations, is <CR>).

     Thus the simple answer is to use readln, and never see the <CR>.

     Note that the above is meant to be true for Standard Pascal, which
has no "string" type (you declare your own implementation, usually using
a packed array of characters).  The Borland languages might have some
additional twists to this tale ...

Bob Schor
Pascal Enthusiast



Wed, 18 Jun 1902 08:00:00 GMT  
 Inputing strings. ARRRRGGGGG!

Quote:

> i'm having touble with inputing a string.  I read somewhere that
> after inputing chars/srings/etc that a carraige return is left over or
> something.  How do I get rid of this carraige return?

> thanks...

> if at all possible, please reply via email...

> --
> Keith Jennings

> Yes, Mississippi...

You probably uses something like:

read(mystring);

right? This does leave a carriage return in the buffer, because "read" is
NOT for entering strings. Instead use

readln(mystring);

which does exactly the same, except for the carriage return. Just keep one
thing in mind: only use "read" when reading from a typed file (FILE OF ...).

Kent Friis



Wed, 18 Jun 1902 08:00:00 GMT  
 Inputing strings. ARRRRGGGGG!

Quote:


>> i'm having touble with inputing a string.  I read somewhere that
>> after inputing chars/srings/etc that a carraige return is left over or
>> something.  How do I get rid of this carraige return?

>> thanks...

>> if at all possible, please reply via email...

>> --
>> Keith Jennings

>> Yes, Mississippi...
>You probably uses something like:
>read(mystring);
>right? This does leave a carriage return in the buffer, because "read" is
>NOT for entering strings. Instead use
>readln(mystring);
>which does exactly the same, except for the carriage return. Just keep one
>thing in mind: only use "read" when reading from a typed file (FILE OF ...).
>Kent Friis

To Keith Jennings: Are you aware that a tutorial exists about Pascal?

Look at the URL below.....

Glenn Grotzinger

MOD and S3M user extraordinaire.
Writer of TP tutorial.  All released parts findable at:
ftp://garbo.uwasa.fi/pc/turbopas/tptutr0h.zip



Wed, 18 Jun 1902 08:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Inputing into DBImage

2. TP Question: Problem with inputing integers and ENTER

3. instructions for inputing and outputing data in BP7 for win

4. Inputing fixed width files

5. How to set where inputed text appears?

6. How to set where inputed text appears?

7. Inputing a date of birth..

8. pchar := string; string:=pchar

9. How to convert strings to nul-terminated strings?

10. String vs. String literal

11. String within a String

12. String (swapping two chars in a string)

 

 
Powered by phpBB® Forum Software