Go offline with the Player FM app!
How to write a text input routine in Commodore BASIC
Archived series ("Inactive feed" status)
When? This feed was archived on September 09, 2023 23:10 (). Last successful fetch was on April 01, 2023 17:45 ()
Why? Inactive feed status. Our servers were unable to retrieve a valid podcast feed for a sustained period.
What now? You might be able to find a more up-to-date version using the search function. This series will no longer be checked for updates. If you believe this to be in error, please check if the publisher's feed link below is valid and contact support to request the feed be restored or if you have any other concerns about this.
Manage episode 215546538 series 2427271
In this screencast I’ll show you how to write your own INPUT routine in Commodore BASIC. This comes in handy when you want to reject certain keys from being used when asking users for keyboard input. In my example I’m going to allow all alpha characters (A-Z), as well as SPACE, RETURN and the DELETE key.
Here’s the code:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 print | |
10 w$="" | |
20 print "(greater than)_"; | |
30 get a$:if a$="" then 30 | |
40 a=asc(a$) | |
50 if a=13 then 200:rem return | |
60 if a=32 then 110:rem space | |
70 if a=20 then 300:rem backspace | |
100 if a<65 or a>90 then 30 | |
110 print chr$(20);a$;"D"; | |
115 w$=w$+a$ | |
120 goto 30 | |
200 rem handle return | |
210 print chr$(20) | |
215 if w$="" then print:print"you typed | |
nothing!":end | |
220 print:print"you typed:":print w$ | |
230 end | |
300 rem handle backspace | |
305 if len(w$)=0 then 30 | |
310 print chr$(20);chr$(20);"D"; | |
320 w$=left$(w$,len(w$)–1) | |
330 goto 30 |
16 episodes
Archived series ("Inactive feed" status)
When? This feed was archived on September 09, 2023 23:10 (). Last successful fetch was on April 01, 2023 17:45 ()
Why? Inactive feed status. Our servers were unable to retrieve a valid podcast feed for a sustained period.
What now? You might be able to find a more up-to-date version using the search function. This series will no longer be checked for updates. If you believe this to be in error, please check if the publisher's feed link below is valid and contact support to request the feed be restored or if you have any other concerns about this.
Manage episode 215546538 series 2427271
In this screencast I’ll show you how to write your own INPUT routine in Commodore BASIC. This comes in handy when you want to reject certain keys from being used when asking users for keyboard input. In my example I’m going to allow all alpha characters (A-Z), as well as SPACE, RETURN and the DELETE key.
Here’s the code:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 print | |
10 w$="" | |
20 print "(greater than)_"; | |
30 get a$:if a$="" then 30 | |
40 a=asc(a$) | |
50 if a=13 then 200:rem return | |
60 if a=32 then 110:rem space | |
70 if a=20 then 300:rem backspace | |
100 if a<65 or a>90 then 30 | |
110 print chr$(20);a$;"D"; | |
115 w$=w$+a$ | |
120 goto 30 | |
200 rem handle return | |
210 print chr$(20) | |
215 if w$="" then print:print"you typed | |
nothing!":end | |
220 print:print"you typed:":print w$ | |
230 end | |
300 rem handle backspace | |
305 if len(w$)=0 then 30 | |
310 print chr$(20);chr$(20);"D"; | |
320 w$=left$(w$,len(w$)–1) | |
330 goto 30 |
16 episodes
All episodes
×Welcome to Player FM!
Player FM is scanning the web for high-quality podcasts for you to enjoy right now. It's the best podcast app and works on Android, iPhone, and the web. Signup to sync subscriptions across devices.