We would like to build a community for Small Basic programmers of any age who like to code. Everyone from total beginner to guru is welcome. Click here to register and share your programming journey!


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
SmallBasic Open Edition
#1
Hi,

This project (SmallBasic Open Edition) is part of a larger whole, where the goal is to recreate Microsoft SmallBasic, at least in its main features.

The first phase of the project, which is exactly this, is to create the same classes as in SmallBasic: Text, Math, GraphicsWindow, and so on. The project is mostly complete, although types for variables, some small tests, and so on are still required.

Note: The classes Array, Flickr, and Dictionary have not been created.

Array is missing because I have not yet decided on the final way the future compiler will handle arrays. I have a couple of different solutions for this, but I haven’t had time to decide yet. 

Flickr is missing because I am simply not very familiar with this service, and their API is completely unknown to me. 

Dictionary is a class I’m not sure if I want to spend time on, at least not personally.

Unlike the original SmallBasic, Open Edition converts SmallBasic code into the C# programming language and compiles it afterward. This brings significant advantages in terms of memory management, speed, and extensibility.

Variables will function mostly the same way as in the original SmallBasic. This is made possible by C#’s dynamic. However, the idea is that variables will require a suffix of "$" at the end of their names. Not only does this make the programs easier to compile, but I also believe it helps distinguish variables and makes coding a bit easier.

The program that tokenizes and converts SmallBasic code into C# is also mostly done. However, at the moment, it's more like a pile of sticks rather than a well-designed and structured program, so its release will be more appropriate at a later time.

Example SmallBasic program:

Code:
' Example Smallbasic program
x$ = 1
y$ = 2
c$ = "Foo"
TextWindow.WriteLine(x$ + y$ + c$)
SayHello()
Goto MyLabel:
TextWindow.WriteLine("I'm never printed.")
MyLabel:
Program.End()
Sub SayHello
    TextWindow.WriteLine("Hello")
EndSub

Converted to C#:

Code:
// Converted as C#
namespace SmallBasicOpenEditionDll
{
    public static class SB_Program
    {
        // Declare dynamic variables (similar to Smallbasic's dynamic typing)
        public static dynamic x = 1;
        public static dynamic y = 2;
        public static dynamic c = "Foo";
        // Entry point of the program
        public static void Main()
        {
            // Equivalent of TextWindow.WriteLine(x$ + y$ + c$)
            TextWindow.WriteLine(x + y + c);
            // Call the method SayHello()
            SayHello();
            // This line will not be executed
            Goto MyLabel:
            TextWindow.WriteLine("I'm never printed.");
            MyLabel:
            Program.End();
        }
        // The equivalent of SmallBasic's subroutine 'SayHello'
        public static void SayHello()
        {
            TextWindow.WriteLine("Hello");
        }
    }
}

Note: I work with this while I am working with two job's and such, so this will not move forward in fast speed. Help is appreciated here. Let me know Smile
[-] The following 2 users Like KristianVirtanen's post:
  • AbsoluteBeginner, Scout
Reply


Messages In This Thread
SmallBasic Open Edition - by KristianVirtanen - 10-13-2024, 04:41 PM
RE: SmallBasic Open Edition - by KristianVirtanen - 10-13-2024, 08:55 PM
RE: SmallBasic Open Edition - by litdev - 10-14-2024, 08:35 AM
RE: SmallBasic Open Edition - by z-s - 10-14-2024, 09:02 AM
RE: SmallBasic Open Edition - by KristianVirtanen - 10-14-2024, 10:59 AM
RE: SmallBasic Open Edition - by z-s - 10-14-2024, 04:39 PM
RE: SmallBasic Open Edition - by KristianVirtanen - 10-14-2024, 05:57 PM
RE: SmallBasic Open Edition - by Scout - 10-15-2024, 09:11 AM
RE: SmallBasic Open Edition - by litdev - 10-15-2024, 12:46 PM
RE: SmallBasic Open Edition - by Scout - 10-15-2024, 03:44 PM
RE: SmallBasic Open Edition - by KristianVirtanen - 10-15-2024, 07:27 PM
RE: SmallBasic Open Edition - by KristianVirtanen - 10-18-2024, 08:41 AM
RE: SmallBasic Open Edition - by litdev - 10-18-2024, 12:21 PM
RE: SmallBasic Open Edition - by jrmrhrb00 - 10-18-2024, 03:52 PM
RE: SmallBasic Open Edition - by KristianVirtanen - 10-18-2024, 08:13 PM
RE: SmallBasic Open Edition - by z-s - 10-19-2024, 02:28 AM
RE: SmallBasic Open Edition - by litdev - 10-19-2024, 10:49 AM
RE: SmallBasic Open Edition - by KristianVirtanen - 10-19-2024, 12:53 PM
RE: SmallBasic Open Edition - by z-s - 10-19-2024, 03:47 PM
RE: SmallBasic Open Edition - by KristianVirtanen - 10-20-2024, 08:59 AM
RE: SmallBasic Open Edition - by KristianVirtanen - 10-25-2024, 08:54 PM
RE: SmallBasic Open Edition - by KristianVirtanen - 11-05-2024, 06:37 PM

Forum Jump:


Users browsing this thread: 5 Guest(s)