Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

qbasic and modem

Status
Not open for further replies.

fizik72

Programmer
Aug 11, 2003
8
0
0
TR
can i write a game using qbasic and pressed phone keys with
dial up connection?
 
LOL...

Are you wanting to use a land line for a game controller???

Never thought about doing that before ;-)

(I wonder if Direct X could recognize it as a game controller :p)

Good Luck!

Have Fun, Be Young... Code BASIC
-Josh
cubee101.gif


PROGRAMMER: (n) Red-eyed, mumbling mammal capable of conversing with inanimate objects.
 
DECLARE SUB opencom () 'opens com port for communication
DECLARE FUNCTION menu% () 'displays menu and accepts&returns input
DECLARE SUB waitforcall () 'waits for a call and connects when modem rings
DECLARE SUB callbbs () 'calls a place and connects
DECLARE SUB setmodemoption () 'sets modem option and saves it to a file
DECLARE SUB endprog () 'ends the program
DECLARE SUB connect () 'connects and handles output/input to/from modem


CONST HALT = 27
CLS
COLOR 6
DO
item% = menu%
SELECT CASE item%
CASE 1: waitforcall
CASE 2: callbbs
CASE 3: setmodemoption
CASE 4: endprog
END SELECT
LOOP UNTIL item% = 4
SYSTEM

SUB callbbs
COLOR 3
INPUT "Number to call: ", number$
opencom
PRINT #1, "ATDT" + number$
PRINT "Calling " + number$ + "...."
connect
END SUB

SUB connect
echo% = 0
PRINT &quot;Start Typing when modems connect... Press <Esc> for options or to quit:&quot;
PRINT
OPEN &quot;CON&quot; FOR OUTPUT AS #3
DO

ch$ = INKEY$
IF ch$ = CHR$(HALT) THEN 'if ESC pressed
PRINT &quot;====== OPTIONS =======&quot;
PRINT &quot;1. Local echo on/off &quot;
PRINT &quot;2. Send HALT character (<ESC> by default)&quot;
PRINT &quot;3. Close port &quot;
PRINT &quot;4. Return to terminal &quot;
SELECT CASE INPUT$(1)
CASE &quot;1&quot;:
echo% = echo% XOR 1
between 0 and 1
PRINT &quot;Local echo toggled. Returning to terminal....&quot;
CASE &quot;2&quot;:
PRINT #1, CHR$(HALT) PRINT &quot;HALT character sent. Returning to terminal....&quot;
CASE &quot;3&quot;: EXIT DO
closes port
CASE &quot;4&quot;:
pressing 4, but does X
CASE ELSE:
PRINT &quot;Invalid option! Returning to terminal....&quot;
END SELECT
ELSEIF ch$ <> &quot;&quot; THEN PRINT #1, ch$;
END IF
IF echo% = 1 THEN
PRINT #3, ch$;
ANSI.SYS, if avail
END IF
IF LOC(1) <> 0 THEN
inchar$ = INPUT$(1, #1)
ELSE
inchar$ = &quot;&quot;
END IF
PRINT #3, inchar$;
LOOP
CLOSE #1 'close the file once done
CLOSE #3 'close the screen of ANSI support
END SUB

SUB endprog
COLOR 7
PRINT &quot;Ending Program.&quot;
END SUB

FUNCTION menu%
DO
COLOR 5
PRINT &quot;==== BASTerm Menu ====&quot;
PRINT &quot; 1. Wait for a call &quot;
PRINT &quot; 2. Call somewhere &quot;
PRINT &quot; 3. Set Modem options &quot;
PRINT &quot; 4. End Program &quot;
PRINT &quot; Choose One: &quot;;
LOCATE , , 1: ch$ = INPUT$(1)
PRINT : PRINT 'go to the next line then skip a line
LOOP UNTIL VAL(ch$) >= 1 AND VAL(ch$) <= 4
menu% = VAL(ch$) 'returns the typed option to the function's caller
END FUNCTION

SUB opencom
PRINT &quot;Retrieving COM port data. Please hold.&quot;
OPEN &quot;BASTerm.CFG&quot; FOR INPUT AS #2
INPUT #2, comport$
CLOSE #2
OPEN comport$ + &quot;,N,8,1,RB2048,TB2048&quot; FOR RANDOM AS #1
END SUB

SUB setmodemoption
COLOR 2
INPUT &quot;COM Port Number (1 or 2): &quot;, portno$
INPUT &quot;Modem Speed (300, 1200, 2400, etc): &quot;, speed$
PRINT &quot;Are The Settings Right? &quot;;
ch$ = INPUT$(1)
IF ch$ = &quot;Y&quot; OR ch$ = &quot;y&quot; THEN
PRINT &quot;Yes&quot;
comport$ = &quot;COM&quot; + portno$ + &quot;:&quot; + speed$
OPEN &quot;BASTerm.CFG&quot; FOR OUTPUT AS #2
PRINT #2, comport$ 'store data
CLOSE #2 'close file
PRINT &quot;Settings saved.&quot;
ELSE
PRINT &quot;No&quot; 'print No... something fancy here....
PRINT &quot;Disregarding New Settings....&quot;
END IF
PRINT
END SUB

SUB waitforcall
COLOR 3
opencom
PRINT #1, &quot;ATS0=1&quot;
connect
END SUB


This is the terminal program I told you about. In the connect SUB you should add your code for what you want to happen when certain characters come through.

I will be posting the whole of basterm.bas in the FAQ section for future quick-reference
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top