This article is about clipboard and Microsoft Small Basic programming language.


What is Clipboard

Clipboard is a common tentative memory which can contain a text, an image or other information.  Clipboard is used to move or copy such an information in an application or between applications.

Clipboard and Small Basic

The clipboard can be used as following four situations with Small Basic.

Clipboard in the Small Basic environment

With the Small Basic environment, a text can be selected in the editor and copied it to the clipboard.  Following commands of the toolbar (keyboard shortcuts) are also used for the clipboard:

  • Cut (Ctrl+X)
  • Copy (Ctrl+C)
  • Paste (Ctrl+V)
  • (Ctrl+A for Select All)

TextWindow

In TextWindow, a text can be copied with the menu [Edit], [Mark] and selecting the text by mouse, then [Copy].

Text input box

In GraphicsWindow Small Basic program, text input boxes created with Controls.AddTextBox() or Controls.AddMultiLineTextBox() allow to use clipboard by keyboard shortcuts above.

LitDev Extension

LitDev Extension has a LDClipboard object to manipulate clipboard in Small Basic program.  Following code are from LDClipboard.sb included in sample programs for LitDev Extension.  The first one is a sample to copy a text to clipboard and get from it.

LDClipboard.SetText("Hello World")
TextWindow.WriteLine(LDClipboard.GetText())

The second code to handle a file list with the clipboard.

LDClipboard.SetFileList(File.GetFiles(Program.Directory))
files = LDClipboard.GetFileList()
For i = 1 To Array.GetItemCount(files)
  TextWindow.WriteLine(files[i])   
EndFor

The third one is handling an image with clipboard.

image = ImageList.LoadImage(Flickr.GetRandomPicture("Car"))
LDClipboard.SetImage(image)
image2 = LDClipboard.GetImage()
GraphicsWindow.DrawResizedImage(image2,0,0,GraphicsWindow.Width,GraphicsWindow.Height)

 


See Also

Other Resources