Subject: Common Turbo Pascal Questions and Timo's answers Date: Tue, 10 Aug 1999 21:25:21 -0700 From: Timo Salmi Organization: University of Vaasa Newsgroups: borland.public.turbopascal 164988 Apr 25 1999 ftp://garbo.uwasa.fi/pc/link/tsfaqp.zip tsfaqp.zip Common Turbo Pascal Questions and Timo's answers -------------------------------------------------------------------- FAQPAS1.TXT Frequently (and not so frequently) asked Turbo Pascal questions with Timo's answers. 1) How do I disable or capture the break key in Turbo Pascal? 2) How do I get a printed documentation of my students' TP runs? 3) What is the code for the weekday of a given date? 4) Need a program to format Turbo Pascal source code consistently 5) Can someone give me advice for writing a tsr program? 6) Why can't I read / write the com ports? 7) What are interrupts and how to use them in Turbo Pascal? 8) Should I upgrade my Turbo Pascal version? 9) How do I execute an MS-DOS command from within a TP program? 10) How is millisecond timing done? 11) How can I read the text character fonts from the memory? 12) How to find the files in a directory and subdirectories? 13) I need a power function but there is none in Turbo Pascal. 14) How can I create arrays that are larger than 64 kilobytes? 15) How can I test that the printer is ready? 16) How can I clear the keyboard type-ahead buffer? 17) How can I utilize expanded memory (EMS) in my programs? 18) How can I obtain the entire command line? 19) How do I redirect text from printer to file in my TP program? 20) Turbo Pascal is for wimps. Use standard Pascal or C instead? 21) How do I turn the cursor off? 22) How to find all roots of a polynomial? 23) What is all this talk about "Pascal homework on the net"? 24) How can I link graphics drivers directly into my executable? 25) How can I trap a runtime error? -------------------------------------------------------------------- FAQPAS2.TXT More frequently (and not so frequently) asked Turbo Pascal questions with Timo's answers. 26) How to get ansi control codes working in Turbo Pascal writes? 27) How to evaluate a function given as a string to the program? 28) How does one detect whether input (or output) is redirected? 29) How does one set the 43/50 line text mode? 30) How can I assign a value to an environment variable in TP? 31) How does one store, and then restore the original screen? 32) How can I convert a TPU unit of one TP version to another? 33) Which error is e.g. Runtime error 205, etc 34) Why can't I open read-only files? I get "File access denied". 35) How do I obtain high and low parts of a byte variable? 36) How can I set a hi-intensity color background in the text mode? 37) Where can I find a program to convert (Turbo) Pascal to C? 38) How can I read input without echoing to the screen? 39) How can I edit the readln input stream? 40) How can I write (brand) something into my executables? 41) What is wrong with my program? It hangs without a clear pattern? 42) How do I convert a decimal word into a hexadecimal string, etc? 43) How to determine the last drive? 44) How can I put a running clock into my Turbo Pascal program? 45) How to establish if a name refers to a directory or not? 46) How does one disable alt-ctrl-del? 47) How can I test whether a file exists? 48) What is the name of the current Turbo Pascal program? 49) How is the code for rebooting the PC written in Turbo Pascal? 50) How can I write inline code? -------------------------------------------------------------------- FAQPAS3.TXT The third set of frequently (and not so frequently) asked Turbo Pascal questions with Timo's answers. 51) I am running out of memory when compiling my large program. 52) How do I avoid scrolling in the last column of the last row? 53) How can one hide (or unhide) a directory using a TP program? 54) How do I test whether a file is already open in a TP program? 55) How can I test and convert a numerical string into a real? 56) How can I reverse a TP .EXE or .TPU back into source code? 57) How can I calculate the difference between two points of time? 58) Is a program running stand-alone or from within the IDE? 59) Please explain Turbo Pascal memory addressing to me. 60) How do I obtain a bit or bits from a byte, a word or a longint? 61) What are Binary Coded Decimals? How to convert them? 62) How can I copy a file in a Turbo Pascal program? 63) How can I use C code in my Turbo Pascal program? 64) How do I get started with the Turbo Profiler? 65) How can I detect if the shift/ctrl/alt etc key is pressed? 66) How do I get a base 10 logarithm in TP? 67) If Delay procedure does not work accurately, how do I fix it? 68) How much memory will my TP program require? 69) How to detect if a drive is a CD-ROM drive? 70) How do I convert an array of characters into a string? 71) How do I get started with graphics programming? 72) Where to I find the different sorting source codes? 73) A beginner's how to write and compile units. 74) What are and how do I use pointers? 75) How can I read another program's errorlevel value in TP? -------------------------------------------------------------------- FAQPAS4.TXT The fourth set of frequently (and not so frequently) asked Turbo Pascal questions with Timo's answers. 76) What are the current Pascal newsgroups on the Usenet news? 77) How do I detect the CapsLock status, how do I turn it on/off? 78) How do I detect if the F11 or F12 key has been pressed? 79) How do I extract (parse) substrings from an input string? 80) How do I find out the size of any kind of a file? 81) How do I format graphics output like in textmode writeln? 82) How do I detect if more than one standard key is pressed down? 83) How can I read a disk's Volume Serial Number? 84) How can I disable and then enable the keyboard in my TP program? 85) How do I get the character device name of the (first) CD-ROM? 86) How do I eject a CD-ROM using a Turbo Pascal program? 87) How do I find out if the ANSI.SYS driver has been loaded? 88) Where do I find Turbo Pascal tutorials and/or good textbooks? 89) How do I make an executable of my Turbo Pascal source program? 90) How can I quickly read the last byte of a file? 91) Is 2000 a leap year? What is the leap year algorithm? 92) Does anybody have a program that gives the week number? 93) How can I use OutText to write numbers in the graphics mode? 94) How can I redirect output to file if I use the Crt unit? 95) How to write a function to return true if I am in graphics mode? 96) My graph.tpu got corrupted. Someone please email me a new copy. 97) How can I avoid run-time errors in numeric input using readln? 98) How can I limit the user's readln input to e.g. 3 characters? 99) Can you tell a beginner how to delete files with Turbo Pascal? 100) Could you please explain shl and shr operators to a beginner? -------------------------------------------------------------------- FAQPAS5.TXT The fifth set of frequently (and not so frequently) asked Turbo Pascal questions with Timo's answers. 101) How do I detect if mouse hardware/driver is installed? 102) How can I read absolute sectors directly from a floppy? 103) How can I move a file to another directory in Turbo Pascal? 104) How can I get/set a disk volume label? 105) Is there a function to chop off the leading zero from 0.322? 106) How can I print a text file (and conclude sending a formfeed)? 107) How can I round 4.1256455 to two decimal places to give 4.13? 108) How can I list with paths all the files on a drive? 109) What are the formulas for ArcSin and ArcCos? 110) How can I determine how many bytes are allocated to a file? 111) How can I modify the colors of the VGA graphics palette? 112) How can I check if SMARTDRV has been installed? Which version? 113) Is there a way to make the text blink in the graphics mode? 114) How do I make writeln (15/18) give 0.83, not 8.3333333333E-01? 115) How do I get 256 colors instead of Turbo Pascal's normal 16? 116) How can I read a text character from the screen (e.g. xy 5,2)? 117) How can I clear the screen without the Crt unit? 118) How can I test if a disk is present in the drive? 119) What is the Pascal code to add a number of days to a date? 120) How can I stuff keystrokes in advance into the keyboard buffer? 121) What is the code for a fast 16-color PutPixel Routine? 122) What is the code for a fast 256-color PutPixel Routine? 123) How can I substitute a substring with another in a string? 124) Curing Crt initialization runtime error 200 on fast machines 125) How can I copy text and example codes from Turbo Pascal help? -------------------------------------------------------------------- FAQPAS6.TXT The sixth set of frequently (and not so frequently) asked Turbo Pascal questions with Timo's answers. 126) How do I detect if my program is running under Windows? 127) How do I set errorlevel in Turbo Pascal and test it in a batch? 128) How do I get started with mouse programming? 129) How can I find out if a date is a valid date? 130) How can I write an array to a text file in Turbo Pascal? 131) Where do I get ASCII and scan codes for the different keys? 132) How do I define and use records? How do I give initial values? 133) What real numbers types are there? How do I use them? 134) How do I find out the default status of the compiler switches? 135) Anyone know where I can download Pascal source codes? 136) Is there a bug in Turbo Pascal's set operations? 137) How can I output 1000000 as 1,000,000? 138) How can I write text to the printer from a TP program? 139) How do I get a random number from 1 to 49 instead of 0 to 49? 140) How do I get a list of numbers from 1 to 52 in a random order? 141) How can I disable/re-enable a drive from within a TP program? 142) How can I write a filter for ROT13 encryption in Turbo Pascal? 143) Why does writing the value of r := 104.50; give a false result? 144) What is the quickest way to find a word from an ordered array? 145) How to tell which TP version has been used to compile an .exe? 146) How can I make a directory read-only under TP, and vice versa? 147) Where can I find Turbo Pascal 7.0 compiler on the net? 148) I don't have the printer.tpu. Who can please email it to me? 149) How can I convert Arabic numerals into Roman ones? 150) Could someone please explain to me how I can rotate an image? -------------------------------------------------------------------- FAQPAS7.TXT The seventh set of frequently (and not so frequently) asked Turbo Pascal questions with Timo's answers. 151) Is there a frequency table for the different notes (C C# D...)? 152) Where is the help for Code in Val(S; var V; var Code: Integer)? 153) How can I test if an integer number is a prime? 154) How can I detect if a drive exists? 155) How can I detect if a drive medium is write protected or not? -------------------------------------------------------------------- FAQPASB.TXT Bibliography of textbooks and references for frequently asked Turbo Pascal questions with Timo's answers. -------------------------------------------------------------------- All the best, Timo -- Prof. Timo Salmi ftp & http://garbo.uwasa.fi/ archives 193.166.120.5 Department of Accounting and Business Finance ; University of Vaasa mailto:ts@uwasa.fi ; FIN-65101, Finland Digital photos collection at http://www.uwasa.fi/ktt/lasktoim/photo/