Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - B+

Pages: [1] 2 3 ... 27
1
Code and examples / Re: DJPeter Math Solver in o2
« on: 19. July 2017, 16:11:01 »
I thought that most BASICs had some sort of EVAL function built in that can evaluate pretty much any expression you care to give it? I know Sinclair BASIC back in '82 (and possible as far back as '80) definitely had one.

I thought a version of the Quick Basic (QB) line had EVAL back in the 90's because I remember that from the one I purchased (for compiling stand alones) or in VB for MS DOS from that time. Apparently it has gone missing in all free BASICs from that line of evolution including Free Basic, QB64 and it's fork and JB. JB doesn't have it nor is it planned for the long awaited JB 2.0 that Carl has recently announced. It is in Liberty Basic and maybe the LB Booster (I think, if Richey is still looking in he might verify.) SmallBASIC has the work around but it's not the same as build-in.

BTW Richard's sweet simple version of EVAL with () posted in a thread called Basic in a Basic at the JB forum has been disappeared quite mysteriously and without explanation along with the entire thread! It disappeared the same day Richard posted so might be part of the on going feud between Richard and Rod (or is Rod acting as Carl's minion?) or, of course, another reason entirely! I wonder how much Carl is aware of Rod' censorship. In whose vision is the forum being molded?

(edits right after post for clarity and information)

2
Code and examples / Re: DJPeter Math Solver in o2
« on: 17. July 2017, 23:01:37 »

3
Code and examples / Re: XML Parser
« on: 08. July 2017, 16:43:17 »
I had an idea of using an associative array as a keyed file system index with Script BASIC's record based file I/O. The only thing I'm missing is a way to traverse the keys in sorted order forward and back. Direct key access is already covered. Any ideas?

Hi John,

If your inquiry is addressed to me, I have to say sorry there are too many technical phrases in the above quote that are not part of my experience to give ideas.

I have heard of this term: "associative array", interestingly enough, from someone at FB forum who was commenting on something they found at ScriptBasic forum.

"a keyed file system index"
"Script BASIC's record based file I/O"
"traverse the keys in sorted order forward and back"

Jargon talk Yikes! but I will take a stab at last item with a question.

Isn't the point of a key / value structure (like a hash table?) to get away from having to sort things out?

 
APPEND: Dang! I missed your July 4 EDIT, the above reply was made not having read the new link in that edit.

4
Code and examples / Re: Spirograph
« on: 05. July 2017, 16:21:18 »
Hey jbk,

That is gorgeous! Thanks :)

That Squares thread is gigantic + humongous, I bet it has more such golden nuggets. Maybe I will do some mining when don't have a project going.

Or someone could start a highlights museum... hmm


5
Code and examples / Re: XML Parser
« on: 04. July 2017, 16:54:22 »
:) Yes, that's the idea!

Can you reverse the process eg list all the keys that have the value "bee" or LIKE "bee" in different ways?

BTW, nice Help Link "HASH", I should read it before asking questions ;-))

6
Code and examples / Re: It's the 4th, have a blast!
« on: 04. July 2017, 06:35:08 »
Code: [Select]
'fireworks 3.bas SmallBASIC 0.12.2 [B+=MGA] 2015-05-09
'fireworks 2.bas 2016-05-05 now with Gravity, Newtonian bounce, smoke debris
'fireworks 3.bas try with map variables make bursts around a central point


flare_max = 300 : debris_max = 5000 : debris_stack = 0
dim flare(flare_max)
dim debris(debris_max)

sub NewDebris(i)
  local c
  debris(i).x = rnd * xmax
  debris(i).y = rnd * ymax
  c = rnd * 255
  debris(i).c = rgb(c, c, c)
end

while 1
   rnd_cycle = rnd * 30
   loop_count = 0
   burst.x = .75 * xmax * rnd + .125 * xmax
   burst.y = .5 * ymax * rnd +.125 * ymax
   repeat
      cls
      'color 14 : locate 0,0: ? debris_stack; " Debris" 'debug line
      for i=1 to 20   'new burst using random old flames to sim burnout
         nxt = rnd * flare_max + 1
         angle = rnd * 2 * pi
         flare(nxt).x = burst.x + rnd * 5 * cos(angle)
         flare(nxt).y = burst.y + rnd * 5 * sin(angle)
         angle = rnd * 2 * pi
         flare(nxt).dx = rnd * 15 * cos(angle)
         flare(nxt).dy = rnd * 15 * sin(angle)
         rc = int(rnd * 3)
         if rc = 0 then
            'flare(nxt).c = 12 'patriotic theme
            flare(nxt).c = rgb(255, rnd * 255, 0)
         elseif rc = 1
            'flare(nxt).c = 9 'patriotic theme
            flare(nxt).c = rgb(100 + rnd * 155, 100 + rnd * 155, 220)
         else
            flare(nxt).c = 15
         endif
      next
      for i = 0 to flare_max
         if flare(i).dy then 'while still moving vertically
            line flare(i).x, flare(i).y step flare(i).dx, flare(i).dy, rgb(98, 98, 98)
            circle step flare(i).dx, flare(i).dy, 1, 1, flare(i).c filled
            flare(i).x += flare(i).dx
            flare(i).y += flare(i).dy
            flare(i).dy += .4  'add  gravity
            flare(i).dx *= .99 'add some air resistance
            if flare(i).x < 0 or flare(i).x > xmax then flare(i).dy = 0  'outside of screen
            'add some spark bouncing here
            if flare(i).y > ymax then
              if abs(flare(i).dy) > .5 then
                flare(i).y = ymax : flare(i).dy *= -.25
              else
                flare(i).dy = 0
              fi
            fi
          fi
      next
      for i = 0 to debris_stack
        pset debris(i).x, debris(i).y, debris(i).c
        debris(i).x += rnd * 3 - 1.5
        debris(i).y += rnd * 3.5 - 1.5
        if debris(i).x < 0 or debris(i).y < 0 or debris(i).x > xmax or debris(i).y > ymax then NewDebris(i)
      next
      showpage
      delay 2
      loop_count += 1
    until loop_count > rnd_cycle
    if debris_stack < debris_max then
      for i = 1 to 20
        NewDebris i + debris_stack
      next
      debris_stack += 20
    fi
wend


7
Code and examples / It's the 4th, have a blast!
« on: 04. July 2017, 06:33:15 »
Code: [Select]
' more particles.bas  SmallBASIC 0.12.8 [B+=MGA] 2016-11-18
' from: more particles.sdlbas [B+=MGA] 2016-11-18
' attempt to simulate alpha effect

func rand(n1, n2)
  if n1 > n2 then hi = n1 : lo = n2 else hi = n2 : lo = n1
  rand = (rnd * (hi - lo + 1)) \ 1 + lo
end

def rdir = iff(rnd < .5, -1, 1)

numPoints = 100

dim  vx(numPoints), vy(numPoints), clr(numPoints), life(numPoints), lifeTime(numPoints)

wantColor = 1  'colorize on/off, 1 or 0

for i = 0 to numPoints
  initPoint(i)
next
while 1
  cls
  for p = 0 to numPoints
    life(p) += 1
    if life(p) = lifeTime(p) then
      initPoint(p)
    else
      'redraw the whole arc of particle path
      x0 = xmax/2 : y0 = .35 *  ymax : drop = vy(p)
      for i = 0 to life(p)
        if wantColor then
          select case clr(p)
          case 0
            r = 1: g = 0 : b = 0
          case 1
            r =1 : g = 1 : b = 1
          case 2
            r =0 : g = 0 : b = 1
          case 3
            r = 0 : g = .7 : b = 0
          case 4
            r= 1: g = 1 : b = 0
          case 5
            r = 1 : g = 0 : b = 1
          case 6
            r = 1 : g = .6 : b = 0
          end select
          if r = 0 then
            r = 3 * (life(p) - i)
          else
            r = i/life(p) * 255 * r
          end if
          if g = 0 then
            g = 3 * (life(p) - i)
          else
            g = i/life(p) * 255 * g
          end if
          if b = 0 then
            b = 3 * (life(p) -1)
          else
            b = i/life(p) * 255 * b
          end if
          color rgb(r, g, b)
        else
          m = i/life(p) * 255
          color rgb(m, m, m)
        end if
        xnext = x0 + vx(p)
        drop += .1
        ynext = y0 + drop
        radius = i/life(p) * 8
        circle xnext, ynext, radius filled
        x0 = xnext
        y0 = ynext
      next
    end if
  next
  showpage
wend

sub initPoint(p)
  vx(p) = rnd * 7  * rdir
  vy(p) = rnd * 7  * rdir
  clr(p) = rand(0, 6)
  life(p) = 0
  lifeTime(p) = rand(30, 70)
end

8
Code and examples / Re: XML Parser
« on: 03. July 2017, 15:59:45 »
Python dictionary structure is a variable/value pairing like what might be used for properties. As a common acquaintance of ours once explained it, instead of having an array with numeric indexes, you have an array of string indexes.

For BASIC sim of the dictionary structure, I would use strings and I would use one delimiter for the var/value pair, probably = sign, and another delimiter for the pairings probably a space.

9
Code and examples / Re: XML Parser
« on: 03. July 2017, 15:34:37 »
Code: [Select]
' like test.bas SmallBASIC 0.12.9 (B+=MGA) 2017-07-03
dim hello(), world()
open "Word List.txt" for input as #1
while eof(1)=0
  lineinput #1, fline
  two = left(fline,2)
  if two <> lasttwo then
    locate 1, 1 : ? space(20) : locate 1, 1 : ? two : lasttwo = two
  fi
  if fline like "h*" then
    if fline like "h?ll?" then hello << fline : ? fline
  elif fline like "w*" then
    if fline like "w?r?d" then world << fline : ? fline
  fi
wend
close #1
cls

for h in hello
  for w in world
    ? h;" ";w,
    c++ : if c mod 6 = 0 then ?
  next
next
?
pause

10
Code and examples / Re: Spirograph
« on: 03. July 2017, 04:52:52 »
Wheels within wheels:
Code: [Select]
'Spirograph wheels within wheels.bas SmallBASIC 0.12.9 (B+=MGA) 2017-07-02

rO = ymax/2 - 10 ' fit screen radius of big circle
Ox = xmax/2
Oy = ymax/2
pIndex = 0
dim mark(4)
dim px(), py()
m = 0 : mark(0) = 0
for ir = 5 to 2 step -1
  rI = rO/ir       ' smaller circle that travels inside edge of larger
  OI = rO /rI      ' rate inner circle spins compared to angle on outer circle
  for a = 0 to 2 * pi step pi/360  'while the inner circle contacts outer at angle a
    cls
    circle Ox, Oy, rO, 1, 9
    'the origin of inner circle at same angle
    Ix = Ox + (rO - rI) * cos(a)
    Iy = Oy + (rO - rI) * sin(a)
    Ia = OI * a   'the angle of the inner points are OI * a on outer circle
    'draw line from origin of inner circle to outer edge
    color 12
    wheel Ix, Iy, rI, -Ia
    for i = 0 to pIndex-1
      pset px(i), py(i), 15
    next
    showpage
    delay 10
  next
  m++
  mark(m) = pIndex - 1
next
delay 2000
for j = 0 to m-1
  cls
  for i = mark(j) to mark(j+1)-1
    pset px(i), py(i), 15
  next
  ? "Press any..."
  showpage
  pause
next

sub wheel(x,y,r,a)
  local i, x1, y1, x2, y2, rI2, Ix2, Iy2, Ia2
  circle x, y, r
  for i = 1 to 12
    x1 = x + r*cos(i*2*pi/12 + a)
    y1 = y + r*sin(i*2*pi/12 + a)
    line x, y, x1, y1
    if i = 12 then
      x2 = x + r/2*cos(i*2*pi/12 + a)
      y2 = y + r/2*sin(i*2*pi/12 + a)
      px << x2
      py << y2
      pIndex = pIndex + 1
    fi
  next
  if r > 20 then
    rI2 = r / ir
    Ix2 = x + (r - rI2) * cos(a)
    Iy2 = y + (r - rI2) * sin(a)
    Ia2 = r / rI2 * a
    wheel Ix2, Iy2, rI2, -Ia2
  end if
end

11
Code and examples / Re: XML Parser
« on: 02. July 2017, 19:35:38 »
 :) Yes, you might see a Python like dictionary SIM using the LIKE keyword.


12
Code and examples / Re: XML Parser
« on: 02. July 2017, 13:32:04 »
Hey John,

After this challenge, I pulled out some code that was sitting on shelf for three months and finished it.
This challenge helped me clarify what I wanted that code to do.

So you never know what may become of an effort. ;)

And of course, I am always a fan of different ways to do something or how it might be done in different flavors or PLs.



13
Code and examples / Spirograph
« on: 01. July 2017, 19:39:45 »
Just got the mechanism worked out, here is first fancy up:
Code: [Select]
'Spirograph RO divided by 2 - 10 = RI.bas SmallBASIC 0.12.9 (B+=MGA) 2017-07-01

rO = ymax/2 - 10 ' fit screen radius of big circle
Ox = xmax/2
Oy = ymax/2
pIndex = 0
dim px(), py()
for ir = 2 to 10
  rI = rO/ir       ' smaller circle that travels inside edge of larger
  OI = rO /rI      ' rate inner circle spins compared to angle on outer circle
  for a = 0 to 2 * pi step pi/360  'while the inner circle contacts outer at angle a
    cls
    circle Ox, Oy, rO, 1, 9
    'the origin of inner circle at same angle
    Ix = Ox + (rO - rI) * cos(a)
    Iy = Oy + (rO - rI) * sin(a)
    Ia = OI * a   'the angle of the inner points are OI * a on outer circle
    'draw line from origin of inner circle to outer edge
    color 12
    wheel(Ix, Iy, rI, -Ia)
    for i = 0 to pIndex-1
      pset px(i), py(i), 15
    next
    showpage
    delay 10
  next
next
pause
sub wheel(x,y,r,a)
  local i, x1, y1, x2, y2
  circle x, y, r
  for i = 1 to 12
    x1 = x + r*cos(i*2*pi/12 + a)
    y1 = y + r*sin(i*2*pi/12 + a)
    line x, y, x1, y1
    if i = 12 then
      x2 = x + r/2*cos(i*2*pi/12 + a)
      y2 = y + r/2*sin(i*2*pi/12 + a)
      px << x2
      py << y2
      pIndex = pIndex + 1
    fi
  next
end

14
wait a moment ... ::)
you won  :o
it looks to me that pythoners won - flikifluke
with something like ...i dont know what is this
maybe i must ask someone on network45 ;D

if you ask me you are winner with nano - which looks like PL :D

Perhaps this announcement made at SmallBASIC forum is clearer:
Quote
SmallBasic wins the First Annual CLOCPL Contest
"BTW, flukiluke takes the cake for originality is my vote!"
youd perhaps be interested in judging the contest next year. (not a joke.)
this forums own bplus won the contest this year:
Originality: 4 out of 5 = 12
Simplicity: 3 out of 5 = 6 (4 out of 5 was considered, but it was on the fence.)
Brevity: 3 out of 5 = 6
Features: 5 out of 5 = 10
Documentation: 5 out of 5 = 5
12 + 6 + 6 + 10 + 5 = 39:50
if the numbers seem weird (or just wrong,) theyre fully explained at the official results post: (bplus earned the victory with a first-year entry that perfectly demonstrates what the contest is about. luke was VERY CLOSE on his tail, and even in the "judges stands" it was unsure how it would go. it was basically a photo-finish, in scoring. we could definitely use more or new judges next year. that said, bplus was outstanding.)
I do think it was really close because flukiluke has much more skills than I. I was the one saying,
 "BTW, flukiluke takes the cake for originality is my vote!" because it was a really cool program!

15
 :) Since I won the contest I want to share my happiness with you here with my first (and only?) ever acceptance speech:

Quote
:) Hey an opportunity to give an acceptance speech!

Thanks to flukiluke for making this a contest so the judges had to work!
From their comments, I think they had to compare apples to oranges ;)

Thanks to Chris for providing a fun and powerful flavor of BASIC.

Thanks to Shian for his helpful example at SmallBASIC forum.

Thanks to figosdev who has led me down path of several adventures.

Thanks to Walter who welcomed us at his forum and his great enthusiasm to provide a sharing environment.

Thanks to all at forums where I have hung my pictures on the refrigerator door,
all who teach and learn with me, inspire, challenge and provide social support...
like Johnno with whom I have shared an imaginary cup of coffee almost daily!

Cybermonkey, what I said of Walter applies to you as well!

Pages: [1] 2 3 ... 27