Version 0.5 is here!
The next installment of the Small Basic Community Previews is now available for download. Version v0.5 can be downloaded at: http://download.microsoft.com/download/C/A/F/CAF9E062-94D3-4003-80D9-44CDF7EC7BD9/SmallBasic.msi
This version adds more of the community requested features and bug-fixes, the full list of it is below:
- Arrays: Small Basic now has native support for arrays. Array keys are not limited to numbers, and the arrays themselves can be multidimensional. An example is:
people[1]["Name"]["First"] = "Carl"
people[1]["Name"]["Last"] = "Fredrickson"
people[1]["Age"] = 78- Uninitialized Variables: The Compiler now catches and reports as error, any variable that isn't initialized but is being used in the program. This makes it much easier to catch misspelt variables.
- Spanish localization: The UI and the API reference have been translated to Spanish, and is now available alongside English and French. The Guide will follow in a few hours.
- Environment Features:
* Find feature: Ctrl+F brings up the new Find dialog, F3 finds the next match
* Line and column indicator: At the bottom right of the editor is a line and column indicator
* Save As command + toolbar button
* Format Program command: Available from the context menu in the editor, this command reformats the entire program with the right indentation.
* Mouse click and scroll support for Intellisense list box - Under the hood: * A new attribute "HideFromIntellisense" which hides deprecated operations and properties from the Intellisense list
- Others: * Tons of bug fixes
* Smaller footprint (installer is now just 3.7MB)
* Setup now auto-detects presence of .Net framework 3.5 SP1
- 已編輯Vijaye RajiMSFT, 擁有者Tuesday, 16 June, 2009 20:15
- 已編輯Vijaye RajiMSFT, 擁有者Tuesday, 16 June, 2009 20:15
所有回覆
- Excellent! That Ctrl-F will keep me from using an external editor. The download is version 0.4 though, file compare matched. Maybe I was too quick on the draw...
- The release has been published and will slowly replicate among all servers.
Please refresh and try again - if necessary, you might have to clean out your cache, or wait for an hour or so before trying again. - Nice,
Installation is easy - just uninstall v0.4 first.
Some notes on the use of arrays in v0.5
Previously we used character strings to define arrays:
Array.SetValue("data" ,1,10) and value = Array.GetValue("data" ,1)
We now use:
data[1] = 10 and value = data[1]
We can now use multi-dimensional arrays:
For i = 1 To 10
For j = 1 To 20
data[i][j] = i+j
textWindow.WriteLine(data[i][j])
EndFor
EndFor
We can use the old Array commands (except Array.RemoveValue ) to get the count and identify if a value is in an array
For example:
TextWindow.WriteLine("Count = "+Array.GetItemCount(data)) 'the number of elements in the first dimension (10)
TextWindow.WriteLine("Count = "+Array.GetItemCount(data[1])) 'the number of elements in the second dimension where the first dimension is [1] (20)
TextWindow.WriteLine("Found = "+Array.ContainsValue(data[1],3)) '"True", since data[1][2] = 3
Be careful when changing the dimension of arrays. For example using the following 1D array after the above 2D array works but could be confusing:
TextWindow.WriteLine("Value ="+data[7][1]) ' The original vaule (8)
data[7] = 1000 'Set this value seems to delete the entire array data[7][i], removing data[7][1]
TextWindow.WriteLine("Count ="+Array.GetItemCount(data))
TextWindow.WriteLine("Value ="+data[7])
TextWindow.WriteLine("Value ="+data[7][1])
Some other changes are (these are probably true also for other cases where array as are used as arguments):
File.GetFiles(dir,"files") changes to: files = File.GetFiles(dir)
Array.GetItemCount("files") changes to: Array.GetItemCount(files)
SBfile = Array.GetValue("files",i) changes to: SBfile = files[i]
In summary, those that wanted multi-dimensional arrays will be happy, but there will be a new learning curve and issues of backwards compatibility due to the array changes. For example ASTEROIDS and STARGATES have problems with arrays (not having the Array.RemoveValue may have permormance issues if arrays get too large, requiring different approaches to those used with v0.4).- 已編輯litdev解答者Tuesday, 16 June, 2009 20:05typos
- That is an awesome analysis, litdev. I want to highlight the summary litdev made at the end:
In summary, those that wanted multi-dimensional arrays will be happy, but there will be a new learning curve and issues of backwards compatibility due to the array changes. For example ASTEROIDS and STARGATES have problems with arrays (not having the Array.RemoveValue may have permormance issues if arrays get too large, requiring different approaches to those used with v0.4).
This is important. Some previously published samples would need to be updated because of this. For example, I've modified ASTEROIDS as: MTR191, as an example of how the program could be updated.
PS:
To remove an existing value, you just have to set it to an empty value. For example:
a[1] = "One" a[2] = "Two" TextWindow.WriteLine(Array.GetItemCount(a)) ' prints 2 a[2] = "" TextWindow.WriteLine(Array.GetItemCount(a)) ' prints 1
You probably already follow this ideology, but always make compiler changes to do what makes sense & improves clarity during beta development, I think everyone knows that their programs can turn to mush. I think you did the best job on arrays in any programming language, unless speed were necessary which of course isn't the point here. Nice writeup litdev.
- The array removal method makes good sense and overall I think the new arrays are an improvement - in particular the syntax is now more usual.
A small issue with the uninitialised variable detection, the following codes don't find a problem - tricky to identify whether some subroutine that initialised a variable is called before or after a variable is used. However you will still detect typos in variable names which is by far the most common problem.
y = x
Init()
TextWindow.WriteLine("x = "+x)
TextWindow.WriteLine("y = "+y)
Sub Init
x = 10
EndSub
or even an uncalled subroutine:
y = x
Sub Init
x = 10
EndSub
or without a subroutine:
y = x
x = 10
- Yea for Version 0.5!
I have to say I nearly wet myself when I saw the "Format Program" function listed. I have running it against some of the horror show programs that my students turned it, and I have the say the results are simply pretty. I am also delighted to see that the "auto indenting" logic is a lot more robust. - Thank you bigdaddyo and litdev. I'm happy to see you like the new Array syntax. It was actually really fun getting this feature to work the way it does now. At least 3 different implementations were thrown out before I landed on this.
Another interesting thing to note about this array implementation is that you can save (serialize) an array to a file, and then read (deserialize) it back at a later time to get back the exact array structure.
Also, the "array'ness" of a variable's content is computed at runtime and not set in stone. Hence, you can actually compose an array directly using string manipulation. (Try printing out an array - TextWindow.WriteLine(arr) - to see what I mean).
I'm working on a more readable representation of the internal store for arrays. That will come in v0.6 - didn't want to delay v0.5 until then.
PS:
bigdaddyo, could you please update your StarGates sample to use the new Arrays, so that I can publish it as an example for V0.5? - Fun playing with new toys! SaveAs, Indenting and line numbers are great. The serialising is cool (even with objects) - games can now have nice easily implemented SAVE features.
'Create a test array
For i = 1 To 3
For j = 1 To 3
ball = Shapes.AddEllipse(10,10)
balls[i][j] = ball
EndFor
EndFor
output = Program.Directory+"/game.txt" 'File to save an array
File.WriteLine(output,1,balls) 'Save array to a file in line 1
balls = "" 'Delete array to test reading
TextWindow.WriteLine(balls) 'Test it was deleted
balls = File.ReadLine(output,1) 'Read array and use it
For i = 1 To 3
For j = 1 To 3
ball = balls[i][j]
Shapes.Move(ball,50*i,50*j)
EndFor
EndFor- 已編輯litdev解答者Tuesday, 16 June, 2009 21:35use line number to save output
- Very nice array save feature. I'll update maybe tonight, waiting to get 0.5 still, and have a bit of rework. Any ideas yet on why it takes 6-10 seconds to download the first image in a sb program (see stargates thread)?
When I click on this link I get 0.4.The next installment of the Small Basic Community Previews is now available for download. Version v0.5 can be downloaded at: http://download.microsoft.com/download/C/A/F/CAF9E062-94D3-4003-80D9-44CDF7EC7BD9/SmallBasic.msi
Bill- Bill, could you please clear your cache and try again?
Bill, could you please clear your cache and try again?
I'm sorry but when I click on this link I also get the 0.4. SB version ?
Alain- Hi, this version is great, but I have some problem in the spanish keyboard (I'm from Spain, heh). Because when I try to push the character ']' there is a big problem. In the spanish keyboard you have to push AltGr + '+', so the program catch that you are pushing the control key and the plus one, so it increases the size of the text.
I hope you will be able to fix this little problem soon. Thanks for this amazing job. - would anyone care to give me the uninstall.exe from small basic v0.4, i dont have it anymore..
Bill, could you please clear your cache and try again?
That did it!
Thanks,
Bill
How does arrays works internally ?
Is that compatible with the old scheme (Array....) or does it use a completely new system ?
Can a (custom) function have an array as param, or is that still not possible ?
Is the old Array API still there or not (and, BTW, do you have updated the type of the name of any field related to arrays ?)
BTW, Thanks for the HideFromIntellisense attribute, it find it very useful !
---------------------------------------------------------------------------------------
Please note I'll try to find the answer to my questions on my own. If I find something concluant, I'll update my post, so that anyone can have the information.
Fremy - Developer in VB.NET, C# and JScript ... - Feel free to try my extension- Vijaye,
I want to be sure that I'm not missing something. Above, you state that there is a Save As command + toolbar button. Other than using the button is there another way to do the save as command?
JR - Jim, you're right - the only way to invoke the Save As command is via the toolbar button. I guess I was speaking about the internal implementation of first creating a command and then hooking it up with the toolbar button.
Fremy,
The new array implementation is different (from the old system) - the arrays behave just as any primitive and can be passed to any function as param.
Arrays are internally stored as dictionaries, but they are serialized to string alongside - for "copy/pass by value" purposes. Any time an array is deferenced, the string is deserialized into a dictionary and used. I'll be working on a nicer serialization representation for v0.6, but for now, it is simple and works just well.
For example:
person["Name"] = "Fremy"
person["Age"] = 25
will get serialized as:
person = "Name=Fremy;Age=25;"
The old APIs are deprecated and don't use the same system underneath - because earlier, the arrays were identified by name, instead of by the actual variable.- Ok, it is what I expected after running Reflector on your lib. But I was still unsure about some other things like the way the arrays were handled when copied into a new variable (arrA = arrB), or such things. Some tests had given me hints, but I was not fully sure of my thoughts.
I'll update my extension as soon as I can to the new system. It will take some days, but now I've understood the principe, it should work without any problem.
BTW, if you want a nice representation for next versions at low cost (of developpement and of CPU), I can advice you using JSON. This format is widely used on the web and they are many serializer based on the format for almost any language. Even ASP.NET uses it in its 2.0 version for some things. See http://json.org/ if you want more information. That said, the current implementation is good, no change is absolutely needed. I talked about JSON because you said you wanted to use another format for next version.
Thanks for making Small Basic each time even better,
Fremy
Fremy - Developer in VB.NET, C# and JScript ... - Feel free to try my extension What exactly are the 14 keywords in Small Basic? The Internet seems to think we have 14, 15 or 16. I'm getting ready to teach and I want to make sure I'm not missing anything...
Great job on 0.5!- Check out: http://social.msdn.microsoft.com/Forums/en/smallbasic/thread/9cfe359e-8b7e-4774-85ac-2bbd0fcc2d08
It's 16 now, after we introduced ElseIf. - I got the version 0.5 at home, but just cannot get it at work. It keeps giving me version 0.4. I cleared everything out of the history/temp internet files, went so far as to go from IE 7 to IE 8, reboot, still gives me 0.4.
- Looks like your work proxy has got that file cached. Not sure how to get around it. Sorry.
- Try using a different browser. I had a similar problem with fire fox, switching to IE (which I almost never use) let me down load the correct version.
- Wow! Hurrah for the new version, especially the multi-dimensional arrays and the "save as" features. Thanks for the improvements!
- Where can I find the "Format Program"? I don't have any menus. I have version 0.5 loaded and the Icons at the top similar to the "Introducing Small Basic.pdf" guide. The only difference that I have from the guide is that there is 2 items (Build & Check) shown next to the 'Run' button shown in the guide whereas my programme does not show them. The other 'Enviroment Features' are there. Is there a different version out there that I should be using? Thanks
- Right-Click with your mouse to bring up the context menu
The menu includes-
Cut
Copy
Paste
Find
Format Program - Many Thanks. I had been only 'right-click'ing the icon/title area and not the programme area.
- Any idea why the 2 items (Build & Check) shown next to the 'Run' button shown in the guide do not appear my programme? Anyway to create an '.exe' out of any of the Small Basic programmes? Thanks again. :-)
- The "Introducing" PDF shows a picture of an early release of Small Basic. According to Vijaye, the buttons were disabled just before release and were later removed.
Executables (.exe) are created when you "Run" (F5) the program. They are in the same directory where your source code (.sb) file is. If you have not saved your source code, it uses the "Temp" folder. - Your blood is worth bottling. Thanks again.
That is the sort of thing that would be very useful if added to the guide. Along with an up to date picture. Apart from those things, the guide was very helpful. - Hi, Vijaye.Same problem about "]" character here. On a Spanish keyboard, it's impossible to use this character. Small Basic editor catch it as a Ctrl++ (plus sign), so it increases the text size.Please, can you fix it?? Until then, no arrays for me. :-)Thanks a lot for your great job!

