Forum > Beginners

type [SOLVED]

<< < (2/2)

pascal111:

--- Quote from: lucamar on May 17, 2021, 12:49:54 am ---
--- Quote from: pascal111 on May 16, 2021, 11:12:39 pm ---I think I once read in the Help for "of" Turbo Pascal that read differs from readln in that it does not add an end-of-line block "character" (line feed) and that this creates a problem in the following readln statements if reading from the console i.e. almost not preferring to use read for reading, "from" the console.
--- End quote ---

It isn't that it doesn't "add" an EOL but that it reads up to but excluding the ending <CR> (or <LF>), while ReadLn reads and discards it. The consequence is that after a Read there is a <CR> still in the queue which a later ReadLn will interpret as reading an empty line.

There are several ways to deal with this, among other by using the EOLn function for a conditional ReadLn, but if all one's doing is just reading a single value it's usually better to just use ReadLn().

--- End quote ---

تصويبٌ ممتاز ومعلوماتٌ غنيّة أغبطكـ عليها.

لقد حاولتُ أنْ أكون عُضواً فاعلاً وأنْ أُساعد غيري ولكن يبدو أنّني أفتقد بعض الدقائق والتفاصيل ،مازلتُ أتعلّم.

google translate:

"Excellent shooting "correction" and rich info I envy (good kind of envy) you "about it".

I have tried to be an active member and help others but it seems that I am missing some minutes and details, I am still learning."

PascalDragon:

--- Quote from: pascal111 on May 17, 2021, 01:05:12 am ---I have tried to be an active member and help others but it seems that I am missing some minutes and details, I am still learning."

--- End quote ---

And there's no fault in trying to be helpful even if one doesn't know the small details. :)

To be fair: this specific difference between Read and Readln isn't important very often as most people simply tend to use Readln. ;)

Nitorami:

--- Quote ---this specific difference between Read and Readln isn't important very often as most people simply tend to use Readln.
--- End quote ---

Yes, this is what I am used to. But under windows 10 it does not seem to work as it used to.
When running this code in a windows 10 cmd shell from the textmode IDE (3.2.0), I need to press enter twice to arrive at the writeln; and writeln overwrites the number I typed.
I changed to "use legacy console" but the behaviour remains the same.


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---var x: single; begin  repeat    readln (x);    writeln(x);  until x=0;end. 

pascal111:

--- Quote from: PascalDragon on May 17, 2021, 09:07:06 am ---
--- Quote from: pascal111 on May 17, 2021, 01:05:12 am ---I have tried to be an active member and help others but it seems that I am missing some minutes and details, I am still learning."

--- End quote ---

And there's no fault in trying to be helpful even if one doesn't know the small details. :)

To be fair: this specific difference between Read and Readln isn't important very often as most people simply tend to use Readln. ;)

--- End quote ---

رائعٌ هذا التشجيع ،أشكركـ.

google translate:

"Great encouragement, thank you."

Navigation

[0] Message Index

[*] Previous page

Go to full version