home *** CD-ROM | disk | FTP | other *** search
/ The Grim Reaper 5 / Grim_Reaper_The_Issue_05_1992___BASIC.atr / bet.doc < prev    next >
Text File  |  2023-02-26  |  3KB  |  1 lines

  1. BETTER PROGRAMMING¢------------------¢¢I hope that this article will be a¢regular feature, I will try to help you¢make your BASIC programs more user-¢friendly and look more professional.¢I must admit I am not the best BASIC¢programmer, but I hope this article¢will help someone, somewhere.¢*¢PRESS RETURN TO CONTINUE¢------------------------¢¢It is required in some programs for a¢prompt to 'PRESS RETURN TO CONTINUE',¢but how do you wait for the RETURN key¢(or ANY KEY if you wish) to be pressed?¢There are a number of ways...¢¢---> INPUT A$¢¢Never use this! There is nothing worse¢than being asked to press RETURN and¢then seeing the INPUT '?', it takes¢the polish off a program. If you do¢need to use INPUT then use¢¢---> INPUT #16,A$¢¢This will remove the question mark, but¢other characters can still be typed so¢it isn't perfect. It does look a lot¢better with the cursor off (POKE 752,1)¢so if you do use this then make sure¢there is no cursor.¢¢---> PEEK (764)¢¢This one is OK also, you could have¢your program...¢¢400 ? "Press RETURN";:POKE 764,255¢410 IF PEEK(764)<>12 THEN 410¢420 POKE 764,255¢430 ... continues¢¢If you wish to check for ANY KEY being¢pressed to continue then change the¢<>12 into =255.¢This is a good one to use, but if your¢program requires a lot of 'Press RETURN¢to continue' then it would be a good¢idea to have just one 'RETURN keypress¢check' and GOSUB to it whenever it is¢needed,¢¢---> GET #3,DUMM¢¢This is another good one to use, make¢sure the channel (in this case 3) has¢already been opened with¢OPEN #3,4,0,"K:" or you will get an¢error. The program could now go...¢¢400 GET #3,DUMM:IF DUMM<>32 THEN 400¢410 ...¢¢Notice the 'check' change? You must¢check location 764 for 12, but with¢GET it is 32. Why? I don't know!¢With the above you can also change it¢for ANY KEY by simply removing all the¢IF... because the GET command waits¢for a key to be pressed.¢¢And that is them all! So which one is¢for you? Well, take a look at each one¢and decide for yourself, it all depends¢on what YOU want. For example the GET¢waits for a keypress, so no more BASIC¢commands can be executed until a key¢has been pressed. But with the¢PEEK (764) you can have BASIC¢instructions also taking place whilst¢waiting for a key to be pressed.¢With the example I have given try¢changing the THEN 410 in line 410 into¢THEN 405 and then add:-¢¢405 POKE 712,PEEK(53770)¢¢What does this do? Try it and see!¢¢I hope this has helped someone, of¢course I have just skimmed over the¢surface and haven't gone into other¢uses of a command. Say for instance¢INPUT #16,A$ can be used when asking¢for input of somebodys name, it emits¢the '?' and so can look a lot neater.¢DO TRY things yourself and if you¢have any problems then contact me¢through 'TGR' and I'll try to help.¢¢John E. (TEBSF)¢