Author Topic: Craft Basic  (Read 1496 times)

Offline Gemino Smothers

  • BASIC Developer
  • Posts: 24
    • Lucid Apogee
Craft Basic
« on: July 07, 2023, 09:15:43 AM »
I was shy to post my work here, but I am more confident that it might be worth looking at now.

Several times throughout my years, I tried to write an expression evaluator and never had any success. About 8 months ago, I really pushed hard to get something done and came up with something using RPN. I made a calculator and BASIC interpreter.

These programs were initially written in QuickBasic. I am still updating them.

Tiny Craft Basic Interpreter written in QuickBasic: https://www.lucidapogee.com/forum/viewtopic.php?t=4

RPN Calc written in QuickBasic: https://www.lucidapogee.com/forum/viewtopic.php?t=28

Tiny Craft Basic is meant to be a simple line mode basic with the more minimal set of features. RPN Calc tries to be a scientific command line calculator.

Since then, I have also been developing Craft Basic for Windows or just Craft Basic. It's a direct interpreter like its line mode sibling. Written in Emergence Basic.

Craft Basic really just tries to be a minimal tiny BASIC with some bonus features including graphics and forms.

Craft Basic for Windows: https://www.lucidapogee.com/index.php?page=craftbasic

What's cool about this language is that everything you need is packed into one exe. All the other files are just for support. The language still works if all the other files are lost. Also, the syntax while limited is very easy to pick up.

One of the biggest limits is the lack of string support (I will be adding it in a future version release).

Some neat language features include the ability to use expressions with all FOR loop parameters including the step. DO/LOOP/LOOPWHILE/LOOPUNTIL is supported. BREAK works with FOR and DO loops. You may nest IF and ELSE. (although there's no ELSEIF or SELECT CASE)

I test my language with Rosetta Code tasks. There's already over 60 tasks complete. https://rosettacode.org/wiki/Category:Craft_Basic

Here's a preview of some Craft Basic code:
Code: [Select]
'https://rosettacode.org/wiki/Ultra_useful_primes

for n = 1 to 10

let k = -1

do

let k = k + 2
wait

loop prime(2 ^ (2 ^ n) - k) = 0

print "n = ", n, " k = ", k

next n

Code: [Select]
'https://rosettacode.org/wiki/Attractive_numbers

for x = 1 to 120

let n = x
let c = 0

do

if int(n mod 2) = 0 then

let n = int(n / 2)
let c = c + 1

endif

wait

loop int(n mod 2) = 0

for i = 3 to sqrt(n) step 2

do

if int(n mod i) = 0 then

let n = int(n / i)
let c = c + 1

endif

wait

loop int(n mod i) = 0

next i

if n > 2 then

let c = c + 1

endif

if prime(c) then

print x, " ",

endif

next x

Code: [Select]
'https://rosettacode.org/wiki/Draw_a_sphere

let j = 2

for i = 221 to 0 step j * -1

for k = -3.14 to 3.14 step .01

dot 221 + i * sin(k), 222 + 221 * cos(k)
dot 221 + 221 * sin(k), 222 + (i - 1) * cos(k)

wait

next k

let j = j + 1

next i

Offline Gemino Smothers

  • BASIC Developer
  • Posts: 24
    • Lucid Apogee
Re: Craft Basic
« Reply #1 on: August 03, 2023, 10:52:26 PM »
In the latest update for Craft Basic to version 1.6, there's new keywords, examples, and features.

The TAB keyword works along with the COMMA, QUOTE, and NEWLINE keywords for printing tabs in the output window.

Arrays may now be dimmed with multi line lists.

The recursion limit was raised. This ability is still limited.

The CONFIRM command provides an input dialog with a prompt, a yes button, and a no button. Yes returns 1 and no returns 0.

When defining variables, it is now optional to assign an expression or value. This way you don't have to type the = 0.

The ERASEARRAY command zeroes the contents of an array.

There's 5 new examples in version 1.6.
Top

Offline John

  • Forum Support / SB Dev
  • Posts: 3597
    • ScriptBasic Open Source Project
Re: Craft Basic
« Reply #2 on: August 05, 2023, 10:10:28 PM »
Is Craft Basic an open source project?


Offline Gemino Smothers

  • BASIC Developer
  • Posts: 24
    • Lucid Apogee
Re: Craft Basic
« Reply #3 on: August 06, 2023, 09:48:57 AM »
Craft Basic for Windows (written in Emergence Basic) is open source. Tiny Craft Basic for DOS (written in Quick Basic) is also open source.

Craft Basic is a direct interpreter, so execution is slow. It's main feature is expression evaluation.

Most of my software is open source.

There's one closed source project that I am currently developing called Commando Basic. It's a tokenized BASIC language that is similar, but faster than it's cousin Craft Basic. I am writing a "learn to program" book to go along with it. My goal is to release it as a commercial product. This will be my first attempt at doing such a thing. The price tag I have planned is $5.

Craft Basic will remain free and open source while I (attempt to) sell Commando Basic.
 
Many of the advancements I make with Craft Basic are going to Commando Basic and vice versa ass I am working on them at the same time. I plan to maintain these languages and provide support to the best of my ability.

Offline John

  • Forum Support / SB Dev
  • Posts: 3597
    • ScriptBasic Open Source Project
Re: Craft Basic
« Reply #4 on: August 06, 2023, 12:27:35 PM »
Oxygen Basic for Windows (16 & 32 bit) self compiling ASM BASIC compiler might make a good foundation for a BASIC interpreter.

Offline Gemino Smothers

  • BASIC Developer
  • Posts: 24
    • Lucid Apogee
Re: Craft Basic
« Reply #5 on: August 07, 2023, 11:46:36 AM »
I have seen Oxygen Basic around and find it fascinating. From the looks of things, it may be the best BASIC compiler available.

My reason for using Emergence is mostly personal. I grew up with it and told myself in 2020 that I wanted to become proficient with it. A few years later and I have done that. My greatest project with Emergence has been Craft Basic. Unfortunately I have found out the hard way that it's a slow compiler.

For my next project, I decided to try Free Basic. Commando Basic tokenizer and interpreter is being written in Free Basic while the IDE is in Emergence. Things were going pretty well at first. I eventually found my self berated over aking questing about -qb lang syntax. So I am having trouble implementing GUI and sound beyond some simple features.

The Free Basic community has all, but totally discouraged me, but after six months of development I am struggling to survive(off grid with little power) and cannot fathom rewriting everything just yet. Need to focus my day job or starve.

I decided that I would release Commando Basic version 1 as I have done it with -qb lang. Then in a later version I will rewrite with fblite syntax and add more GUI/sound features.

The thing is I would MUCH rather switch to Oxygen Basic, so I am torn. I know it would be worth the learning curve, but the time is something I don't have right now. So I either need to refrain from releasing Commando Basic until I do an Oxygen Basic rewrite or just release it written in Free Basic. It's a hard decision because I know if I release it written with Free Basic now, it may be too hard to port to Oxygen exactly as is without changing anything.

It's been driving me nuts. Regardless, I am still working on Commando Basic and look forward to releasing it.

I want to also add that while Commando Basic will be a commercial product with a book that I plan to get an ISBN for, there will be a free version available. The free version will only include the tokenizer, interpreter, reference manual, and examples. The free version will just not include the book or IDE. That way people may use the language without a paywall if desired enough.

Offline John

  • Forum Support / SB Dev
  • Posts: 3597
    • ScriptBasic Open Source Project
Re: Craft Basic
« Reply #6 on: August 07, 2023, 12:11:34 PM »
Charles Pegge is a brilliant programmer and has done an amazing job with O2. Being open source and self compiling gives you a lot of options how you use it. ScriptBasic has an extention O2 module that gives me FFI and virtual DLLs.