자주 묻는 질문입니다.

What are the best programming tips and tricks?
마지막 업데이트 8일 전에

Professional BASIC Programming Tips

Techniques used by expert Commodore programmers to write faster, more efficient code.

Speed Optimization

REM SLOW:
FOR I = 1 TO 1000
X = X + 1
NEXT I

REM FAST (USE INTEGER VARIABLES):
FOR I% = 1 TO 1000
X% = X% + 1
NEXT I%

Memory-Saving Tricks

  • Remove REM statements in final version
  • Use multiple statements per line with colons
  • Shorten variable names (A instead of ANSWER)
  • Use ? instead of PRINT
REM EXPANDED (EASY TO READ):
10 REM CALCULATE TOTAL
20 LET TOTAL = 0
30 FOR COUNT = 1 TO 10
40 LET TOTAL = TOTAL + COUNT
50 NEXT COUNT
60 PRINT "TOTAL IS "; TOTAL

REM COMPRESSED (SAVES MEMORY):
10 T=0:FORI=1TO10:T=T+I:NEXT:?"TOTAL IS";T

Useful Subroutines

59000 REM *** CLEAR SCREEN ***
59010 PRINT CHR$(147);:RETURN

59100 REM *** WAIT FOR KEYPRESS ***
59110 GET A$:IF A$="" THEN 59110
59120 RETURN

59200 REM *** CENTER TEXT ***
59210 PRINT TAB((40-LEN(T$))/2);T$
59220 RETURN

Debugging Technique

10 REM ADD STOP POINTS TO DEBUG
20 X = 5: Y = 10
30 STOP : REM PROGRAM PAUSES HERE
40 Z = X * Y
50 PRINT Z
RUN
BREAK IN 30
PRINT X, Y    : REM CHECK VALUES
CONT          : REM CONTINUE RUNNING
"The best programmers are lazy - they write efficient code so the computer does more work and they do less!" - COMPUTE! Magazine
This website relies on temporary cookies to function, but no personal data is ever stored in the cookies.
OK

Loading ...