-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Announcing Visual Small Basic #172
Comments
@nonkit
And to support the dot syntax, the designer will add some notation comment at the beginning of the file. This is the code that will be generated to design a simple calculator:
Note that I can define the controls without the need of xaml file, (or beside it, if I want to extend the design):
All the above code (including the notation), should be separated in a
Note that sample is functional now in my modified SB IDE in sVB repo, and you can find it in the samples folder. Note that I am using a fast dirty parsing code to support the dot syntax, and I think this should be be better written in the compiler parser. I've just proven that it doesn't need big changes in the compiler or runtime. It just a lowering stage that kicks in if the Obj doesn't exist but we know what is the real object is. I can generalize my approach by getting rid of the FormName first param, and supply it as a property, and decorate the The last thing I hope, is that the compiler allow this syntax to have better support for binding object names with their classes: I hope you can see the potential of such suggestions. I think it will make SB easier and more powerful. Irrelevant Note: |
@kmelmon @EdPrice-MSFT @AndrewCook When you switch to the Form code tab, you will see the auto generated SB code, and you can just run it, to see the form in run time. |
@nonkit @kmelmon @EdPrice-MSFT @AndrewCook
I think this is more kid-friendly than manually typing string color names, or their hex representations. And I have an idea to ease the use of the Color.GetName method. We can mark methods and properties with the actual type of the primitive. For example: in the Control module, we can define the GetBackColor like this: <ReturnType(NameOf(Color))>
Public Function GetBackColor(formName As Primitive, controlName As Primitive) As Primitive
End Function So, the compiler now knows that ther return value related to the color module, and hence can allow this syntax: BackColor marked as Color, so, this syntax says:
Which makes using liberties too hard. |
Interesting sample: Use the form designer to add a textBox and a button, then add this code after the generated SB code:
Things will be a bit nicer if we allow the syntax (the way I explained b4): |
Hi @VBAndCs, this is just for your information. LitDev's Small Basic Prime has Shapes Editor that we can also create controls visually. |
@nonkit
ToDo:
You can say that sVB 1.0 will be ready for kids in a few days. |
sVB is a release candidate now. |
I just published vSB 1.0-final. The form designer has only 4 controls now but it will have more soon. I also improved the SB compiler and added new code features:
You can use the x = {1, 2, 3} Nested initializers are also supported when you deal with multi-dimensional arrays: y = {"a", "b", {1, 2, 3}} You can also use vars inside the initializer, so, the above code can be rewritten as: y = {"a", "b", x} And you can send an initializer as a param to a function: TextWindow.WriteLine({"Adam", 11, "Succeeded"})
SB uses
Sub Print(Name, Value)
TextWindow.WriteLine("Name=" + Name + ", Value=" + Value)
EndSub And call this sub like this: Print("Distance", 120) Note that you can use
Function Sum(x, y)
Return x + Y
EndFunction And you can use it like this: x = Sum(1, 2)
So, as a good practice:
|
I just released Visual Small Basic v1.2 And I made a Cars game sample. It is just a prototype as I want kids to complete it themselves. |
One simplification rule I added to vSB is to treat any variable name that starts or ends with a control name as an object of this control. In the Cars game, you can see code like this:
carLabel is treated as a Label object, so, sVB provides auto completion after writing
Which will be lowered to:
This will make it work like dynamic in C# and VB.NET :) |
sVB now allows using the dictionary lockup operator (
It also allows using _ to split lines into multi sub lines. But the _ is not needed after some symbols like Sub Add (
n1, ' The first number
n2 ' The second number
)
End sub sVB editor formats such lines very well, and also applies some pretty listing to adjust spaces between tokens to format the code as expected. |
sVB 2.0 is released. It can create a multi form project with a common Global .sb module where you can declare global variables and subroutines that can be used from any form in the project via the Global. prefix, such as Globla.MyFuncution(). |
sVB v2.3 can create a code library!
Name = Dialogs.InputBox("Enter your name") So, now you can create reusable code, and write your own libraries for sVB. In the past, this was available only by using C# and VB.NET to create SB and sVB libraries! |
sVB v2.5 is ready to create productive desktop apps:
fileName = File.OpenFileDialog ({
{"Text Files", "txt", "rtf"},
{"Docs", "doc"}
}) For an example, see how these methods are used to open and save files in the
Font = Desktop.ShowFontDialog(Me.Font)
Me.FontName = Font!Name
Me.FontSize = Font!Size In the above example, you see that the ShowFontDialog has a parameter that receives an array containing the initial font properties. To make this easy, each control now has a Font property that returns an array with the font properties. You can also use this property to change font properties of the control in one step: font = Desktop.ShowFontDialog(Me.Font)
If font <>"" Then
Me.Font = font
EndIf And to make this even easier, each control has a
Ther first argument is the name of the child form (and the auto completion list will offer the names of the forms for you), and the second param is an extra data that will be passed to the ArgsArr property in the child form.
Create an external library for sVB:sVB can use external libraries created for Small Basic (like LitDev). Just insert those libraries dll files in the Lib folder of sVB and you are ready to go!
For more info, see the Now we can announce sVB as a mature productive dssktop programming language, and you can use it to build interesting apps. Have fun. |
Write and run unit tests in sVB v2.6!sVB makes it easy to write unit tests. Every form can define test functions among its normal function, and you can run them all easily just by calling the
The UnitTest Library:To make things more easier, sVB samples folder contains the UnitTest project, which is used to create the
For an example on how to use this method, see the tests written in the
Now when you select the test form and run the project, all the tests in all forms of the project will be run, and you will see the error report (if any) in the textbox, so you can fix any errors.
Note that I kept the UnitTest lib out of the Small Visual Basic Library, so you can modify its sVB source code, in case you want to add more Assert methods, or want to change the format of the result message. |
sVB 2.8.1 is released, and this is its installer. It contains the sVB reference book, which is also published on google drive. |
Edit: I just released Visual Small Basic v1.2. See the readme.
I think small basic needs a mini win forms framework, and a form designer, so in become Visual Small Basic, close to Visual basic 6.
Starting learning programming by graphics is hard as it involves some math. dragging some buttons and textboxes will be more fun, and the tool box can contain some geometric shapes and a timer, which will make many fantastic things.
By the way, where is the repo for the SB desktop IDE?
The text was updated successfully, but these errors were encountered: