rem EXAMPLE.BAS by William Yu
rem   Demonstrates just some of the supported features of BASEC

DIM MyNAME    AS STRING * 30
DIM Message   AS STRING * 30
DIM CopyRIGHT AS STRING * 30
DIM PRODUCT   AS STRING * 15
DIM Year      AS INTEGER
DIM N AS INTEGER
DIM X AS INTEGER

MyNAME    = "William Yu"
PRODUCT   = "BASEC v0.20"
CopyRIGHT = "Copyright "
Message   = "Isn't that cool?!"

' BEC can handle almost any complex equation

N=10^3       '' Available operators (+-*/^=<>, MOD, AND, OR, XOR, NOT)
X=N/5 + 20
Year=(2 * N) / ((4 - -2) + -2) + (N - 100) / X + N + (N - (N / 2)) - 6

'CLS  ' This is a DOS function

? PRODUCT;" ";CopyRIGHT;Year;" by ";MyName
?
PRINT "My name is "; MyNAME:PRINT:PRINT "Count to ten: ";
FOR N=1 TO 10
  ?N;
NEXT N
?" how's that?":?"Notice that (unlike QB), the numbers aren't split up"
PRINT
PRINT "PRINT Message: "; Message
PRINT "Negative number: "; ---(10 MOD 6);" and ";
PRINT -10 + -val(mid$("100 or 200 or 300",8,3))
PRINT
PRINT "Other numbers ";  1456789; " and, "; 987654321;
PRINT 123456789
PRINT
PRINT "Hi, "; MyNAME; " how are you today?"
PRINT
PRINT "Let's try some bitwise operators..."

N = NOT 16
X = 32 OR 16 OR 8 OR 4 OR 2 OR 1
PRINT "NOT 16 = "; N; ",  32 OR 16 OR 8 OR 4 OR 2 OR 1 = "; X

N = 16 AND 16
X = 16 XOR 16
PRINT "16 AND 16 = "; N; ",  16 XOR 16 = "; X;
?

N = 16 XOR 255
PRINT "This is what N equals "; N
X = N = 2
PRINT "Does N equal 2? "; X
X = N > 2
PRINT "Is N greater than 2? "; X

IF N <> (255 XOR 16) THEN
  PRINT "N is "; N
  ?255 xor 16
ELSEIF N = 39 THEN
  ?"oh no"
ELSEIF N = 39 THEN
  ?"oh no"
ELSEIF N <> 239 THEN
  ?"oh yes"
  if X > 2 then
    ?"X is greater than 2"
  elseif X < 2 then
    ?"not!"
    ?X
  end if
else
  ?"howdy!"
END IF

PRINT "At the end\n\n\n"

END
