What does this extension provides This extension provides support :

Better Shapes and Controls management - More controls : Button, TextBox, CheckBox, Label, Polygon, WebBrowser, ... - Possibility to register events of Shapes and Controls - More properties for Shapes and Controls (Opacity, ...)

Full interop with .NET FrameWork - Creating .NET objects - Using .NET objects using Reflection - Registering events and converting delegate from a type to another - ...

New SmallBasic functions - Eval() - Timers - Sort of SmallBasic events - Call Sub by Name, ... - Simple reflection (name of all defined subs/variables)

Support for XML - Loading documents from file or string - Reading/Writing the DOM - Saving to file

And much more ! 

You can download the API Reference at
http://cid-201f3835d49587fe.skydrive.live.com/self.aspx/Public/Small%20Basic/Help%20archive.zip 


How to use it ?

1. Getting the DLL: Download it at http://cid-201f3835d49587fe.skydrive.live.com/self.aspx/Public/Small%20Basic/lib.zip Or compile it from sources at http://cid-201f3835d49587fe.skydrive.live.com/self.aspx/Public/FC.SmallBasic.Complements.zip (may be an old version)

2. Adding the DLL as plugin for Small Basic Copy the DLL into a 'lib' folder you create in the Small Basic's installation directory

3. Opening Small Basic Open Small Basic and start to use the new objects.



Samples First sample : the Controls extension (and others)
' Init variables
Timer = ""

' Init Window
GraphicsWindow.Show()
GraphicsWindow.BackgroundColor = GraphicsWindow.GetColorFromRGB(240,240,240)
Controls.LoadTheme("Vista")

' Create animation
MyImage = Controls.AddImage("AppIcon.png")
ButtonClick()

' Create button
MyButton = Controls.AddButton(150, 22, "Start/Stop")
Controls.Move(MyButton, 5, 150)
Controls.RegisterMouseUpEvent(MyButton, "ButtonClick")

' Create textbox
MyTextBox = Controls.AddTextBox(175, 22, "")
Controls.Move(MyTextBox, 165, 150)
Controls.SetText(MyTextBox, "Some text")
Controls.RegisterEvent(MyTextBox, "TextChangedEvent", "OnTextChange")

' Create checkbox
MyCheckBox = Controls.AddCheckBox("Cliquez ici !")
Controls.Move(MyCheckBox, 350, 155)
Controls.SetChecked(MyCheckBox, "True")

' Subs
CurrentMyImageRotation = 0
To150 = "False"
Sub RotateMyImage
  CurrentMyImageRotation = CurrentMyImageRotation + 1
  If CurrentMyImageRotation = 360 Then
    CurrentMyImageRotation = 0
    If To150 = "False" Then
      To150 = "True"
      Controls.MoveAsAnimation(MyImage, 0, 0, 1080)
    Else
      To150 = "False"
      Controls.MoveAsAnimation(MyImage, GraphicsWindow.Width-125, 0, 1080)
    EndIf
  EndIf
  Controls.SetRotationAngle(MyImage, CurrentMyImageRotation)
EndSub

Sub ButtonClick
  If Timer = "" Then
    Timer = SmallBasic.SetInterval("RotateMyImage", 3, -1)
    GraphicsWindow.AnimateShape(MyImage, GraphicsWindow.Width-125, 0, 1080)
  Else
    SmallBasic.AsyncStop(Timer)
    Timer = ""    
  EndIf
EndSub

Sub OnTextChange
  GraphicsWindow.ShowMessage(Controls.GetText(MyTextBox),"Text")
EndSub

Second sample : XML
TextWindow.WriteLine("Test du système XML")

Quote = Text.GetCharacter(34)
Doc = Xml.LoadXMLFile("Data.XML")
TextWindow.WriteLine("")

' First test
Bag2 = Xml.GetNode(Doc, "//bag2")
TextWindow.WriteLine("The element : " + Bag2)
TextWindow.WriteLine("Content of the element : " + Xml.GetOuterXML(Bag2))
TextWindow.WriteLine("")

' Second test
ItemE = Xml.GetNode(Bag2, "./item@name="+Quote+"e"+Quote+"")
TextWindow.WriteLine("The element : " + ItemE)

Name = Xml.GetNodeValue(Xml.GetNode(ItemE, "@name"))
TextWindow.WriteLine("Name of the element : " + Quote + Name + Quote)

TextWindow.WriteLine("")

Last sample : Interop
Array.SetValue("Args", 0, "Bonjour ")
Builder = Interop.CreateObject("System.Text.StringBuilder","Args")
ClearArgs()

Array.SetValue("Args", 0, "Objet StringBuilder créé !")
Array.SetValue("Args", 1, "My TestApp for Interop")
Interop.CallSharedSub("System.Windows.Forms.MessageBox", "Show", "Args")
ClearArgs()

TextWindow.Write("Entrez votre nom ici : ")

Array.SetValue("Args", 0, TextWindow.Read())
Interop.CallSub(Builder, "Append", "Args")
ClearArgs()

Array.SetValue("Args", 0, "L'objet StringBuilder semble avoir fonctionné correctement")
Array.SetValue("Args", 1, "My TestApp for Interop")
Interop.CallSharedSub("System.Windows.Forms.MessageBox", "Show", "Args")
ClearArgs()

TextWindow.WriteLine(Interop.ToString(Builder))
TextWindow.Read()

Sub ClearArgs
  For ArgsCleanerIndex = 0 To Array.GetItemCount("Args")
    Array.RemoveValue("Args", ArgsCleanerIndex)
  EndFor
EndSub

Download these examples and some others at http://cid-201f3835d49587fe.skydrive.live.com/self.aspx/Public/Small%20Basic/  (included in the Help archive)
 

References

This content originally came from the Small Basic Wiki. (archive)

Other Resources