LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 01-02-2005, 07:09 PM   #1
slackr007
Member
 
Registered: Dec 2004
Distribution: Ubuntu 64-bit
Posts: 67

Rep: Reputation: 15
Need help with BASIC


Sorry that this is probably a simple question, but here goes. I'm teaching myself basic with "Just BASIC" and I can't figure out how to make input instant. I have a program that something when you hit a certain key, but you have to hit that key and then press enter. I want it to happen as soon as you hit that key. Anyone know how to do that. Just incase you need it, here's my source:
Code:
let x=0
let y=0
let w$="w"
let s$="s"
let a$="a"
let d$="d"
let exit$="end"
let zero$=""
Print "You are in cell 0,0"
print "Press W, A, S, or D, then [Enter] to move through cells."
print "Type 'end' to end the program"
input "Press [Enter] to continue."; dummyVariable
cls
[start]
    input "Which way would you like to go?"; key$
    If key$ = w$ then let x = x + 1
    If key$ = s$ then let x = x + -1
    If key$ = a$ then let y = y + -1
    If key$ = d$ then let y = y + 1
    If key$ = exit$ then goto [end]
    If key$ = zero$ then goto [help]
    Print "You are in cell: "; x; ","; y
    let key$=zero$
    goto [start]
[help]
    Print "Please press A, S, D, or W to change cells"
    input "Press [Enter] to continue."; dummyVariable
[end]
I'd also appreciate it if you could tell me if im doing anything inefficiently and how to fix it.
Thanks.
 
Old 01-02-2005, 09:14 PM   #2
leonscape
Senior Member
 
Registered: Aug 2003
Location: UK
Distribution: Debian SID / KDE 3.5
Posts: 2,313

Rep: Reputation: 48
Having had a quick look at the docs, this is what I'd of done ( though I can't check this )
Code:
[start]
    print "Which wat would you like to go?"
    key$ = input$(1)
    select case key$
        case w$
            let x = x + 1
        case s$
            let x = x - 1
        case a$
            let y = y + 1
        case d$
            let y = y - 1
        case exit$
            goto [end]
        case else
            goto [help]
        end select
    print "You are in cell:"; x; ","; y
    key$ = zero$
    goto [start]
I would recommend actually using a loop instead of a goto, check the documents on looping.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Very Basic Help Lyko Linux - Newbie 72 03-17-2005 08:53 PM
really basic os? gravy Linux - Newbie 7 02-26-2005 09:20 PM
basic Ryan450 Linux - General 5 08-20-2004 11:59 PM
Really Basic ?'s Susan Linux - Newbie 3 10-26-2001 01:51 PM
I'm a BASIC chap, looking for some info on BASIC programming CragStar Programming 2 01-21-2001 09:19 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 08:46 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration