Quickbasic Program Examples

Programming The Parallel Port In QBasic. If you have built any of the interfaces on my circuits page and now want to know how to actually make use of them, this page is for you. Aksi-IDE_10.png' alt='Quickbasic Program Examples' title='Quickbasic Program Examples' />File Name Issue Description Authors Call Sign 11x14Hershberger 112014 Various files, including audio examples, associated with Controlled Envelope. Gem6K Information. DataTables. txt 3K Shows use of DATP files. From the MP CD. PLCP3. K PLCP Examples. From the MP CD. Multitask. txt 2K Motion with Multitasking. View and Download Agilent Technologies 33120A user manual online. MHz Function Arbitrary Waveform Generator. A Processor pdf manual download. Gangsters 2 Vendetta Full. QBasic Quick Beginners All purpose Symbolic Instruction Code is an IDE and interpreter for a variety of the BASIC programming language which is based on QuickBASIC. Razes Programming in QuickBasic for Complete Beginners Series Link Description Author Lesson I Starts you off right from the beginning with PRINT, then moves. Factorial. Calculates and outputs factorials of numbers from 0 to 16, inclusive. Factorial of a number is defined as n 1 2 n. Program output should look. Quickbasic Program Examples' title='Quickbasic Program Examples' />This is a simple introduction to programming the parallel port in QBasic, Quick. Basic or similar language. Note that most of the concepts in this page can also be applied to GWBASIC. If you are interested in using Visual Basic to control the port, see Programming The Parallel Port In Visual Basic. What this document will not do is give you lots of details on using bi directional ports, DMA and other advanced topics. This document assumes that you are familiar with the basic functions of BASIC itself. The parallel port is made up of three different sections. These are the data lines, control lines and status lines. There are 8 data lines, and they are the primary means of getting information out of the port. In simple projects, you will be concentrating mostly on the data lines. The control lines are another 4 outputs. Chapter 3 CLS. It was probably a bit hard to find your messages on the screen with that last program. Open Qfx File In Excel more. Wouldnt it be nice to be able to clear all that stuff off the. They are meant to provide control signals to the printer such as form feed or initialize. The status lines are a standard parallel ports only inputs. There are 5 of them. They were meant to allow the printer to communicate things such as error, paper out and busy to the PC. Each section is accessed by its own address and will act independently from the rest. This is almost as if they were different ports. The addresses are as follows. Port. Address DecimalAddress HexData Lines. Control Lines. 89. Ah. Status Lines. You need to know the address of the port you want to use. You will also need two other things the command to access the port and the number you want to set it to. The command will be explained in a little while. The ports work with numbers. These can be expressed in hex, binary or decimal, but for this document all values will be expressed in decimal. Its just easier that way. Anyway, you operate the port by sending it a number that represents the binary pattern of the physical outputs on the port. For example, to set the 8 data lines to 1. To set them to 0. Note that these are all 8 bit binary numbers, and the port is also 8 outputs. Excite Chat Vp S Folder. Coincidence I think not. Now that we know how to tell the port what bit patterns we want, we have to actually apply that to the BASIC language. BASIC uses two commands to talk to the computers ports. These are OUT and INP. OUT is a statement and is used like the following. OUT port,number. We will get to INP later. As you can see, the two parameters required are the port address and the value we want to set it to. The address can be decimal or hex, as can the value. Because there are only 8 data lines, we can only send a maximum of 2. The examples below illustrate sending a few different bit patterns to the data lines. Of course, you can also turn on more than one bit. Note that when you send a bit pattern to the port everything that was there previously is cleared. This is a convenience and also a annoyance. For example, what if we want bit 2 to always stay at 1, but want to turn bit 5 on and off in sequenceEvery time we set bit 5, bit 2 is turned off, and vice versa. We will discuss how to get around this when we get to the INP function. The control lines are just as easy to control, but there are a few differences. First, the address of the port is 8. Second is that there are only 4 outputs, so the highest decimal representation of the binary bit pattern you will be using is 1. Outputting information is easy, and inputting is just as easy. If you actually want to get information into the computer, you will be using the 5 status lines. Reading the bit pattern of a port is done using the INP function. This function is used in the following way. INPport. So if we wanted to get the current status of the status lines port 8. Port. NumINP8. Port. Num would then contain the decimal representation of the binary bit pattern present at the 5 status lines. If you try this and get 3. When there is nothing connected to the input of a TTL logic chip, a high input is usually assumed. Not only can you perform inputs on ports actually designed for inputting, but you can also use INP to read the status of an output port. For example. Port. NumINP8. 88. The above would set Port. Num to the current value of the data lines port 8. We can prove this by doing the following. Port. NumINP8. If all is well, the number 5. Now that we know the INP function we can use it to solve the problem of keeping the state of one bit while changing the state of another. For that we will define a subroutine that uses both functions. SUB Out. PortPort. Address, Out. Num. Port. State INPPort. Address. Port. Num Port. State Out. Num. OUT Port. Address, Port. Num. Note how the sub adds the current port state to the number we send it. This has the effect of keeping all previous bits at the same state they were in, but either turning on or off the bit or bits represented by the number we pass to the sub. This also requires a change in the way the function is used. To turn on bit 1, we would. This example assumes a current port status of 0 0. If bit 1 is already high, you will get unexpected results, so keeping track of the port is important. To turn bit 1 back off, we would. Out. Port 8. 88, 1. Now this sub introduces a problem. How do we clear everything on the port as if we were doing OUT 8. Sending 0 to the sub has no effect adding or subtracting 0 will always give you the original number, so we will need to add a statement to specifically react to a 0. This done by a simple IF. THEN decision. SUB Out. PortPort. Address, Out. Num. Port. State INPPort. Address. Port. Num Port. State Out. Num. OUT Port. Address, Port. Num. IF Out. Num 0 THEN OUT Port. Address, 0. The sub does all its normal stuff, but also sets the port to 0 if a 0 was passed to it. This is a very easy to clear up a port if you create strange bit patterns by trying to turn a bit on twice. You may want to keep track of the state you expect the port to be and compare it to the actual state by using the INP function. If the two do not match, clear the port and reset all the the bits using your other variable. Now that we know a few useful functions with respect to output, we should look at a very useful input function. When using the port in software, you will very likely need to know the status of a single bit at one time or another. There are various ways of doing this, but I find the function below to be the most useful. FUNCTION Bit. StatusPort. Address, Bit. You. Want AS INTEGER. IF Port. Address 8. THEN. ELSE IF Port. Address 8. 89 THEN. REDIM Port. BitsNum. Of. Bits AS INTEGER. Port. Num INPPort. Address. FOR i 1 To Num. Of. Bits. Port. Bitsi Port. Num MOD 2. Port. Num FIXPort. Num 2. Bit. Status Port. BitsBit. You. Want. The function first decides how many bits it has to work with by looking at the address of the port. Note that in all other examples it was really irrelevant if you used decimal or HEX addresses. In this function you will need to change the numbers if you work in HEX. Now, back to how the function functions he he he. After deciding how many bits there are in the port, it makes an array of the same number of elements. It then goes through a loop, performing integer division on the number returned from the port. It performs one division for each bit in the port. This is probably the easiest way to convert to binary, as BASIC has no built in decimal to binary function.