Author Topic: Welcome to the SmallBASIC board  (Read 4116 times)

B+

  • Hero Member
  • *****
  • Posts: 799
    • View Profile
Re: Welcome to the SmallBASIC board
« Reply #15 on: 11. September 2018, 16:27:52 »
Is it a completely re-written version of this interpreter? I think I did try Small Basic in the past, but this version seems to be much better (or I'm just getting old and don't remember things correctly ;)).

SmallBASIC, not MS Small Basic, did go through a radical change with IDE going from a normal one to one accessed from right mouse clicks only (after a file is loaded from Navigation screen).

There is an opening screen from which to select files or folders to run or edit, I call the navigation screen, there is another screen to start new files, save as files, rename files... the other functions of a file dialog besides selecting a file to load for run or edit.

SmallBASIC (not MS Small Basic)  http://smallbasic.github.io

Or get if from GooglePlay for your Android device. Oh for Android, right mouse clicks are simulated by tapping the tiny 3 vertical dots in lower right of screen (unless that was changed since last I looked).
« Last Edit: 11. September 2018, 16:34:13 by B+ »

Tomaaz

  • Sr. Member
  • ****
  • Posts: 319
    • View Profile
Re: Welcome to the SmallBASIC board
« Reply #16 on: 11. September 2018, 22:16:56 »
SmallBASIC (not MS Small Basic)  http://smallbasic.github.io

I know the difference between these two (I don't consider MS Small Basic to be BASIC), but I remember a SmallBASIC version based on FLTK(?). Also, I use Geany with SmallBASIC. It's much easier and more comfortable to use.

B+

  • Hero Member
  • *****
  • Posts: 799
    • View Profile
Re: Welcome to the SmallBASIC board
« Reply #17 on: 11. September 2018, 23:01:36 »
Yes FLTK, F? Light Took Kit is gone as well as the normal IDE.

Development outside SmallBASIC edtor looses advantage of instant help F1?

Tomaaz

  • Sr. Member
  • ****
  • Posts: 319
    • View Profile
Re: Welcome to the SmallBASIC board
« Reply #18 on: 11. September 2018, 23:15:32 »
Development outside SmallBASIC edtor looses advantage of instant help F1?

That indeed may be an advantage for beginners. But for me the comfort of using Geany outweighs lack of a build-in help (I can still see error messages and use the documentation). But you know what is the best about SmalBASIC? It doesn't use sigils! :) And the set of build-in functions is quite impressive.

Tomaaz

  • Sr. Member
  • ****
  • Posts: 319
    • View Profile
Re: Welcome to the SmallBASIC board
« Reply #19 on: 11. September 2018, 23:25:58 »
And the arrays can hold values of a different type. And their size doesn't have to be explicitly declared. Ladies and gentleman - we have a very nice BASIC here! :)
« Last Edit: 11. September 2018, 23:27:56 by Tomaaz »

B+

  • Hero Member
  • *****
  • Posts: 799
    • View Profile
Re: Welcome to the SmallBASIC board
« Reply #20 on: 12. September 2018, 17:47:38 »
And the arrays can hold values of a different type. And their size doesn't have to be explicitly declared. Ladies and gentleman - we have a very nice BASIC here! :)

I am very eager to see what you might code with it. Maybe try something using << for array appending.

Code: [Select]
REM SmallBASIC
REM created: 12/09/2018

Dim shoppingList()
while 1
  input "Enter item for shopping list > ";item
  if item ="" then exit else shoppingList << item
wend
for i in shoppingList do ? i;", ";

B+

  • Hero Member
  • *****
  • Posts: 799
    • View Profile
Re: Welcome to the SmallBASIC board
« Reply #21 on: 12. September 2018, 17:51:50 »
Text rotation fun!
Code: [Select]
'text rotation fun.bas for SmallBASIC 0.12.11 (B+=MGA) 2017-02-02

'global variables
message = "abcdefghijklmnopqrstuvwxyz""
secWide = txtw(message) + 2
secHigh = txth(message) + 2
dim sect(secWide, secHigh) 'array to store message points
color rgb(200, 200, 200),0 : cls
rect 0, 0, secWide, secHigh, 9

? message
loadSect 0, 0 'load array
'debug checks
'for y = 0 to secHigh
'  for x = 0 to secWide
'    if sect(x, y) then pset x + 200, y + 200
'  next
'next
'input "OK ";ok

dim plasma(5, 3)
for i = 0 to 5
  plasma(i, 0) = rnd * rnd
  plasma(i, 1) = rnd * rnd
  plasma(i, 2) = rnd * rnd
next

cls
cx = xmax/2 : cy = ymax/2
while 1
  cls
  dp 0
  yaxis cx, cy/4, a, 2
  dp 1
  xaxis cx, 3*cy/4, a, 5
  dp 2
  rotate cx/2, cy, a, 1
  dp 3
  rotate 3*cx/2, cy, a -90, 2.5
  dp 4
  rotate cx, cy/2, -4*a + 90, 2
  dp 5
  rotate cx, 3*cy/2, 2*a + 180, 4.5
  showpage
  delay 10
  a = a + 1
  if a = 360 then a = 0
wend
pause

sub dp(i)
  color rgb(128 + 127*sin(plasma(i,0)*a), 128 + 127*sin(plasma(i, 1)*a), 128 + 127*sin(plasma(i, 2)*a))
end

sub loadSect(xstart, ystart)
  local x, y, p, black
  'these are all global
  black = rgb(100 ,100, 100)
  for y = 0 to secHigh
    for x = 0 to secWide
      p = POINT(xstart + x, ystart + y)
      if p < black then sect(x, y) = 1 '<== data from screen points
    next
  next
end

sub rotate(cx, cy, angle, scale) 'and scale
  local cax, cay, ra, cc, d, anew, ax,ay

  cax = secWide/2 : cay = secHigh/2  'array center
  for y = 0 to secHigh
    for x = 0 to secWide
      cc = sect(x,y)
      if (x-cax) <> 0  and cc <> 0 then
        d = ((x-cax)^2+(y-cay)^2)^.5
        anew = atan((y-cay)/(x-cax))
        if x-cax <  0 and y-cay  < 0 then anew = anew + pi+rad(angle)  '-x,-y
        if x-cax <  0 and y-cay >= 0 then anew = anew + pi+rad(angle) '-x,+y
        if x-cax >= 0 and y-cay  < 0 then anew = anew + rad(angle)    '+x,-y
        if x-cax >= 0 and y-cay >= 0 then anew = anew + rad(angle)   '+x,+y
        ax = d*cos(anew):ay=d*sin(anew)
        rect int(cx+ax*scale),int(cy+ay*scale) step scale+1, scale+1 filled
      end if
    next
  next
end

sub yaxis(cx, cy, angle, scale)
   local cax, cay, cc, ax,ay

  cax = secWide/2 : cay = secHigh/2  'array center
  for y = 0 to secHigh
    for x = 0 to secWide
      cc = sect(x,y)
      if cc <> 0 then
        ax = (x - cax)*cos(rad(angle)):ay= (y - cay)
        rect int(cx+ax*scale),int(cy+ay*scale) step scale+1, scale+1 filled
      end if
    next
  next
end

sub xaxis(cx, cy, angle, scale)
   local cax, cay, cc, ax,ay

  cax = secWide/2 : cay = secHigh/2  'array center
  for y = 0 to secHigh
    for x = 0 to secWide
      cc = sect(x,y)
      if cc <> 0 then
        ax = (x - cax) :ay = (y - cay) * sin( rad(angle))
        rect int(cx+ax*scale),int(cy+ay*scale) step scale+1, scale+1 filled
      end if
    next
  next
end 


B+

  • Hero Member
  • *****
  • Posts: 799
    • View Profile
Re: Welcome to the SmallBASIC board
« Reply #22 on: 12. September 2018, 17:55:08 »
Do you like chess?
Code: [Select]
'internet grabber by jasali  SmallBASIC 0.12.11 2018-02-13

open "chess-pgnfile.pgn" for output as #2
for i=1 to 20
  open "http://moodle.usm.md/endgame/getpgn.php?pid="+i as #1
  tload #1,p
  ?p:?#2,p
  close #1
next
close #2
pause 'for screen shot and scroll through screen


lettersquash

  • Newcomer
  • *
  • Posts: 7
    • View Profile
Re: Welcome to the SmallBASIC board
« Reply #23 on: 10. February 2019, 22:23:54 »
Hi Guys, this is my first post here. Thanks to all who have helped me get registered here - there was some glitch in the system somewhere - and thanks especially to Chris for continuing to work on "sb". It's a damn shame M$ ripped off the name, and I don't suppose your lawyers would be up to theirs. ;D Would it be worth changing the name to avoid the confusion? Projects change names all the time. Almost every hit when I search is for MS Small Basic, and they often don't specify that it's MS.

Anyway, I'm almost completely new to sb, just played around with it on my phone, tablet and now my Windows 7 PC. I've written BBC BASIC since the '80s (on an Acorn Electron), and now use BBC for Windows (BB4W) and AutoHotkey, just for things I want to use myself, or for fun. Profit would be nice.

Over the years I've looked at a few other BASICs, but not found any that grabbed me, or I found issues with them, or something about them just didn't fit. I tried sb expecting it to disappoint too, but it hasn't. I'm really impressed with it.

One thing I'm puzzled about is the different files in the installation. sbasicg.exe and sbasicg64 are presumably 32-bit and 64-bit versions, are they? I thought at first that sbasic.exe would run and choose the right version, but it reports the missing file, libstdc++-6.dll and the other, sbasicw.exe starts a web server in a console window, but I've no idea how to use it or what I'd use it for. It also triggered some warning about certain features being blocked for security reasons. I didn't find anything online about installing sb.

Should I run sbasicg64.exe on my 64-bit Windows, and is there anything I need to take care with between them when coding?

Cheers

B+

  • Hero Member
  • *****
  • Posts: 799
    • View Profile
Re: Welcome to the SmallBASIC board
« Reply #24 on: 11. February 2019, 01:21:12 »
Hi Guys, this is my first post here. ...

Should I run sbasicg64.exe on my 64-bit Windows, and is there anything I need to take care with between them when coding?

Cheers

Welcome lettersquash!

I use sbasic64.exe on my 64-bit Windows 10 laptop. Do you know how to find SB files in Roaming? Might be handy to make a copy of a working set of settings.txt

lettersquash

  • Newcomer
  • *
  • Posts: 7
    • View Profile
Re: Welcome to the SmallBASIC board
« Reply #25 on: 11. February 2019, 01:58:42 »
Cheers for that B+, and thanks for the welcome. I've found it and made a copy. I don't know where the settings would be editable other than in Roaming though - I don't see a link to set anything in the program.

BTW, I love the text rotation fun, that's a clever piece of coding, but what does the line rect 0, 0, secWide, secHigh, 9 do at the end of the global variables section? It seems like it ought to be drawing a rectangle in colour 9, but I can't see one or get it to be seen, even when I mess about with it - change the colour, position, add filled to it, etc.

B+

  • Hero Member
  • *****
  • Posts: 799
    • View Profile
Re: Welcome to the SmallBASIC board
« Reply #26 on: 11. February 2019, 02:20:00 »
Text rotation fun? You will have to remind where that's at, not on-line or samples, from here at Retro?

ah! here: http://retrogamecoding.org/board/index.php?topic=630.msg4695#msg4695

I have to refresh my memory...

OK
Code: [Select]
'global variables
message = "abcdefghijklmnopqrstuvwxyz""
secWide = txtw(message) + 2
secHigh = txth(message) + 2
dim sect(secWide, secHigh) 'array to store message points
color rgb(200, 200, 200),0 : cls
rect 0, 0, secWide, secHigh, 9

? message
input "ok" ;wate  'added this because I probably deleted it when everything was working correctly

This was a check to see that I got the box dimensions correctly, that all the text was fitting in the Load Section.

Oh heck! It's here in this thread too! ;-))
« Last Edit: 11. February 2019, 02:36:48 by B+ »

B+

  • Hero Member
  • *****
  • Posts: 799
    • View Profile
Re: Welcome to the SmallBASIC board
« Reply #27 on: 11. February 2019, 02:47:17 »
Here is another one from BP.org (I think), still works! I think this is my own handmade font.
Code: [Select]
'SB rotation.bas for SmallBASIC 0.12.2 [B+=MGA] 2016-04-11

cx=xmax/2:cy=ymax/2
secwide=275
sechigh=50
dim sect(secwide,sechigh)
sz=50
color 15,0:cls
post 18,8,sz,15,"SmallBASIC"
getsec 0,0
color 15,4:cls
rotate
pause

'scale for 1x2 cells
sub post(x,y,scale,fore,mess)
  local lm,i,c,p1,p2,p3,p4,px,gf
  thick=1/40*scale
  dr=1/6*scale-.5*thick
  gf=.04*scale
  color fore
  p1=.16*scale : p2=.32*scale : p3=.48*scale : p4 =.64*scale
  lm=len(mess) : py=y+.5*thick
  if lm*scale*.5+x-xmax>0 then Beep 'draw it anyway
  for i=1 to lm
    c=mid(mess,i,1)
    px=x+(i-1)*scale*.5+.5*thick
    select case c
    case "a":ac px+p1,py+p3,0,360:lx=px+p2:ly=py+p2-gf:tl 0,p2:tl 0,2*gf
    case "l":lx=px+p1-gf:ly=py:tl gf,0:tl 0,p4:tl gf,0:tl -2*gf,0
    case "m":lx=px:ly=py+p2:tl 0,p2:lx=px+p1:ly=py+p4:tl 0,-p2:tl -p1,p1:lx=px+p2:ly=py+p4:tl 0,-p2:tl -p1,p1
    case "A":lx=px:ly=py+p4:tl p1-gf,-p4:tl 2*gf,0:tl p1-gf,p4:lx=px+p1-2*gf:ly=py+p2:tl p1,0
    case "B":ac px+p1,py+p1,270,450:ac px+p1,py+p3,270,450
             lx=px:ly=py:tl 0,p4:tl p1,0:lx=px:ly=py+p2:tl p1,0:lx=px:ly=py:tl p1,0     
    case "C":ac px+p1,py+p1,180,320:ac px+p1,py+p3,40,180:lx=px:ly=py+p1:tl 0,p2   
    case "I":lx=px+p1*.5:ly=py:tl p1,0:lx=px+p1*.5:ly=py+p4:tl p1,0:lx=px+p1:ly=py:tl 0,p4
    case "M":lx=px:ly=py+p4:tl 0,-p4:tl p1,p2:tl p1,-p2:tl 0,p4
    case "S":ac px+p1,py+p1,90,360:ac px+p1,py+p3,270,540
    end select
  next
end

'ac is for arc, x,y is radius center, das=degree angle start, dae=degree angle end
sub ac(x,y,das,dae)
  'note dr, drawing radius has to be global, use COLOR globally sets color
  'note thick also made globals by POST sub
  local a,x1,y1,stepper
  if dr then
    if int(thick)=0 then stepper=1/(dr*pi) else stepper=(thick/2)/(dr*pi/2)
    for a=das to dae step stepper
      x1=dr*cos(rad(a)) : y1=dr*sin(rad(a))
      if int(thick)<1 then  pset x+x1,y+y1 else circle x+x1,y+y1,thick filled
    next
  fi
end

'tl stands for thick line in the LINE STEP x,y format
sub tl(stepx,stepy) 'tl=thickline 
  'lastx, lasty globals for last drawn position
  'thick has to be global
  'note thick=0 still draws a line, use COLOR so line is drawn from this global
  local length,dx,dy,i
  length=((stepx)^2 +(stepy)^2)^.5
  if length then
    dx=stepx/length : dy=stepy/length
    for i=0 to length
      circle lx+dx*i,ly+dy*i,thick filled
    next
  end if
  lx=lx+stepx : ly=ly+stepy
end

sub getsec(xstart,ystart)
  local x,y
  'these are all global
  for y=0 to sechigh
    for x=0 to secwide
      sect(x,y)=POINT(xstart+x,ystart+y) '<== data from screen points
    next
  next
end

sub rotate 'and scale
  local cax,cay,ra,cc,d,anew,ax,ay
  dx=(xmax/secwide)/720 :dy=(ymax/sechigh)/720
  cax=secwide/2:cay=sechigh/2  'array center
  for i=1 to 721
    cls
    for y=0 to sechigh
      for x=0 to secwide
        cc=sect(x,y)
        if (x-cax)<>0 and cc<>0 then
          d=((x-cax)^2+(y-cay)^2)^.5
          anew=atan((y-cay)/(x-cax))
          if x-cax<0 and y-cay<0 then anew=anew+pi+rad(ra)  '-x,-y
          if x-cax<0 and y-cay>=0 then anew=anew+pi+rad(ra) '-x,+y
          if x-cax>=0 and y-cay<0 then anew=anew+rad(ra)    '+x,-y
          if x-cax>=0 and y-cay>=0 then anew=anew+rad(ra)   '+x,+y
          ax=d*cos(anew):ay=d*sin(anew)
          cc=sect(x,y)
          rect cx+ax*i*dx,cy+ay*i*dy step i*dx,i*dy filled
        end if
      next
    next
    ra+=1
    ra=ra%360
    showpage
    delay 10
  next
end

Nope it was from here: http://retrogamecoding.org/board/index.php?topic=439.0

I sped up the display, in the above code. Very appropriate for this thread. :)
« Last Edit: 11. February 2019, 02:54:17 by B+ »

lettersquash

  • Newcomer
  • *
  • Posts: 7
    • View Profile
Re: Welcome to the SmallBASIC board
« Reply #28 on: 11. February 2019, 03:02:04 »
Yeah, sorry I forgot to say where the code was I was referring to.  ::) ...neat.

chrisws

  • Moderator
  • Newcomer
  • *****
  • Posts: 25
    • View Profile
Re: Welcome to the SmallBASIC board
« Reply #29 on: 12. February 2019, 10:52:03 »
Hi lettersquash,

Welcome to the forum!

> Would it be worth changing the name to avoid the confusion?
I'm not completely averse to that idea, but I'm not sure what Nicholas thinks about it. I guess if someone said, here's a new name, new icon, new marketing stuff along with some legal protection for the name - we probably wouldn't say no.

> One thing I'm puzzled about is the different files in the installation. sbasicg.exe and sbasicg64 are presumably 32-bit and 64-bit versions, are they?
Yes 32 and 64 bit variations. There are potential issues with large floating point numbers in the 32 bit build. Good to hear the 64 bit one is working for you, so just use that one. The web server version executes requested .bas files then returns the results using javascript graphics commands.  The other exe is a command line version. Just use what works and ignore the rest.

I made a "getting started" section on the android page, This more or less also applies to the desktop version:

https://smallbasic.github.io/pages/android.html

Cheers,
Chris