GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Download
  • News
  • Community
  • Resources
  • Language Reference
  • SmallBASIC Manual

This view

  • Original page
  • New address

GeezerVison is showing smallbasic.github.io — SmallBASIC | REM

Edit History

REM

REM comment

Home > Reference > Language

Code comments. Comments can also be introduced using #, single quote character '.

The # character can only be used as remarks if it is the first character of the line.

Example 1:

' That text-line is just a few remarks
REM another comment
# one more comment

Example 2:

' Although the code is very short (less then thousands of lines...), it's
' almost impossible to decode it... - That's why comments are so useful:
' to remind *yourself* and others what you did and why.
' Let's try to analyze "Curlie borealis.bas" code and add few comments to it:

' --- Start of "Curlie borealis.bas" + Comments:
' Initialize variables for the main loop:
Randomize           ' - I'm not sure why do we need it here... (MGA?)
ff = 440.03         ' Factor for defining x,y location to draw point
maxi = 25000        ' Maximum points to draw in each shape
maxi2 = maxi \ 2    ' Factor for defining two different color schemes in shape
b = Rgb(40, 20, 30) ' Background color
Color 0, b
Cls
' Run program in an endless loop (Press Ctrl+B or Ctrl+C to stop):
While 1
  ff += 9.444 ' Move the next shape to different x,y location

  ' Draw a single shape using two color schemes, or draw an invisible shape:
  For i = 0 To maxi
    ' Define location (x,y) to draw a single point:
    f += ff
    x = Min(xmax, -x + Cos(f * i)) ' (MIN makes sure location is within screen)
    y = Min(ymax, -y + Sin(f * i))

    ' Define nice color to draw a point:
    If cc Mod 6 = 0 Then
      If i < maxi2 Then ' One color scheme
        c = Rgb(255 - 255 * i \ maxi2, 255 * i \ maxi2, 0)
      Else              ' Second color scheme
        c = Rgb(0, 255 - 255 * (i - maxi2) \ maxi2, 255 * (i - maxi2) \ maxi2)
      Fi
    Else
      c = b ' Use background color to draw invisible shape
    Fi

    ' Draw a single point (pixel):
    Pset x, y, c
    If i Mod 5000 = 0 Then Showpage ' Update screen each 5000 points (smoother)
  Next
  cc++ ' Counter for drawing invisible shape (using background color)
Wend
' --- End of "Curlie borealis.bas" + Comments

' To sum up:
' Whether you write a short program or long, comments will help you
' and others to understand, debug and improve your program later on; i.e.
' comments make your code useful!
REM "Curlie borealis.bas" code example taken from:
REM http://smallbasic.sourceforge.net/?q=comment/1184#comment-1184
REM Without explicit permission from MGA...
Code samples using REM
000 hello.bas   001 3 ways to print hello 5 times.bas   002 numeric variables.bas   004 loops.bas   005 challenge.bas   006 arrays+.bas   100lines.bas   2048.bas   3d_palmx.bas   7gables.bas   ai.bas   analog clock.bas   anomail.bas   bairstow.bas   BAS_1968.bas   BAS_NOW.bas   base64.bas   betrayal: crows ii.bas   biorythms.bas   blackjack.bas   BlackJack.bas   blushing snowflakes.bas   Calendar.bas   calendar.bas   Capitol pal test.bas   Chaos_1xt.bas   Chaos_NPhase.bas   circ.bas   colors1.bas  
Language
AND   AS   BAND   BG   BOR   BYREF   CALL   CASE   CATCH   CONST   DECLARE   DEF   DO   ELIF   ELSE   ELSEIF   END   END TRY   ENDIF   EQV   EXIT   FALSE   FI   FOR   FUNC   GOSUB   GOTO   IF   IFF   IMP   IN   LABEL   LET   LIKE   LOCAL   LSHIFT   MDL   MOD   NAND   NEXT   NOR   NOT   ON   OR   REM   REPEAT   RETURN   RSHIFT   SELECT   STEP   STOP   SUB   THEN   THROW   TO   TRUE   TRY   UNTIL   USE   USG   USING   WEND   WHILE   XNOR   XOR  
This page was last edited on Thu, 6 Jul 2023 10:20:18 +0200 | Markdown processed with pandoc 3.1.12.1
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.