Tiny Craft Basic Interpreter

Share your Craft Basic creations here.
Post Reply
admin
Site Admin
Posts: 67
Joined: Wed Feb 22, 2023 6:51 am

Tiny Craft Basic Interpreter

Post by admin »

There's an X86 DOS version of Craft Basic that is not actively updated. It's written in QuickBasic and has a line mode editor.
It's language and environment is essentially a variant of Tiny BASIC.

This thread is it's home.

Download it here:
https://www.lucidapogee.com/download.ph ... tinycb.zip

Rosetta Code:
https://rosettacode.org/wiki/Category:Tiny_Craft_Basic
admin
Site Admin
Posts: 67
Joined: Wed Feb 22, 2023 6:51 am

Re: Tiny Craft Basic Interpreter

Post by admin »

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
cguy
Posts: 9
Joined: Thu May 25, 2023 9:06 pm

Re: Tiny Craft Basic Interpreter

Post by cguy »

admin wrote: Fri Jun 30, 2023 6:22 pm 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.
This is really cool!

What BASIC is this intended for?

I was able to get it to compile with QB64(PE) and also FreeBasic.

FreeBasic complained about this line:

Code: Select all

			PRINT "Operator precedence -
It is missing the ending double quote.

The readme.txt notes:
Immediate mode is supported.
You may type print 2+10/2 without line numbers and it will execute.
And sure enough:

Code: Select all

print "Hello Word!"
Works!

if I try:

Code: Select all

print "Hello, Word!"
It apparently gets a little confused by the comma, as it then prints:
hell-1
But this is just a minor nit.
This is very cool! Good job! I like these tiny interpreters! Keep at it!
admin
Site Admin
Posts: 67
Joined: Wed Feb 22, 2023 6:51 am

Re: Tiny Craft Basic Interpreter

Post by admin »

This is really cool!

What BASIC is this intended for?

I was able to get it to compile with QB64(PE) and also FreeBasic.
Tiny Craft Basic is an attempt at creating a simple line mode BASIC interpreter. It uses RPN for expression evaluation and was pretty much the first project I started out with in my efforts to develop a programming language. It is very minimal only having the most essential commands, but has plenty of functions.

The parser and evaluator are the heart. They are also used in the Windows version of Craft Basic and FTC BASIC. I use them in my RPN calculator program and it will be used in the language I am currently developing, Commando Basic. FTC BASIC is a compiler and Commando Basic will be a tokenized interpreter whereas Craft Basic and Tiny Craft Basic are direct interpreters.

I am doing everything pretty much from scratch, reinventing the wheel to learn the most that I can. The result is I have made BASIC like languages with the goal of having the most important BASIC commands. My languages are like custom Tiny BASICs with bonus features.

FTCBASIC supports strings (to an extent) and Commando Basic does as well. I plan to add some string support to Craft Basic as well.
It apparently gets a little confused by the comma, as it then prints:
In Craft Basic and Tiny Craft Basic, print outputs may be combined using commas. To display a comma, use the COMMA keyword. There's also QUOTE and NEWLINE keywords to insert double quote or a new line.

Example

Code: Select all

PRINT "Hello", COMMA, " World! ", 2 + 10 / 2, NEWLINE, "and here is another line"
In this last update to Tiny Craft Basic, I added the TAB keyword to insert tabs. This allows for better print formatting. I will add this keyword to the next version of Craft Basic for windows. The TAB keyword replaces having both ; and , in PRINT statements.

Example

Code: Select all

10 PRINT i, TAB,
20 LET i = i + 1
30 IF i < 100 THEN 10
Attachments
tab.PNG
tab.PNG (31.73 KiB) Viewed 973 times
admin
Site Admin
Posts: 67
Joined: Wed Feb 22, 2023 6:51 am

Re: Tiny Craft Basic Interpreter

Post by admin »

I found that a bit of code was missing related to the new functions. Fixed that and added the missing quote you mentioned.

You can drag and drop the .bas examples on the .exe to run them. You may also type load examples\progname without using the .bas extension. The .bas is assumed.
Post Reply