convert from QBASIC to PBASIC
MYM
Posts: 9
I was wondering whether anyone can help me to program the following code, which is in QBASIC, to PBASIC.
I am really just getting to know PBASIC and having a very difficult time moving toward PBASIC. So I would really appreciate it if anyone could help me. Thank You.
I am using BASIC STAMP EDITOR 2.2 and the BOE kit which includes the BS2.
NOTE: This program was created to control a model elevator using QBASIC.
[noparse][[/noparse]code]
BEGIN: cf = 0 df =0 Start: CLS LPRINT CHR$(cf); PRINT "current floor ="; INPUT "enter destination-"; df IF df > cf AND df <= 9 THEN GOTO Up IF df < cf AND df >= 0 THEN GOTO Down IF df = cf THEN GOTO Start REM Up: PRINT "elevator ascending" DO LPRINT CHR$(48 + cf); SLEEP 1 DO LPRINT CHR$(48 + cf); IF NOT STRIG(1) THEN EXIT DO LOOP DO LPRINT (48 + cf) IF STRIG(1) THEN EXIT DO LOOP SOUND 440, 2 cf = cf + 1 PRINT "current floor="; cf LPRINT (48 + cf) LOOP UNTIL cf = df GOTO Start Down: PRINT "elevator descending" DO PRINT CHR(64 + df); SLEEP 1 DO LPRINT CHR$ (64 + df); IF NOT STRIG(1) THEN EXIT DO LOOP SOUND 40, 2 df = df + 1 cf = cf - 1 PRINT "destination floor="; cf LPRINT (64 + df); LOOP UNTIL df = df GOTO Start END
I am really just getting to know PBASIC and having a very difficult time moving toward PBASIC. So I would really appreciate it if anyone could help me. Thank You.
I am using BASIC STAMP EDITOR 2.2 and the BOE kit which includes the BS2.
NOTE: This program was created to control a model elevator using QBASIC.
[noparse][[/noparse]code]
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
It's not exactly clear to me what you want to do with the converted program. Since LPRINT sends data to the printer port,
do you want the Stamp to "talk" directly to the printer? If so, there is a bit more overhead involved.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Beau Schwabe
IC Layout Engineer
Parallax, Inc.
Thanks a lot for your help.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Another method, which probably affords the quickest, easiest, and most flexible method of implementing the LPRINT QBASIC command on a PBASIC Stamp, without attempting to simulate a parallel port, is to change the LPRINT commands to SEROUT commands, convert (if necessary) any control codes, and output the data to a serial-to-parallel printer driver IC. This type of IC will also handle any control functions that may be necessary for your program to operate properly.
One inexpensive choice (less than $14.00 US) is the EDE1400 or EDE1401 Printer Driver IC from ELABs. You can find the documentation here:
http://www.elabinc.com/ then punch the EDE ICs button.
Regards,
Bruce Bates
But I think it is better for me to do PBASIC from scratch and learn the basics before I start converting this and that without knowing all of the commands. (and there explanations ).
However -- attached is a PBasic version of your program.
Open one of the 'terminal' windows to see it in action.