# COM pc port....

Joined Mar 15, 2005
19
I have some exprerience programming and i can handle COM port.
Because i am a beginne4r at electronics i want to make something simple
How can i use com as a switch.Like when i click a button to close a circuit
and when i click again to open it.

#### n9xv

Joined Jan 18, 2005
329
This might be easier to do from the parallel printer port which is at address 378h. Pins 2 through 9 are data. Pin 2 being LSB. You can output any 0 to 255 bit pattern you like. Output a 0 (00000000) for all zero's, this could be "OFF". Output a 1 (00000001) this could be "ON". That example is using bit 0 (pin 2) as the control bit. You can talk to any port on a PC through Qbasic. I 've wrote several programs that generate various bit patterns on the parellel printer port. You can download qbasic 4.5 free on the web too!

#### buddyengineers

Joined Mar 19, 2005
26
Originally posted by Kadmos@Mar 19 2005, 11:18 PM
I have some exprerience programming and i can handle COM port.
Because i am a beginne4r at electronics i want to make something simple
How can i use com as a switch.Like when i click a button to close a circuit
and when i click again to open it.
[post=6218]Quoted post[/post]​

Ur querry can be best solved using a parallel port.., u can use turbo c (TC) to excellent effect.., it is available free on the net.., TC Installer is the keyword to be typed on Downloads.com.., There is a simlpe command called as "outp" in TC where u need to specify the port address and the data in HEX tht u need to transfer., then by any click u can change the data being transfered to the parallel port.., this is very simple., and u can also use the PC Powersupply to work ur device., u get 5V., if u plan to drive something desiring high current., then do use a seperate poersupply..,else the parallel port of the pc might get damaged .,

So check it out and njoy
Dilu

Joined Mar 15, 2005
19
I will try tommorow TC and qbasic.Do they work on XP?
tc i have tried it before a year and work but i amnot sure for qbasic..

#### pebe

Joined Oct 11, 2004
626
Originally posted by Kadmos@Mar 24 2005, 11:44 PM
I will try tommorow TC and qbasic.Do they work on XP?
tc i have tried it before a year and work but i amnot sure for qbasic..
[post=6364]Quoted post[/post]​
QBasic will run under XP but you may have a problem with any display.
I have been trying to get XP to display QBasic in 80x25 mode but the screen gives 80x50 mode.

I can't seem to find the answer. If anyone knows how, I would be grateful,

#### pebe

Joined Oct 11, 2004
626
Further information about running QBasic programs under XP.

To get a 'normal' display of 25 lines, use the statement WIDTH 80, 25 at the beginning of the program. That applies to .bas programs and .exe programs.

#### n9xv

Joined Jan 18, 2005
329
You can also use the statement SCREEN 9 at the begining of the program. Use Qbasic 4.5 with the .exe utility if you can.

#### pebe

Joined Oct 11, 2004
626
Originally posted by n9xv@Mar 28 2005, 06:18 AM
You can also use the statement SCREEN 9 at the begining of the program. Use Qbasic 4.5 with the .exe utility if you can.
[post=6475]Quoted post[/post]​
I've just tried SCREEN 9 on one of my programs, but it limits the colour range of text. For example

COLOR 7, 1: CLS
COLOR 1, 15RINT " MENU "

gives a blank blue screen.

#### n9xv

Joined Jan 18, 2005
329
Pebe, immidiately after the SCREEN 9 statement use the statement COLOR 0,0.

i.e.

SCREEN 9 : COLOR 0, 0

This initially sets the entire color palate to black. Now when you want color, turn it on and off according to what color you want.

i.e.

COLOR 14 : LOCATE 12, 3 : PRINT "What is the value of X. " ; value$' I like to use yellow for prompts. COLOR 9 : LOCATE 14, 3 : PRINT "result = " ; (X / Y) ' I like deep blue for results. If you want white text again just throw in a COLOR 7 statement etc. BTW, If you figure out how to upload Qbasic programs here I'd sure like to know how. I've been wanting to do that every since I found this site. #### pebe Joined Oct 11, 2004 626 Originally posted by n9xv@Mar 29 2005, 07:01 AM Pebe, immidiately after the SCREEN 9 statement use the statement COLOR 0,0. i.e. SCREEN 9 : COLOR 0, 0 This initially sets the entire color palate to black. Now when you want color, turn it on and off according to what color you want. i.e. COLOR 14 : LOCATE 12, 3 : PRINT "What is the value of X. " ; value$ ' I like to use yellow for prompts.

COLOR 9 : LOCATE 14, 3 : PRINT "result = " ; (X / Y) ' I like deep blue for results.

If you want white text again just throw in a  COLOR 7  statement etc.

BTW, If you figure out how to upload Qbasic programs here I'd sure like to know how. I've been wanting to do that every since I found this site.
[post=6517]Quoted post[/post]​
Ok, n9xv, but I don't want a black background. This is a sub I use regularly because it gives a 'pretty' display. It gives a blue background with a double line surround. At the top I can insert a string to identify which part of the proram I am in, eg, Menu, Addresses, etc. in blue on a bright white background . It's a standard format I use in all sections of my programs and I don't want the hastle of changing every one of them. Try it. I've included a sample header$header$ = " MENU " 'sample for this demo

SUB box 'Main Box
COLOR 7, 1: CLS 'clears screen to blue
LOCATE 1, 1
PRINT CHR$(201); 'top left corner FOR n = 2 TO 79 PRINT CHR$(205); 'along top line
NEXT
PRINT CHR$(187) 'top right corner y% = 2: x% = 1 FOR n = 2 TO 24 LOCATE y%, x% PRINT CHR$(186); 'down left side
y% = y% + 1
NEXT
y% = 2: x% = 80
FOR n = 2 TO 24
LOCATE y%, x%
PRINT CHR$(186); 'down right side y% = y% + 1 NEXT LOCATE 25, 1 PRINT CHR$(200); 'bottom left corner
FOR n = 1 TO 78
PRINT CHR$(205); 'along bottom side NEXT PRINT CHR$(188); 'bottom right corner
x% = 40 - LEN(header$) / 2 COLOR 1, 15: LOCATE 1, x%: PRINT header$
COLOR 15, 1
END SUB

XP seems the worst Windows version so far to run DOS programs. I get the program cramped into the top half of the screen. The screen is normal if I use WIDTH 80, 25
Using SCREEN 9, I get full screen but header\$ is not shown - just the blue background.

I'll look at the upload problem again. I did before but came to a dead stop. I'll keep trying.

#### n9xv

Joined Jan 18, 2005
329
Pebe, I'm still working on your program getting it typed into the editor screen. Man I wish those files would upload! If I get brave enough I'll type in one of my programs here on the forum.

I was curious though, are your files ready to run .exe files or are they .bas files that you load into the editor and run from there? The reason I ask is because I run Windows XP on my machine and have not had any problems with the screen sizing. Maybe try making a .exe of one of your files and send it to the desktop and click and run it from there. Do you use the Alt + Enter command to get full screen in DOS?

#### pebe

Joined Oct 11, 2004
626
Originally posted by n9xv@Mar 30 2005, 08:45 PM
Pebe, I'm still working on your program getting it typed into the editor screen. Man I wish those files would upload! If I get brave enough I'll type in one of my programs here on the forum.

I was curious though, are your files ready to run .exe files or are they .bas files that you load into the editor and run from there? The reason I ask is because I run Windows XP on my machine and have not had any problems with the screen sizing. Maybe try making a .exe of one of your files and send it to the desktop and click and run it from there. Do you use the Alt + Enter command to get full screen in DOS?
[post=6573]Quoted post[/post]​
Why don't you paste the text into notepad, then save it in the QB directory as sample.bas or something? Then you can open it in the QB editor and after giving it a few tweeks, it will run.

About my files, I run them as compiled .exe files, accessed from the desktop via a shortcut. I have tried running my original .bas files from the editor. Same result.

I started using QuickBasic 4.0 originally in DOS 5. I never used a WIDTH or SCREEN statement, because the screen was 25 lines anyway and only used for text. Going from memory, I think it defaults to SCREEN 0. I progressed to DOS 6.22, then QuickBasic 4.5, then Windows 95 and 98SE, and never experienced a problem.

Then I went to XP after having many crashes with 98SE and got this shortened screen. The entire screen is blue but text only occupies the top half. Even the editor is in 50line mode - though that's an advantage because I can see more lines! I tried every permutation available on the short cut for screen size - all without sucess. I finally cured it by seeking help from one of the QBasic forums. The guy there recomended using WIDTH 80, 25 and it worked like a charm.

I don't know why SCREEN 9 doesn't work. The color I am using for the header (blue text on a bright white background) is a valid command in ver. 4.0, though I don't know about 4.5 because I haven't got the manual (downloaded version!).

If you find out, I'd be interested to know out of curiosity. I raised the question of printouts with the guy on the QB forum, and he gave me the impression that XP was very 'iffy' when dealing with various DOS programs. It's probably because MS are trying to phase out DOS completely.

#### n9xv

Joined Jan 18, 2005
329
Pebe, I do know that the statement COLOR 15, 1 is a valid command in Quick Basic 4.5 as well. I have used that at least once somewhere in my programs. The copy & paste as you said will work too, I just need to stream line that proceedure a bit. It's been a while since I had to manipulate Qbasic files "in the raw" so to speak. I guess ole Bill down there at MS thought there was no longer a need for Qbasic anymore. He probably sat staring out the window of his lavish office and scratched his head thinking "Qbasic HA HA HA, who in their right mind uses Qbasic anymore - yep thats gotta go!" Oh well, gotta go where the money is I suppose -.

I have a Qbasic programmers reference manual if thats ever of any interest.

#### pebe

Joined Oct 11, 2004
626
Originally posted by n9xv@Mar 31 2005, 08:05 AM
....I have a Qbasic programmers reference manual if thats ever of any interest.
[post=6609]Quoted post[/post]​
n9xv,
Thanks. I'll bear that in mind.

Coming back to the question of uploading programs, you opened a thread in the off-topic section on 3 Feb. The thread was 'just checkin' and you included an attachment 'mod256.pdf'.

I couldn't get it to work, but I replied with an attachment using an alternative method - a zipped file. I zipped up a file LCZ.EXE into pebe.zip and the upload was accepted alright.

Hope that helps.

#### n9xv

Joined Jan 18, 2005
329
Ok Pebe, I'd be very curious to try that. As a point of reference can you tell me exactly how you zipped up the file? At least I'll know I'm following a proceedure that has documented success

#### pebe

Joined Oct 11, 2004
626
Originally posted by n9xv@Apr 3 2005, 07:23 AM
Ok Pebe, I'd be very curious to try that. As a point of reference can you tell me exactly how you zipped up the file? At least I'll know I'm following a proceedure that has documented success
[post=6660]Quoted post[/post]​
I used WINZIP. It's an archiving utility that compresses one or more files into a single .zip file. You use the same program to 'unzip' them again to their originals. I think the forum accepts a .zip for upload because it hasn't got the dreaded .exe extension - with its risk of viruses. The forum cannot interpret the .zip file as a .jpg so it just leaves it as an attachment. At least, that's how I assume it works.

Winzip can also make self-extracting files, but they would have an .exe extension and probably couldn't be uploaded. I think most of the downloads available are self-extracting zip files. Winzip provides a good tutorial.

A similar prog for archiving is WINRAR. It will unzip a .zip file but I'm not sure if it will make one. It might be worth looking at though. Here are the two links.

www.winzip.com
www.rarlab.com

I hope that helps.

#### n9xv

Joined Jan 18, 2005
329
Ok Pebe cool! Just posting to let you know I'am working on it.

4-05-05

Ok, lets try this. A file called freqwave.zip programmed in Qbasic 4.5.

see attachment;

#### n9xv

Joined Jan 18, 2005
329
Is anyone getting the freqwave.zip to work?

#### pebe

Joined Oct 11, 2004
626
Originally posted by n9xv@Apr 6 2005, 06:39 AM
Is anyone getting the freqwave.zip to work?
[post=6753]Quoted post[/post]​

But when I try to run the file WinRaR takes over and comes up with this message.
"Do you want to replace
freqwave.exe .......131,459 bytes.............dated 15/04/2005
with
freqwave.exe .......47644 bytes ..............dated 13/07/2003.."

Whether I say Yes or No, the prog will not run. I cannot find the second file on my HD, so I don't know what's going on. Are you sending two files?

#### n9xv

Joined Jan 18, 2005
329
No, I'am only sending one file but I'am confused as well. I'll keep hacking away at it. Does'nt Windows XP have a built in compression/zip utility?