## Tiny Craft Basic Interpreter

Announce and discuss the progress of your various programming-related projects...programs, games, websites, tutorials, libraries...anything!

Moderators: Pete, Mods

bongomeno
Veteran
Posts: 263
Joined: Wed Dec 10, 2008 9:08 am
Location: Arizona
Contact:

### Tiny Craft Basic Interpreter

I have just released my own Tiny Basic written in QuickBasic.
It's called Tiny Craft Basic and is the DOS version of Craft Basic.
It has a line mode editor and aims to be very similar to classic Tiny Basic.

Homepage: http://www.lucidapogee.com/forum/viewtopic.php?p=4

Here's it's example programs.

Code: Select all

``````10 cls
20 print "Solve For Quadratic Roots"
30 input "a: ",a
40 input "b: ",b
50 input "c: ",c
60 print "Roots: ",(-1*b+sqrt(b^2-4*a*c))/(2*a),comma," ",(-1*b-sqrt(b^2-4*a*c))/(2*a)
70 shell "pause"
``````

Code: Select all

``````5 cls
10 print "NIM"
20 let h = int(rnd * 12) + 12
30 print "There are ", h ," tokens remaining."
40 input "How many would you like to take? ", t
50 if t > 3 or t < 1 then 140
60 if h - t < 0 then 160
70 let h = h - t
80 if h = 0 then 180
90 let t = 4 - t
91 if h < 15 then 93
92 let t = 3
93 if h > 3 then 100
94 let t=h
100 print "I will take ", t ," tokens."
110 let h = h - t
120 if h = 0 then 200
130 goto 30
140 print "You must take between 1 to 3 tokens."
150 goto 40
160 print "You cannot take that many. There's only ", h ," left."
170 goto 40
180 print "Congratulations. You got the last token."
190 goto 210
200 print "I got the last token. I win. Better luck next time."
210 shell "pause"
``````

Code: Select all

``````10 cls
20 input "Temperature in Kelvin: ", k
30 let c = k + 273
40 let r = ( 9 * k ) / 5
50 let f = r + 460
60 print c, " Celsius"
70 print f, " Fahrenheit"
80 print r, " Rankine"
90 shell "pause"
``````

Code: Select all

``````10 cls

20 let r = int(rnd * 100) + 1

30 print "hilo game"
40 print "guess the nusmber between 1 and 100"

50 rem loop

60 let t = t + 1

70 input "guess: ", g

80 if g <> r then 110

90 print "you guessed it in ", t ," tries."
100 goto 220

110 rem endif

120 if g > r or g < 1 then 140

130 print "too low"

140 rem endif

150 if g < r or g > 100 then 170

160 print "too high"

170 rem endif

180 if g >= 1 and g <= 100 then 200

190 print "invalid guess"

200 rem endif

210 if g <> r then 50

220 shell "pause"
``````

Code: Select all

``````'fibonacci example

10 cls

20 let a = 1
30 let b = 1

40 print "Fibonacci Sequence"

50 rem loop

60 let s = a + b
70 let a = b
80 let b = s
90 let i = i + 1

100 print s

120 if i < 20 then 50

130 shell "pause"
140 end
``````

Code: Select all

``````1 shell "echo Data analasys results:>results.dat"

10 cls

20 print "Find how long it takes to generate 1 out of 100 a total of 10"
30 print "times while recording the results to a data file using shell."

40 shell "pause"

50 let c = 10

60 rem loop

70 let t = clock

80 rem loop

90 let r = int(rnd * 100) + 1

100 print "Random number: ", r

110 if r <> 1 then 80

120 let d = clock - t
130 let a = a + d

140 shell "echo ", d ,">>results.dat"

150 let c = c - 1

160 if c <> 0 then 60

170 let a = a / 10

180 shell "echo Average time = ", a ,">>results.dat"
190 print "done. check the file results.dat"

200 shell "pause"
210 end
``````

Code: Select all

``````5 cls

10 print "Timer"
20 input "Seconds? ", l

30 let t = clock

40 rem loop

50 let c = clock
60 print c

70 if c < t + l then 40

80 print "Alarm!"
90 shell "pause"
``````

Code: Select all

``````10 cls
20 let area = 0
30 let height = 0
50 let pi = 3.14
60 print "Find the surface area of a cylinder."
70 input "height: ", height
90 let area = radius * 2 * pi * ( radius + height )
100 print "Surface area: ", area
110 shell "pause"
``````
Last edited by bongomeno on Wed Mar 01, 2023 8:28 pm, edited 4 times in total.
Anthony.R.Brown
Veteran
Posts: 157
Joined: Thu Mar 27, 2014 1:03 pm

### Tiny Craft Basic Interpreter

Cool stuff bongomeno

I would love to wright my own BASIC but it's a bit beyond me

A.R.B
bongomeno
Veteran
Posts: 263
Joined: Wed Dec 10, 2008 9:08 am
Location: Arizona
Contact:

### Re: Tiny Craft Basic Interpreter

Let me know if I can help. I am not great at language development and have taken forever to get this far, but I would be happy to explain how things work. I can also provide study resources.

Tiny Craft Basic has been updated!
Fixed some small bugs and added more examples.
bongomeno
Veteran
Posts: 263
Joined: Wed Dec 10, 2008 9:08 am
Location: Arizona
Contact:

### Re: Tiny Craft Basic Interpreter

Here's a few more code examples that are now included in the download.
These particular examples are compatible with QBasic without any modification!

100 doors

Code: Select all

``````10 rem loop

20 let i = i + 1
30 print i * i, " open"

40 if i * i < 100 then 10

50 shell "pause"
60 end``````
factorials

Code: Select all

``````10 let f = 1

20 print "factorial"
30 input "enter an integer (1-34): ", n

40 rem loop

60 let f = f * n
70 let n = n - 1

80 if n > 0 then 40

90 print f
100 shell "pause"``````
bongomeno
Veteran
Posts: 263
Joined: Wed Dec 10, 2008 9:08 am
Location: Arizona
Contact:

### Re: Tiny Craft Basic Interpreter

Tiny Craft Basic has been updated! It also has a new homepage (in the OP). I brought some of the updates over from it's Windows counterpart.

The set of math functions is now standard BASIC syntax. I have updated the examples to reflect this.

For example, int(rnd*100)+1 returns 1 to 100.
Also look at the square root example in the OP.
bongomeno
Veteran
Posts: 263
Joined: Wed Dec 10, 2008 9:08 am
Location: Arizona
Contact:

### Re: Tiny Craft Basic Interpreter

Tiny Craft Basic has been updated! Still no version number yet.

I fixed a typo in the help, added more examples, and more functions/keywords.

The new keyword TAB allows the insertion of tabs in print formatting. This allows for nicely spaced consecutive printing.

I will be adding this tab keyword to regular Craft Basic in the next version (1.6).

Here's the new TinyCB examples. The Tau one shows the new TAB keyword in use.

Code: Select all

``````1 'https://rosettacode.org/wiki/Tau_number

10 let count = 0
20 let num = 0
30 let modulus = 0
40 let nums = 100
50 let tau = 0

60 rem do

70 let count = count + 1
80 let tau = 0
90 let modulus = 1

100 rem do

100 if count mod modulus <> 0 then 130

120 let tau = tau + 1

130 rem endif

140 let modulus = modulus + 1

150 if modulus < count + 1 then 100

160 if count mod tau <> 0 then 190

170 let num = num + 1
180 print count, tab,

190 rem endif

200 if num < nums then 60
``````

Code: Select all

``````1 'https://rosettacode.org/wiki/Babbage_problem

10 print "calculating..."

20 let n = 2

30 rem do

40 let n = n + 2

50 if (n ^ 2) % 1000000 <> 269696 then 30

60 print "The smallest number whose square ends in 269696 is: ", n
70 print "It's square is ", n * n
``````