You are a BASIC bitch, so type-in and share your BASIC listings here. Any and all BASIC dialects are welcome.

  • Zaphod42@lemmy.sdf.org
    link
    fedilink
    arrow-up
    5
    ·
    1 year ago

    Originally coded for a Sharp PC-1251. Basically my “Hello World” in every programming language I try:

    10: INPUT "GEWICHT IN KG" , M
    20: INPUT "GROESSE IN M" ,L
    30: B=M/L^2
    40: PRINT "BMI = ";B
    

    I ported this to LF-BASIC https://github.com/LiquidFox1776/LF-BASIC, a BASIC-interpreter written in Python:

    10 LET M=0
    20 LET L=0
    30 LET B=0
    40 INPUT "GEWICHT IN KG "; M
    50 INPUT "GROESSE IN CM "; L
    60 LET L=L/100
    70 LET B=M/L^2
    80 PRINT "BMI = "; B
    

    Then I started using PDP-8-Emulation and TSS-8:

    10 LET M=0
    20 LET L=0
    30 LET B=0
    35 PRINT "WEIGHT IN KG.G:"
    40 INPUT M
    45 PRINT "HEIGHT IN CM:"
    50 INPUT L
    60 LET L=L/100
    70 LET B=M/L^2
    75 PRINT "YOUR BMI IS:"
    80 PRINT B
    90 END
    
  • over_clox@lemmy.world
    link
    fedilink
    arrow-up
    3
    ·
    edit-2
    1 year ago

    RapidQ integer rounding was totally broken, so I wrote this…

    
    ABSVal# = ABS(Value#): SGNVal& = SGN(Value#)
    	FIXVal& = FIX(ABSVal#): FRACVal# = FRAC(ABSVal#)
    	AddVal& = (((FRACVal# = .5) AND FIXVal&) OR (FRACVal# > .5)) AND 1
    	FIXVal& += AddVal&: IF SGNVal& = -1 THEN FIXVal& = -FIXVal&
    	RQRoundFix = FIXVal&
    END FUNCTION```
    • jadero@lemmy.sdf.org
      link
      fedilink
      arrow-up
      2
      ·
      1 year ago

      Are you sure that rounding was broken? Many systems use “Gaussian” or “banker’s” rounding to reduce accumulation of rounding errors. Instead of always rounding to the next larger absolute value at .5, they round to the nearest even number. Although it introduces a bias toward even numbers in the result set, it reduces accumulation of error when .5 is as likely as as any other fraction and odd/even are equally likely in the source.

      I was taught “banker’s” rounding in school (graduated 1974) and have had to implement it a few times to reduce error accumulation.

      If you are looking for a rabbit hole, Wikipedia has a pretty comprehensive article, including an example of how the wrong choice of rounding algorithm led to massive problems at the Vancouver Stock Exchange (Canada).

  • Ubuntu Peronista@lemmy.sdf.orgOP
    link
    fedilink
    arrow-up
    1
    ·
    edit-2
    8 months ago

    Star Wars March for the Atari!

    1 GRAPHICS 2+16
    2 ? #6;"STAR WARS THEME"
    3 ? #6;"BY JOHN WILLIAMS"
    4 REM ARR. BY AARON NESS
    5 REM FROM ACE NEWSLETTER, VOL.2,NO.3, MARCH 1981
    8 FOR W=1 TO 500:NEXT W
    9 GRAPHICS 0
    10 READ S,N0,N1,N2,N3
    20 IF N0=-1 THEN END 
    25 ? S;"|";N0;"|";N1;"|";N2;"|";N3
    30 SOUND 0,N0,10,4:SOUND 1,N1,10,4
    35 SOUND 2,N2,10,4:SOUND 3,N3,10,4
    40 FOR X=1 TO S*150:NEXT X:GOTO 10
    100 DATA .3,108,0,0,0
    101 DATA 0,0,0,0,0
    102 DATA .3,108,0,0,0
    104 DATA 0,0,0,0,0
    105 DATA .2,108,0,0,0
    110 DATA 1,81,108,128,162
    111 DATA 1,81,108,128,173
    114 DATA 1,53,64,81,193
    116 DATA 1,53,64,81,217
    120 DATA .3,60,81,96,243
    122 DATA .3,64,81,96,243
    124 DATA .2,72,81,96,243
    125 DATA 1,40,53,64,128
    128 DATA 1,40,53,64,144
    129 DATA 1,53,64,81,162
    140 DATA .3,60,81,96,243
    141 DATA .3,64,81,96,243
    144 DATA .2,72,81,96,243
    145 DATA 1,40,53,64,128
    148 DATA 1,40,53,64,144
    149 DATA 1,53,64,81,162
    160 DATA .3,60,72,91,182
    161 DATA .3,64,72,91,182
    164 DATA .3,60,72,91,182
    165 DATA 2,72,85,108,217
    168 DATA .6,108,0,0,0
    169 DATA 0,0,0,0,0
    172 DATA .3,108,0,0,0
    173 DATA 0,0,0,0,0
    180 DATA 1,81,103,128,162
    181 DATA 1,81,108,128,173
    184 DATA 1,53,64,81,193
    185 DATA 1,53,64,81,217
    190 DATA .3,60,81,96,243
    191 DATA .3,64,81,96,243
    194 DATA .2,72,81,96,243
    196 DATA 1,40,53,64,128
    198 DATA 1,40,53,64,144
    199 DATA 1,53,64,81,162
    210 DATA .3,60,81,96,243
    211 DATA .3,64,81,96,243
    214 DATA .2,72,81,96,243
    215 DATA 1,40,53,64,128
    218 DATA 1,40,53,64,144
    219 DATA 1,53,64,81,162
    230 DATA .3,60,72,91,182
    231 DATA .3,64,72,91,182
    234 DATA .3,60,72,91,182
    235 DATA 1,72,85,108,217
    236 DATA .6,108,0,0,0
    237 DATA 0,0,0,0,0
    238 DATA .3,108,0,0,0
    250 DATA 1.5,96,121,162,0
    251 DATA 0,0,0,0,0
    252 DATA .5,96,0,0,217
    254 DATA .5,60,81,96,217
    255 DATA .5,64,81,96,217
    256 DATA .5,72,81,96,217
    258 DATA .5,81,81,96,217
    270 DATA .3,81,96,0,217
    271 DATA .3,72,96,0,217
    274 DATA .3,64,96,0,217
    275 DATA 1,72,0,0,217
    278 DATA .25,96,0,0,217
    279 DATA 1,85,108,144,217
    282 DATA .6,108,0,0,0
    283 DATA 0,0,0,0,0
    284 DATA .3,108,0,0,0
    290 DATA 1.5,96,121,162,217
    291 DATA 0,0,0,0,0
    292 DATA .5,96,121,162,217
    294 DATA .5,60,81,121,217
    295 DATA .5,64,81,121,217
    298 DATA .5,72,81,121,217
    299 DATA .5,0,81,121,217
    310 DATA .75,53,68,91,136
    311 DATA .25,72,0,0,0
    314 DATA 2,72,85,108,217
    315 DATA .6,108,0,0,0
    318 DATA 0,0,0,0,0
    319 DATA .3,108,0,0,0
    320 DATA 1.5,96,121,162,0
    321 DATA 0,0,0,0,0
    322 DATA .5,96,0,0,217
    324 DATA .5,60,81,96,0
    325 DATA .5,64,81,96,0
    328 DATA .5,72,81,96,217
    329 DATA .5,0,81,96,0
    340 DATA .3,81,96,121,217
    341 DATA .3,72,96,121,0
    344 DATA .3,64,96,121,0
    345 DATA .6,72,96,121,217
    348 DATA .3,0,96,0,0
    349 DATA 1,85,0,0,0
    352 DATA .6,53,0,0,217
    353 DATA 0,0,0,0,0
    354 DATA .3,53,0,0,0
    360 DATA .6,40,50,60,81
    361 DATA .3,45,60,81,128
    364 DATA .6,50,60,81,243
    365 DATA .3,53,0,81,217
    368 DATA .6,60,0,81,204
    369 DATA .3,68,0,0,182
    372 DATA .6,72,0,0,162
    373 DATA .3,81,0,0,144
    380 DATA 1,53,0,0,0
    381 DATA .1,72,85,121,217
    384 DATA 0,0,0,0,0
    385 DATA .1,72,85,121,217
    386 DATA 0,0,0,0,0
    387 DATA .1,72,85,121,217
    388 DATA 0,0,0,0,0
    389 DATA .5,72,85,121,217
    390 DATA .3,0,0,108,0
    391 DATA 0,0,0,0,0
    392 DATA .3,0,0,108,0
    393 DATA 0,0,0,0,0
    394 DATA .3,0,0,108,0
    395 DATA 0,0,0,0,0
    400 DATA 1,81,108,128,162
    401 DATA 1,81,108,128,173
    404 DATA 1,53,64,81,193
    405 DATA 1,53,64,81,217
    410 DATA .3,60,81,96,243
    411 DATA .3,64,81,96,243
    414 DATA .2,72,81,96,243
    415 DATA 1,40,53,64,128
    418 DATA 1,40,53,64,144
    419 DATA 1,53,64,81,162
    430 DATA .3,60,81,96,243
    431 DATA .3,64,81,96,243
    434 DATA .2,72,81,96,243
    435 DATA 1,40,53,64,128
    438 DATA 1,40,53,64,144
    439 DATA 1,53,64,81,162
    450 DATA .3,60,72,91,182
    451 DATA .3,64,72,91,182
    454 DATA .3,60,72,91,182
    455 DATA 2,72,85,108,217
    456 DATA .6,108,0,0,0
    457 DATA 0,0,0,0,0
    458 DATA .3,108,0,0,0
    462 DATA 0,0,0,0,0
    470 DATA 1,81,108,128,162
    471 DATA 1,81,108,128,173
    474 DATA 1,53,64,81,193
    475 DATA 1,53,64,81,217
    480 DATA .3,60,81,96,243
    481 DATA .3,64,81,96,243
    484 DATA .2,72,81,96,243
    485 DATA 1,40,53,64,128
    488 DATA 1,40,53,64,144
    489 DATA 1,53,64,81,162
    500 DATA .3,60,81,96,243
    501 DATA .3,64,81,96,243
    504 DATA .2,72,81,96,243
    505 DATA 1,40,53,64,128
    508 DATA 1,40,53,64,144
    509 DATA 1,53,64,81,162
    520 DATA .3,60,72,91,182
    521 DATA .3,64,72,91,182
    524 DATA .3,60,72,91,182
    525 DATA 2,72,85,108,217
    528 DATA 1,53,108,217,0
    530 DATA .5,0,0,0,217
    540 DATA 1,40,53,64,162
    542 DATA 1,40,53,64,173
    544 DATA 1,40,53,64,193
    546 DATA 1,40,53,64,217
    550 DATA 1,40,53,64,243
    552 DATA 1,40,53,64,217
    554 DATA 1,40,53,64,193
    556 DATA 1,40,53,64,173
    558 DATA 2,40,53,64,162
    559 DATA 0,0,0,0,0
    560 DATA .1,40,53,64,162
    561 DATA 0,0,0,0,0
    562 DATA .1,40,53,64,162
    563 DATA 0,0,0,0,0
    564 DATA .1,40,53,64,162
    565 DATA 0,0,0,0,0
    566 DATA 1.7,40,53,64,162
    600 DATA 0,-1,0,0,0
    
  • Ubuntu Peronista@lemmy.sdf.orgOP
    link
    fedilink
    arrow-up
    1
    ·
    1 year ago

    Darthmouth GRAFIX.BAS!

    100 DEF FNF(X)=SIN(X)
    105 DEF FNG(X)=LOG(X)/LOG(10)
    110 DEF FNR(X)=INT(X+.5)
    120 DEF FNX(X)=INT(100*X+.5)/100
    130 READ A,B,S
    140 READ C,D,N
    150 IF N<=50 THEN 180
    160 PRINT "ONLY 50 SUBDIVISIONS"
    170 STOP
    175 :
    180 H=(D-C)/N
    190 PRINT ""Y-AXIS FROM ";C;" TO ";D;
    195 PRINT " IN INCREMENTS OF ";H
    200 PRINT
    210 PRINT TAB(8);"'";
    220 FOR I=1 TO N-1
    230    PRINT "-";
    240 NEXT I
    250 PRINT "'"
    255 :
    260 FOR X=A TO B STEP S
    270    Y=FNF(X)
    272    Y1=8+FNR((Y-C)/H)
    274    Y=FNG(X)
    276    Y2=8+FNR((Y-C)/H)
    278    PRINT FNX(X);
    280    IF Y2
  • Ubuntu Peronista@lemmy.sdf.orgOP
    link
    fedilink
    arrow-up
    1
    ·
    1 year ago
    10 : CLEAR : PAUSE “Mini Moon Age Calculator “
    20 : W=694098 : X=29.53 : Z=365.25 : JN=2460202.6 : REM Julian date for last moon on 25/9/2023 at 2:39am
    30 : INPUT “DAY:” ; D , “MONTH:” ; M , “YEAR:” ; Y
    40 : IF M<=2 LET Y=Y-1 : M=M+12
    50 : A=INT(Y/100) : B=INT(A/4) : C=2-A+B : E=INT(Z * (Y+4716))
    60 : F=INT(30.6001 * (M+1)) : JD=C+D+E+F-1524.5 : DS=JD-JN
    70 : S=(DS/X-INT(DS/X)) * X : S=INT(S+.5)
    80 : PRINT “Age of Moon “ ; USING “###.# “ ; S ; “_days” : END
    

    Stay SHARP!

  • Ubuntu Peronista@lemmy.sdf.orgOP
    link
    fedilink
    arrow-up
    2
    arrow-down
    1
    ·
    1 year ago
    1  REM TEST YOUR INPUT AND THEN
    10 PRINT "DO YOU EAT YOUR BOUGHS??"
    20 INPUT X
    30 IF X="YES" THEN PRINT "YOU PIG!.": END
    40 IF X="NO" THEN PRINT "WHAT ARE YOU WAITING FOR TO TRY?"
    50 END
    
  • Ubuntu Peronista@lemmy.sdf.orgOP
    link
    fedilink
    arrow-up
    1
    ·
    1 year ago

    This a Sharp BASIC suffler for the 40 spanish card deck, for truco and other games.

    10:REM BARAJADOR MAZO DE 40 CARTAS ESPANOLAS,SHARP PC-1360
    20:WAIT 0: CLS : CLEAR
    30:DIM A$(41)*20,S$(0)*32,P$(0)*65
    40:C=0:S$(0)="Basto   Espada  Oro     Copas"
    50:P$(0)="As   Dos  Tres CuatroCincoSeis SieteSota CaballoRey"
    60:FOR S=1 TO 4
    70:FOR N=1 TO 10
    80:C=C+1
    90:A$(C)= MID$ (P$(0),(N*5)-4,5)+" de "+ MID$ (S$(0),(S*8)-5,0)
    100:NEXT N: NEXT S
    110:FOR C=41 TO 2 STEP - 1:A= RND (40)+1:A$(C)=A$(A):A$(A)=A$(C-1): NEXT C: BEEP 1: WAIT
    120:FOR C=1 TO 40: PRINT SRT$ (C);":";A$(C): NEXT C