User Tools

Site Tools


static_objects

STATIC OBJECTS

My

String

Implemented since KBasic V1.77.

Functions are

Append , Asc , Compare , Contains , Count , Decode , Encode , EndsWith , Fill , Format , IndexOf , Insert , InStr , InStRev , LastIndexOf , LCase , Left , LeftJustified , Len , Length , Lower , LTrim , Mid (Builtin) , Peek , Poke , Prepend , ReadBinary , Remove , Replace , Reversed , Right , RightJustified , RTrim , Section , SeekBinary , Simplified , Split , StartsWith , StrComp , StrReverse , Trim , Trimmed , Truncate , UCase , Unicode , Upper , Utf8 , Utf16 , Val , Value , WriteBinary

Example

Log String.Upper("lowered text")

DateTime

Utility

Implemented since KBasic V1.77.

Functions are

Bin , Format , Hex , Random , Randomize , Round

Example

Print Utility.Hex(255)

Cast

Implemented since KBasic V1.77.

If you need a different language to deal with different formats use Application.SetLanguage. If you do not set the language the current local language set by the operating system is used.

Example

Application.SetLanguage("English") ' sets for values like 23,345.45

Functions are

Boolean , String (Cast) , Byte , Short , Integer , Long , Single , Double , Decimal , DateTime , Currency , Date (Cast)

Example

Dim n As Integer = Cast.Integer("567")
Print n

Catching a cast exception (new style)

Try 
  date_ = Date(True) Throws CastException
  Print date_
Catch (CastException)
  Print "Could not convert expression"
End Catch

Literal

Implemented since KBasic V1.77.

Functions are

  • Function Return() As String

Returns a “\n” like kbCr does. Ought to be used for creating a multi-line messagebox string.

Don't write “Literal.Return”, but “Return” only.

Example

MsgBox "Hello" & Return & "World"

Dim b As Boolean = True
  • Function Null() As Null
  • Function True() As Boolean
  • Function False() As Boolean

Debug

Implemented since KBasic V1.77.

Functions are

  • Function Type(Variable) As String
  • Function Size(Variable) As Integer
  • Function File() As String
  • Function Line() As Integer
  • Function IsLinux() As Boolean
  • Function IsMac() As Boolean
  • Function IsWindows() As Boolean
  • Function Sub() As String
  • Function Function() As String
  • Function Module() As String
  • Function Class() As String

Example

  Log File ' prints out current code file
  Log Debug.Line ' prints out current code line
  Log Debug.IsWindows

The Qt documentation in C++ of this class (QMenuBar) can be read here: http://doc.trolltech.com/4.3/qmenubar.html

You may use one MenuBar object in your application only. Name your menubar “myMenuBar” in the project window's file, which you would like to have used by the compiler for building your application.

KBasic adds two menus to your menubar at the end, if the project type property is set to “MDI Application”. First one is the window menu, which is for handling the window list and the help menu creating two menu entries 'Contents' and 'About'. To translate those menu entries, take a look at the translate dialog in the KBasic IDE.

It is possible to completely replace those automatically created menu entries, by providing user created menu items.

For the Windows Menu

“Close” → MainWindow.Close()
“Close All” → MainWindow.CloseAll()
“Tile” → MainWindow.Tile()
“Cascade” → MainWindow.Cascade()
“Next” → MainWindow.SetFocusNext()
“Previous” → MainWindow.SetFocusPrevious()

For the Records Menu

“Add Filter” → Application.CurrentForm().AddFilter(”=”)
“Add NotFilter” → Application.CurrentForm().AddFilter(”<>”)
“Clear Filter” → Application.CurrentForm().ClearFilter
“Set Filter” → Application.CurrentForm().SetFilter(”=”)
“Set NotFilter” → Application.CurrentForm().SetFilter(”<>”)
“Sort Ascending” → Application.CurrentForm().SortAscending()
“Sort Descending” → Application.CurrentForm().SortDescending()
“Seek” → Application.CurrentForm.Seek(…)
“Requery” → Application.CurrentForm.Requery()

Use the following static function of the class MenuBar to get the menubar item of the current menubar.

  • Static Function MenuBarItem(Name As String) As MenuBarItem
Dim i As MenuBarItem = MenuBar.MenuBarItem("File")
i.Enabled = True

Events are

  • Sub Contents_OnEvent()
  • Sub About_OnEvent()
Sub Contents_OnEvent()
  Print "Contents clicked"
End Sub

Sub About_OnEvent()
  Print "About clicked"
End Sub

The following functions are implemented since KBasic V1.6 (l)

  • Static Function SetVisible(Boolean)
  • Static Function IsVisible() As Boolean

The following functions are implemented since KBasic V1.6 (m)

  • Static Sub ShowContextMenu(MenuBarItemName As String, X As Integer, Y As Integer)

Shows a context menu.

  • Static Sub ShowContextMenu(X As Integer, Y As Integer)

The last used menu is expected as menubaritem.

  • Static Sub AppendContextMenu(MenuBarItem)

Creates a context menu.

  • Static Sub RemoveAllChildren(ParentMenuBarItemName As String)
  • Static Sub Show()
  • Static Sub Hide()
  • Static Sub ToggleVisible()
  • Static Sub RemoveAll()
  • Static Sub AppendMenuBarItem(ParentMenuBarItemName As String, MenuBarItem)
  • Static Sub AppendMenuBarItem(MenuBarItem)

The last used menu is expected as parent menubaritem.

  • Static Sub AppendMenu(MenuBarItem)

Creates a top-level menu for the menubar.

  • Static Sub AppendChildMenu(ParentMenuBarItemName As String, MenuBarItem)

Creates a child menu for a top-level menu, a context menu or other child menu.

  • Static Sub AppendChildMenu(MenuBarItem)

The last used menu is expected as parent menubaritem.

Events in class myEvent:

  • Static Sub MenuBar_OnEvent(MenuBarItemName As String)
  • Static Sub MenuBar_OnHovered(MenuBarItemName As String)
  • Static Sub MenuBar_OnAboutToShow(MenuBarItemName As String)
  • Static Sub MenuBar_OnAboutToHide(MenuBarItemName As String)

The following functions are implemented since KBasic V1.6 (n)

  • Static Sub SetWithTag(Tag As String, PropertyName As String, Boolean)
  • Static Sub SetWithTag(Tag As String, PropertyName As String, Integer)
  • Static Sub SetWithTag(Tag As String, PropertyName As String, String)
  • Static Sub SetWithGroup(Group As String, PropertyName As String, Boolean)
  • Static Sub SetWithGroup(Group As String, PropertyName As String, Integer)
  • Static Sub SetWithGroup(Group As String, PropertyName As String, String)

The following functions are implemented since KBasic V1.77

  • Static Sub InsertMenu(ParentMenuBarItemName As String, MenuBarItem)

Creates a top-level menu for the menubar.


ToolBar

The Qt documentation in C++ of this class (QToolBar) can be read here: http://doc.trolltech.com/4.3/qtoolbar.html

You may use one ToolBar object in your application only. Name your toolbar “myToolBar” in the project window's file, which you would like to have used by the compiler for building your application.

Use the following static function of the class ToolBar to get the toolbar item of the desired toolbar.

  • Function ToolBarItem(Name As String) As ToolBarItem
Dim i As ToolBarItem = ToolBar.ToolBarItem("File")
i.Enabled = True

Use the following static function of the class ToolBar to add custom controls. Implemented since KBasic V1.6 (k).

  • Sub InsertControl(Index As Integer, Control)

The following functions are implemented since KBasic V1.6 (l)

  • Static Function SetVisible(Boolean)
  • Static Function IsVisible() As Boolean

The following functions are implemented since KBasic V1.6 (n)

  • Static Sub SetWithTag(Tag As String, PropertyName As String, Boolean)
  • Static Sub SetWithTag(Tag As String, PropertyName As String, Integer)
  • Static Sub SetWithTag(Tag As String, PropertyName As String, String)
  • Static Sub SetWithGroup(Group As String, PropertyName As String, Boolean)
  • Static Sub SetWithGroup(Group As String, PropertyName As String, Integer)
  • Static Sub SetWithGroup(Group As String, PropertyName As String, String)

StatusBar

Implemented since KBasic V1.6 (k).

Available for MDI projects only.

Methods:

  • Static Sub Clear()
  • Static Sub RemoveControl(Control)
  • Static Sub InsertControl(Index As Integer, Control)
  • Static Sub InsertControl(Index As Integer, Control, Stretch As Integer)
  • Static Sub Print(Text As String)
  • Static Sub Print(Text As String, TimeOutInMilliSeconds As Integer)
  • Static Sub Hide()
  • Static Sub Show()
  • Static Sub ToggleVisible()

Math

Enables you to directly use the math functions commonly used in BASIC applications. It declares a set of functions to compute common mathematical operations and transformations.

Methods are

  • Static Function Abs (numerical expression) As Double ' returns the absolute value of an argument.
  • Static Function Atn ( number ) As Double ' returns the arctangent value of the argument 'number' in radians
  • Static Function Cos ( number ) As Double ' returns the cosine of the argument 'number' in radians.
  • Static Function Sin ( number ) As Double ' returns the sine of the argument 'number' in radians.
  • Static Function Exp ( number ) As Double ' returns the exponential value of 'number'.
  • Static Function Ln (n As Double) As Long ' returns the natural logaritm of a number.
  • Static Function Log (n As Double) As Long ' returns the calculates the ten-based logarithmic of a number
  • Static Function Sgn( number ) As Integer ' returns the sign of the argument 'number'.
  • Static Function Fix( number ) As Long ' cuts off the trail of a number
  • Static Function Int( number ) As Long ' returns the next integer number
  • Static Function Sqr( number ) As Long ' returns the square root of the argument 'number'.
  • Static Function Tan( number ) As Long ' returns the tangent of the argument 'number' in radians.
  • Static Function Rnd( number ) As Double ' returns an integer pseudo-random number between 0 and int(EXPR)-1 inclusive.
  • Static Function Min (numeric expression1, numeric expression2) As Double ' returns the minor value of two values
  • Static Function Max (numeric expression1, numeric expression2) As Double ' returns the major value of two values
  • Static Function Fact (numeric expression1) As Double ' returns the mathetical fact (n!)

The following functions can be emulated by existing math functions:

Sekans(X) = 1 / Cos(X) 
Kosekans(X) = 1 / Sin(X) 
Kotangens(X) = 1 / Tan(X) 
Arkussinus(X) = Atn(X / Sqr(-X * X + 1)) 
Arkuskosinus(X) = Atn(-X / Sqr(-X * X + 1)) + 2 * Atn(1) 
Arkussekans(X) = Atn(X / Sqr(X * X – 1)) + Sgn((X) – 1) * (2 * Atn(1)) 
Arkuskosekans(X) = Atn(X / Sqr(X * X - 1)) + (Sgn(X) - 1) * (2 * Atn(1)) 
Arkuskotangens(X) = Atn(X) + 2 * Atn(1) 
HSin(X) = (Exp(X) – Exp(-X)) / 2  
HCos(X) = (Exp(X) + Exp(-X)) / 2 
HTan(X) = (Exp(X) – Exp(-X)) / (Exp(X) + Exp(-X)) 
HSekans(X) = 2 / (Exp(X) + Exp(-X)) 
HKosekans(X) = 2 / (Exp(X) – Exp(-X)) 
HKotangens(X) = (Exp(X) + Exp(-X)) / (Exp(X) – Exp(-X)) 
HArkussinus(X) = Log(X + Sqr(X * X + 1)) 
HArkuskosinus(X) = Log(X + Sqr(X * X - 1)) 
HArkustangens(X) = Log((1 + X) / (1 – X)) / 2 
HArkussekans(X) = Log((Sqr(-X * X + 1) + 1) / X) 
HArkuskosekans(X) = Log((Sgn(X) * Sqr(X * X + 1) + 1) / X) 
HArkuskotangens(X) = Log((X + 1) / (X – 1)) / 2 
LogN(X) = Log(X) / Log(N) 

CMath

Enables you to directly use the C library math functions commonly used in C/C++ applications. It declares a set of functions to compute common mathematical operations and transformations.

Implemented since KBasic V1.6 (n).

Methods are

Trigonometric functions:

  • Static Function sin (Double) As Double ' Compute cosine
  • Static Function cos (Double) As Double ' Compute sine
  • Static Function tan (Double) As Double ' Compute tangent
  • Static Function asin (Double) As Double ' Compute arc sine
  • Static Function acos (Double) As Double ' Compute arc cosine
  • Static Function atan (Double) As Double ' Compute arc tangent
  • Static Function atan2 (Y As Double, X As Double) As Double ' Compute arc tangent with two parameters

Hyperbolic functions:

  • Static Function sinh (Double) As Double ' Compute hyperbolic sine
  • Static Function cosh (Double) As Double ' Compute hyperbolic cosine
  • Static Function tanh (Double) As Double ' Compute hyperbolic tangent

Exponential and logarithmic functions:

  • Static Function exp (Double) As Double ' Compute exponential function
  • Static Function log (Double) As Double ' Compute natural logarithm
  • Static Function log10 (Double) As Double ' Compute base-10 logarithm

Power functions

  • Static Function pow (Double, Double) As Double ' Raise to power
  • Static Function sqrt (Double) As Double ' Compute square root

Rounding, absolute value and remainder functions:

  • Static Function ceil (Double) As Double ' Round up value
  • Static Function floor (Double) As Double ' Round down value
  • Static Function fabs (Double) As Double ' Compute absolute value
  • Static Function fmod (Double, Double) As Double ' Compute remainder of division
Print CMath.atan(232.23)

Not implemented yet:

modf, ldexp and frexp


Application

The Qt documentation in C++ of this class (QApplication) can be read here: http://doc.trolltech.com/4.3/qapplication.html

Application Settings:

Only works, if MDI project:

  • If an image file in your project is named application_splash.png, KBasic will automatically set this image file for displaying it as splash when your application starts.
  • If an image file in your project is named application_icon.png, KBasic will automatically set this image file as icon file for your application.
  • The application name is automatically set by the project name in the project property window.

Works everytime:

  • If a stylesheet qss file in your project is named application.qss, KBasic will automatically set this qss file as stylesheet for your application. (When you use application.qss and customize OnPaint of a form control, make sure that you do not set “QWidget { background-color: … }”, otherwise you won't see your painting on your form.)

The following link lists all available stylesheets properties: http://doc.trolltech.com/4.3/stylesheet.html

Properties:

Maybe used only, if there is a mainwindow (see properties of project. Additionally, myMenuBar menubar class must be created):

  • Static Property X As Integer (ReadWrite)
  • Static Property Y As Integer (ReadWrite)
  • Static Property Width As Integer (ReadWrite)
  • Static Property Height As Integer (ReadWrite)

Methods:

Maybe used only, if there is a mainwindow (see properties of project. Additionally, myMenuBar menubar class must be created):

  • Static Sub ShowFullScreen()
  • Static Sub ShowMaximized()
  • Static Sub ShowMinimized()
  • Static Sub ShowNormal()
  • Static Sub SetFocusNext()
  • Static Sub SetFocusPrevious()
  • Static Sub Cascade()
  • Static Sub CloseActive()
  • Static Sub CloseAll()

Closes forms only related to the mainwindow. Forms like dialogs, toolbox windows and dock windows are not closed. See CloseAllWindows.

  • Static Sub Tile()
  • Static Sub SetScrollBarsEnabled(Boolean)
  • Static Function IsScrollBarsEnabled() Boolean

Implemented since KBasic V1.74

  • Static Sub SetViewMode(String)

Possible values are TabbedView, SubWindowView

Only available for MDI applications.

  • Static Function ViewMode() String

Only available for MDI applications.

  • Static Sub SetCaption(String)
  • Static Sub SetIcon(String)

Maybe a file in the project directory or an absolute path.

Might be a String containing binary data. See the binary project example for using.

More Methods (not related to application's mainwindow):

Maybe used anytime:

  • Static Sub MsgBox(Title As String, Caption As String)
  • Static Sub Run() ' this is used by KBasic to run your project. Do not call this method directly.
  • Static Sub Stop() ' terminates the application immediately, without running closing events and other exit code
  • Static Function ScreenWidth() As Integer
  • Static Function ScreenHeight() As Integer
  • Static Function DirectoryName() As String

It points to the kbasic runtime when you don't create an exe, and the pcode is executed by kbrun.exe.

If you create a standalone application using the exe-creator in the tools menu, it points to the exe file somewhere else.

  • Static Function Path() As String

It points to the kbasic runtime when you don't create an exe, and the pcode is executed by kbrun.exe.

If you create a standalone application using the exe-creator in the tools menu, it points to the exe file somewhere else.

Implemented since KBasic V1.81

Returns the same values as DirectoryName. Provided for VB6 compatibility.

  • Static Function FileName() As String
  • Static Sub SetStyleSheet(Text As String)

Maybe a file in the project directory or an absolute path.

  • Static Sub SetLayoutDirection(RightToLeft As Boolean)
  • Static Sub DoEvents()
  • Static Sub LoadExternalBrowserWithHTML(FileName As String)

Must be an absolute path name, meaning with “c:\…\…\…” on Windows.

  • Static Sub CursorSetWait()
  • Static Sub CursorUnsetWait()
  • Static Function Arguments() As Strings
  • Static Function ArgumentsAsString() As String

Returns the arguments as given to the application as one single string.

The following functions are implemented since KBasic V1.6 (l)

  • Static Function LoadProjectFileAsString(String) As String
  • Static Sub SetClipboardText(Text As String)
  • Static Function ClipboardText() As String
  • Static Sub Move(X As Integer, Y As Integer)
  • Static Sub Resize(Width As Integer, Height As Integer)
  • Static Sub Close()
  • Static Function QtVersion As String()
  • Static Function OperatingSystemName As String()
  • Static Sub SetDefaultIcon(String)

Maybe a file in the project directory or an absolute path.

Might be a String containing binary data. See the binary project example for using.

  • Static Sub ExternalOpenFile(FileName As String)

Must be an absolute path name, meaning with “c:\…\…\…” on Windows.

  • Static Sub CloseAllWindows()

Even forms not related to the mainwindow are closed.

  • Static Function IsLayoutDirection() Boolean

Returns true if layout has been set from right to left.

  • Static Function CurrentForm() Form

This function is particularly useful for applications with many top-level windows.

  • Static Function FocusControl() As Control
  • Static Sub SetStyle(String)

Possible values are Motif, CDE, Windows, Cleanlooks, Plastique, WindowsXP, WindowsVista, DotNetStandard, DotNetOffice.

WindowsVista is only available on Windows Vista.

Some examples

Application.X = 0 ' set the mainwindow to all left
Application.Stop() ' halts your program and exits it immediately

Implemented since KBasic V1.73

  • Static Function LoadURLAsString(String) As String

Might be an URL to a file of a website or a local file as well.

  ' show kbasic website xml file
  MsgBox Application.LoadURLAsString("www.kbasic.com/kbasic_pad.xml"), 0, "www.kbasic.com/kbasic_pad.xml"
  • Static Function AvailableMimeTypes() As Strings

Returns information about, if mp3 or mpeg or other media files are supported.

  Dim ss As Strings = Application.AvailableMimeTypes()
   For Each s As String In ss
     Print s;" ";
   Next
  • Static Function IsMimeTypeAvailable(String) As Boolean
  MsgBox Application.IsMimeTypeAvailable("audio\mp3")

Implemented since KBasic V1.76

  • Static Function AvailableLanguages() As Strings
  • Static Sub SetLanguage(String)

Possible values are http://doc.trolltech.com/4.4/qlocale.html#Language-enum

  • Static Sub PlaySound(String)

Might be a String containing binary data. See the binary project example for using.

  • Static Sub PlayMovie(String, KeyAndMouseCanCancel As Boolean = True)

Might be a String containing binary data. See the binary project example for using.

Implemented since KBasic V1.77

  • Static Function LoadProjectFileAsBinary(String) As String
  • Static Function LoadURLAsBinary(String) As String

Might be an URL to a file of a website or a local file as well.

  MsgBox Application.LoadURLAsBinary("file:///C:/myimage.png")
  • Static Sub SetCountry(String)

Possible values are http://doc.trolltech.com/4.4/qlocale.html#Country-enum

Implemented since KBasic V1.8

  • Static Function TakeScreenShot() As String
  • Static Function StandardIcon(String) As String

Returns a binary string containing a standard icon of the operating system.

Possible values are http://doc.trolltech.com/4.4/qstyle.html#StandardPixmap-enum

Application.SetIcon(Application.StandardIcon("BrowserReload"))
  • Static Function AvailableFontNames() As Strings
  • Static Function ProcessId() As Integer

Implemented since KBasic V1.82

  • Static Sub PrintHtml(Html As String)

Prints html code to the printer. Must be a complete html. Currently, only text is printed.

  • Static Sub PrintHtmlAsPdf(Html As String, FileName As String)

Creates a pdf file named “FileName” with the content of “Html”.

Only works on Mac OS X yet. Currently, only text is printed.

Implemented since KBasic V1.83

  • Static Function QtException() As String
  • Static Sub ClearQtException()

Implemented since KBasic V1.89(q)

  • Static Function DownloadURLAsFile(URL As String, DownloadPathAndFileName As String) As Boolean

MainWindow

The Qt documentation in C++ of this class (QMainWindow) can be read here: http://doc.trolltech.com/4.3/qmainwindow.html

Implemented since KBasic V1.75.

Properties:

Maybe used only, if there is a mainwindow (see properties of project. Additionally, myMenuBar menubar class must be created):

  • Static Property X As Integer (ReadWrite)
  • Static Property Y As Integer (ReadWrite)
  • Static Property Width As Integer (ReadWrite)
  • Static Property Height As Integer (ReadWrite)
  • Static Property Resizable As Boolean (ReadWrite)

If true form’s size may be changed by user.

Implemented since KBasic V1.89(q).

  • Static Property ResizableBigger As Boolean (ReadWrite)

If true form’s size may be changed by user. Allows only growing the width and height.

Implemented since KBasic V1.89(q).

  • Static Property ResizableSmaller As Boolean (ReadWrite)

If true form’s size may be changed by user. Allows only shrinking the width and height.

Implemented since KBasic V1.89(q).

Methods:

Maybe used only, if there is a mainwindow (see properties of project. Additionally, myMenuBar menubar class must be created):

  • Static Sub ShowFullScreen()
  • Static Sub ShowMaximized()
  • Static Sub ShowMinimized()
  • Static Sub ShowNormal()
  • Static Sub SetFocusNext()
  • Static Sub SetFocusPrevious()
  • Static Sub Cascade()
  • Static Sub Close()
  • Static Sub CloseActive()
  • Static Sub CloseAll()

Closes forms only related to the mainwindow. Forms like dialogs, toolbox windows and dock windows are not closed. See CloseAllWindows of Application.

  • Static Sub Tile()
  • Static Sub SetScrollBarsEnabled(Boolean)
  • Static Function IsScrollBarsEnabled() Boolean

Implemented since KBasic V1.74

  • Static Sub SetViewMode(String)

Possible values are TabbedView, SubWindowView

Only available for MDI applications.

  • Static Function ViewMode() String

Only available for MDI applications.

  • Static Sub SetCaption(String)
  • Static Sub SetIcon(String)

Maybe a file in the project directory or an absolute path.

Might be a String containing binary data. See the binary project example for using.

  • Static Sub Move(X As Integer, Y As Integer)
  • Static Sub Resize(Width As Integer, Height As Integer)

Implemented since KBasic V1.76.

  • Static Sub SetVisible(Boolean)
  • Static Function IsVisible() As Boolean

Forms

The Qt documentation in C++ of this class (QMainWindow) can be read here: http://doc.trolltech.com/4.3/qmainwindow.html

It is the controller of your forms.

It opens and closes the forms (or activate or deactivate them). There are two types of objects in kbasic: visual objects, and non-visual objects. A visual object is a control and visible at runtime and lets users interact with your application; it has a screen position, a size and a foreground color. Examples of visual objects are forms and buttons. An invisible object is not visible at runtime, such as a timer. Some objects can contain other components, such as an application window containing a button. With KBasic, you add visual objects/controls to your forms to assemble applications.

Projects keep your work together. When developing an appication in kbasic, you work mainly with projects. A project is a collection of files that make up your application. You create a project ot manage and organize these files. KBasic provides an easy yet sophisticated system to manage the collection fo files that make up a project. The project window shows each item in a project. Starting a new application with KBasic begins with the creation fo a project. So before you can construct an application, you need to create a new project. A project consists of many separate files collected in one project directory, where one *.kbasic_project file is and many other files:

  • *.kbasic_module
  • *.kbasic_class
  • *.kbasic_form
  • and more
The Forms class may only be used, if project's main form is set to “Main()” (see properties of project). Additionally, myMenuBar menubar class must be created and the project type property must be set to “MDI Application”. If you are not sure about how to set all settings, create a new project with type MDI application.

Open a form

Opening is easy use the following code:

  Dim f As FORMNAME = New FORMNAME : f.Open()

E.g. if you form is named Form1 you have to write

  Dim f As Form1 = New Form1 : f.Open()

' OR

Forms.Open("FORMNAME") ' for this call you must setup mainwindow in projects properties

Since KBasic V1.6 (k) all forms are automatically declared as global variables accessable from everywhere. So if you would have a form named 'myForm', you could use it like this

' code somewhere in your module or other form module

myForm.Open ' if myForm is already opened, it is shown and get the focus only
myForm.Caption = "hello"

Methods:

  • Static Function Close(String) As Boolean
  • Static Function Focus() As String

Returns the name of the form, which has got the focus currently.

  • Static Function First() As String

Returns the name of the first form in the form list. Only opened forms are in this list and only normal forms (forms which are not DockWindows or Dialogs).

Example

Dim n As String

n = Forms.First()

If n <> "" Then

  Do
    Dim f As Form
    f = Forms.Form(n)
    ' place your code here
    
    n = Forms.Next()
  Loop While n <> ""

End If
  • Static Function Next() As String

Returns the name of the next form in the form list and only normal forms (forms which are not DockWindows or Dialogs).. If it returns and empty string, there is no further form.

  • Static Function Form(String) As Form
  • Static Sub ShowFullScreen(String)
  • Static Sub ShowMaximized(String)
  • Static Sub ShowMinimized(String)
  • Static Sub ShowNormal(String)
  • Static Sub Show(String)
  • Static Sub Hide(String)
  • Static Sub SetFocus(String)

Sets the focus to the form you wish.

  • Static Function IsOpen(String) As Boolean
  • Static Function Open(String) As Boolean

Events in 'Event' class:

  • Static Sub Forms_OnFormGotFocus(FormName As String)

It is possible that FormName is ””, which means no form has got focus right now. If so, you ought to set the menubar and toolbar entries disabled or enabled as it is expected to work, when no form has got focus.


Sounds

Implemented since KBasic V1.75.

The Qt documentation in C++ of this class can be read here: http://doc.trolltech.com/4.4/phonon.html

Sounds is a list of Sound.

Methods Of Sounds:

  • Static Function SetSound(SoundId As String, FileName As String) As Boolean
  • Static Function Load(SoundId As String, FileName As String) As Boolean
  • Static Sub Play(SoundId As String)

Pixmaps

The Qt documentation in C++ of this class (QPixmap) can be read here: http://doc.trolltech.com/4.3/qixmap.html

See the paint project examples for seeing how to use the pixmaps class.

Pixmaps is a list of Pixmap.

Methods Of Pixmaps:

  • Static Function SetPixmap(PixmapId As String, FileName As String) As Boolean
  • Static Function Load(PixmapId As String, FileName As String) As Boolean

Read Painter for the usage of Pixmaps.


Colors

The Qt documentation in C++ of this class (QColor) can be read here: http://doc.trolltech.com/4.3/qcolor.html

Colors is a list of Color.

Methods Of Colors:

  • Static Sub SetColor(ColorId As String, Red As Integer, Green As Integer, Blue As Integer, Alpha As Integer)

Alpha = 0 means fully transparent, Alpha = 255 means fully visible

Predefined colors are:

Color.White, Color.Black, Color.Red, Color.DarkRed, Color.Green, Color.DarkGreen, Color.Blue, Color.DarkBlue, Color.Cyan, Color.DarkCyan, Color.Magenta, Color.DarkMagenta, Color.Yellow, Color.DarkYellow, Color.Gray, Color.DarkGray, Color.LightGray, Color.Color0, Color.Color1, and Color.Transparent.

Beware that you use the predefined color objects for property control colors with the right syntax.

Background = Color.Red ' !Wrong!
Background = "Color.Red" ' right
Background = "Red" ' right

Fonts

The Qt documentation in C++ of this class (QFont) can be read here: http://doc.trolltech.com/4.3/qfont.html

Fonts is a list of Font.

Methods Of Fonts:

  • Static Sub SetFont(FontId As String, Name As String, Size As Integer, Italic As Boolean, Bold As Boolean, Underline As Boolean)

Painter

The Qt documentation in C++ of this class (QPainter) can be read here: http://doc.trolltech.com/4.3/qpainter.html

You might want to use it to override the event methods of Control, when you would like to implement your own controls for display data or interact with the user. You must override OnPaint(…) and use the following functions.

Example

Your form contains of Box1 (control type Box).

Sub Box1_OnPaint(X As Integer, Y As Integer, Width As Integer, Height As Integer)
  Painter.DrawRect(11, 22, 33, 44)
End Sub

Use the following paint functions:

  • Static Sub DrawArc(X As Integer, Y As Integer, Width As Integer, Height As Integer, StartAngle As Integer, SpanAngle As Integer)

The Qt documentation says

The StartAngle and SpanAngle must be specified in 1/16th of a degree, i.e. a full circle equals 5760 (16 * 360). Positive values for the angles mean counter-clockwise while negative values mean the clockwise direction. Zero degrees is at the 3 o'clock position.

  • Static Sub DrawChord(X As Integer, Y As Integer, Width As Integer, Height As Integer, StartAngle As Integer, SpanAngle As Integer)
  • Static Sub DrawEllipse(X As Integer, Y As Integer, Width As Integer, Height As Integer)
  • Static Sub DrawLine(X1 As Integer, Y1 As Integer, X2 As Integer, Y2 As Integer)
  • Static Sub DrawPie(X As Integer, Y As Integer, Width As Integer, Height As Integer, StartAngle As Integer, SpanAngle As Integer)
  • Static Sub DrawPixmap(X As Integer, Y As Integer, Width As Integer, Height As Integer, PixmapId As String, SX As Integer, SY As Integer, SWidth As Integer, SHeight As Integer)
  • Static Sub DrawTiledPixmap(X As Integer, Y As Integer, Width As Integer, Height As Integer, PixmapId As String, SX As Integer, SY As Integer)
  • Static Sub DrawPixmap(X As Integer, Y As Integer, PixmapId As String)
  • Static Sub DrawTiledPixmap(X As Integer, Y As Integer, Width As Integer, Height As Integer, PixmapId As String)
  • Static Sub DrawPoint(X As Integer, Y As Integer)
  • Static Sub DrawRect(X As Integer, Y As Integer, Width As Integer, Height As Integer)
  • Static Sub DrawRoundRect(X As Integer, Y As Integer, Width As Integer, Height As Integer, XRnd As Integer, YRnd As Integer)
  • Static Sub DrawText(X As Integer, Y As Integer, Text As String)
  • Static Sub DrawFramedText(X As Integer, Y As Integer, BlackFrame As Boolean, Text As String)
  • Static Sub SetFont(FontId As String)
  • Static Sub SetPen(ColorId As String)
  • Static Sub SetPen(ColorId as String, Size As Integer, PenStyle As Long, PenCapStyle As Long, PenJoinStyle As Long)
  • Static Sub SetPenPixmap(PixmapObject As Pixmap)
  • Static Sub SetBrush(ColorId As String)
  • Static Sub SetBrush(ColorId As String, BrushStyle As Long)
  • Static Sub SetBrushPixmap(PixmapId As String)
  • Static Sub SetOpacity(Double)
  • Static Sub SetBackgroundFilled(Boolean)
  • Static Sub SetBackground(ColorId As String)
  • Static Sub SetBackgroundPixmap(PixmapId As String)
  • Static Sub FillRect(X As Integer, Y As Integer, Width As Integer, Height As Integer, ColorId As String)
  • Static Sub FillRectPixmap(X As Integer, Y As Integer, Width As Integer, Height As Integer, PixmapId As String)
  • Static Sub SetLayoutDirection(RightToLeft As Boolean)



Possible values for BrushStyle are:

  • Painter.NoBrush, Painter.SolidPattern, Painter.Dense1Pattern, Painter.Dense2Pattern, Painter.Dense3Pattern, Painter.Dense4Pattern, Painter.Dense5Pattern, Painter.Dense6Pattern, Painter.Dense7Pattern, Painter.HorPattern, Painter.VerPattern, Painter.CrossPattern, Painter.BDiagPattern, Painter.FDiagPattern, Painter.DiagCrossPattern, Painter.LinearGradientPattern, Painter.ConicalGradientPattern, Painter.RadialGradientPattern, Painter.TexturePattern



Possible values for PenStyle are:

  • Painter.NoPen, Painter.SolidLine, Painter.DashLine, Painter.DotLine, Painter.DashDotLine, Painter.DashDotDotLine, Painter.CustomDashLine



Possible values for PenCapStyle are:

  • Painter.FlatCap, Painter.SquareCap, Painter.RoundCap



Possible values for PenCapStyle are:

  • Painter.MiterJoin, Painter.BevelJoin, Painter.RoundJoin, Painter.SvgMiterJoin



Implemented since KBasic V1.74

  • Static Sub DrawShadowedText(X As Integer, Y As Integer, BlackShadow As Boolean, Text As String)
  • Static Sub DrawTextRect(X As Integer, Y As Integer, Width As Integer, Height As Integer, Text As String)
  • Static Sub DrawFramedTextRect(X As Integer, Y As Integer, Width As Integer, Height As Integer, BlackFrame As Boolean, Text As String)
  • Static Sub DrawShadowedTextRect(X As Integer, Y As Integer, Width As Integer, Height As Integer, BlackShadow As Boolean, Text As String)

Implemented since KBasic V1.77

  • Static Sub DrawBinary(DestinationX As Integer, DestinationY As Integer, DestinationWidth As Integer, DestinationHeight As Integer, Binary As String, SourceX As Integer, SourceY As Integer, SourceWidth As Integer, SourceHeight As Integer)
  • Static Sub DrawBinary(X As Integer, Y As Integer, Width As Integer, Height As Integer, Binary As String)
  • Static Sub DrawBinary(Binary As String)
  • Static Sub PutBinary(DestinationX As Integer, DestinationY As Integer, DestinationWidth As Integer, DestinationHeight As Integer, Binary As String, SourceX As Integer, SourceY As Integer, SourceWidth As Integer, SourceHeight As Integer)

Same as DrawBinary above. Provided for your convinience.

  • Static Sub PutBinary(X As Integer, Y As Integer, Width As Integer, Height As Integer, Binary As String)

Same as DrawBinary above. Provided for your convinience.

  • Static Sub PutBinary(Binary As String)

Same as DrawBinary above. Provided for your convinience.

  • Static Function GetBinary(Control, X As Integer, Y As Integer, Width As Integer, Height As Integer) As String
  • Static Function GetBinary(Control) As String
  • Static Function LoadBinary(FileName As String) As Boolean
  • Static Function LoadBinary(DestinationX As Integer, DestinationY As Integer, DestinationWidth As Integer, DestinationHeight As Integer, FileName As String, SourceX As Integer, SourceY As Integer, SourceWidth As Integer, SourceHeight As Integer) As Boolean
  • Static Function SaveBinary(Control, FileName As String) As Boolean
  • Static Function SaveBinary(Control, X As Integer, Y As Integer, Width As Integer, Height As Integer, FileName As String) As Boolean
  • Static Sub Begin(Width As Integer, Height As Integer)

Drawing in binary string.

  • Static Function End() As String

Get the binary string after drawing.


OpenDialog

The Qt documentation in C++ of this class (QFileDialog) can be read here: http://doc.trolltech.com/4.3/qfiledialog.html

Implemented since KBasic V1.6 (m).

Methods:

  • Static Function GetFile() As String
  • Static Function GetFile(Caption As String, Directory As String, Filter As String) As String
  • Static Function GetFiles() As Strings
  • Static Function GetFiles(Caption As String, Directory As String, Filter As String) As Strings
  • Static Function GetDirectory() As String
  • Static Function GetDirectory(Caption As String, Directory As String) As String
Dim filenames As Strings = OpenDialog.GetFiles()
If filenames.Length > 0 Then
  Dim s As String
  For Each s In filenames
    Print s
  Next
End If

For V2.x

GetFile() GetFileWith(…) GetFiles() GetFilesWith(…)


SaveDialog

The Qt documentation in C++ of this class (QFileDialog) can be read here: http://doc.trolltech.com/4.3/qfiledialog.html

Implemented since KBasic V1.6 (m).

Methods:

  • Static Function GetFile() As String
  • Static Function GetFile(Caption As String, Directory As String, Filter As String) As String
  • Static Function GetDirectory() As String
  • Static Function GetDirectory(Caption As String, Directory As String) As String
Dim filename As String = SaveDialog.GetFile()
If filename Then
  Print filename
End If

ColorDialog

The Qt documentation in C++ of this class (QColorDialog) can be read here: http://doc.trolltech.com/4.3/qcolordialog.html

Implemented since KBasic V1.77.

Methods:

  • Static Function GetColor() As Boolean
  • Static Function GetColor(Red As Integer, Green As Integer, Blue As Integer, Alpha As Integer) As Boolean
  • Static Function Red() As Integer
  • Static Function Green() As Integer
  • Static Function Blue() As Integer
  • Static Function Alpha() As Integer
If ColorDialog.GetColor() Then
  Print ColorDialog.Red, ColorDialog.Green, ColorDialog.Blue, ColorDialog.Alpha 
End If

FontDialog

The Qt documentation in C++ of this class (QFontDialog ) can be read here: http://doc.trolltech.com/4.3/qfontdialog.html

Implemented since KBasic V1.77.

Methods:

  • Static Function GetFont() As Boolean
  • Static Function GetFont(Name As String, Size As Integer, Italic As Boolean, Bold As Boolean, Underline As Boolean) As Boolean
  • Static Function Name() As String
  • Static Function Size() As Integer
  • Static Function Italic() As Boolean
  • Static Function Bold() As Boolean
  • Static Function Underline() As Boolean
If FontDialog.GetFont() Then
  Print FontDialog.Name, FontDialog.Size
End If

ProgressDialog

The Qt documentation in C++ of this class (QProgressDialog) can be read here: http://doc.trolltech.com/4.3/qprogressdialog.html

Implemented since KBasic V1.77.

Methods:

  • Static Sub Show()
  • Static Sub Show(Caption As String, CancelCaption As String)
  • Static Sub Hide()
  • Static Function Canceled() As Boolean

Properties:

  • Static Property Caption As String (ReadWrite)
  • Static Property CancelCaption As String (ReadWrite)
  • Static Property Value As Integer (ReadWrite)
  • Static Property Minimum As Integer (ReadWrite)
  • Static Property Maximum As Integer (ReadWrite)
  • Static Property Wait As Integer (ReadWrite)
ProgressDialog.Maximum = 100
ProgressDialog.Caption = "Large Operation"
ProgressDialog.CancelCaption = "Cancel"
ProgressDialog.Show()

Do While True

  Application.DoEvents()

  If ProgressDialog.Canceled() Then 
    Exit Loop
  End If

  ProgressDialog.Value = ProgressDialog.Value + 1
  ' do calculation

  If ProgressDialog.Value = 100 Then Exit Loop   

Loop			

ProgressDialog.Hide()

InputDialog

The Qt documentation in C++ of this class (QInputDialog) can be read here: http://doc.trolltech.com/4.3/qinputdialog.html

Implemented since KBasic V1.77.

Methods:

  • Static Function Ok() As Boolean

Returns true, if the user pressed “Okay” and value is valid.

  • Static Function GetDouble(Caption As String, Text As String = ””, Value As Double = 0, Minimum As Double = -2147483647, Maximum As Double = 2147483647, Decimals = 1) As Double
  • Static Function GetInteger(Caption As String, Text As String = ””, Value As Integer = 0, Minimum As Integer = -2147483647, Maximum As Integer = 2147483647, Step = 1) As Integer
  • Static Function GetString(Caption As String, Text As String = ””, Value As String = ””, EchoMode = “Normal”) As String

Echo might be

NormalDisplay characters as they are entered. This is the default.
NoEchoDo not display anything. This may be appropriate for passwords where even the length of the password should be kept secret.
PasswordDisplay asterisks instead of the characters actually entered.
PasswordEchoOnEditDisplay characters as they are entered while editing otherwise display asterisks.
Dim s As String = InputDialog.GetString("Input some value")
If InputDialog.Ok() Then
  Print s
End If

MessageBox

The Qt documentation in C++ of this class (QMessageBox) can be read here: http://doc.trolltech.com/4.3/qmessagebox.html

Implemented since KBasic V1.77.

Methods:

  • Static Function Show(Caption As String, Text As String = ””, Buttons As String = “Ok”, DefaultButton As String = ””, DetailedText As String = ””, Icon As String = ””) As String
  • Static Function Critical(Caption As String, Text As String = ””, Buttons As String = “Ok”, DefaultButton As String = ””) As String
  • Static Function Information(Caption As String, Text As String = ””, Buttons As String = “Ok”, DefaultButton As String = ””) As String
  • Static Function Question(Caption As String, Text As String = ””, Buttons As String = “Ok”, DefaultButton As String = ””) As String
  • Static Function Warning(Caption As String, Text As String = ””, Buttons As String = “Ok”, DefaultButton As String = ””) As String

Possible values for buttons are

Ok, Open, Save, Cancel, Close, Discard, Apply, Reset, RestoreDefaults, Help, SaveAll, Yes, YesToAll, No, NoToAll, Abort, Retry, Ignore

Example

Select MessageBox.Show("Your choice", "Select one button", "Ok;Cancel;Save", "", "DetailedText", "EDIT_CUT.png")
  Case "Ok"
    Print "Ok"
  Case "Cancel"
    Print "Cancel"
End Select  

Select MessageBox.Critical("Your choice", "Select one button", "Ok;Cancel;Save")
  Case "Ok"
    Print "Ok"
  Case "Cancel"
    Print "Cancel"
End Select    

SystemTray

Implemented since KBasic V1.74b.

The Qt documentation in C++ of this class (QSystemTrayIcon) can be read here: http://doc.trolltech.com/4.3/qsystemtrayicon.html

This class provides an icon for an application in the system tray.

The Qt documentation says that modern operating systems usually provide a special area on the desktop, called the system tray or notification area, where long-running applications can display icons and short messages.

The SystemTray class can be used on the following platforms:

  • All supported versions of Windows.
  • All window managers for X11 that implement the freedesktop.org system tray specification, including recent versions of KDE and GNOME.
  • All supported versions of Mac OS X. Note that the Growl notification system must be installed for Print to display messages.

On Windows, the system tray icon size is 16×16; on X11, the preferred size is 22×22. The icon will be scaled to the appropriate size as necessary.

The icon is initially invisible.

Methods:

  • Static Function IsSystemTrayAvailable() As Boolean
  • Static Function IsPrintSupported() As Boolean
  • Static Sub Print(String)
  • Static Sub Print(Text As String, Title As String)
  • Static Sub Print(Text As String, Title As String, PrintIcon As String)

Possible values are NoIcon, Information, Warning, Critical

  • Static Sub Print(Text As String, Title As String, PrintIcon As String, TimeOut As Integer)

TimeOut = 1000 means 1 second. On Windows, the TimeOut is usually ignored by the system when the application has focus.

  • Static Sub Show()
  • Static Sub Hide()
  • Static Sub ToggleVisible()

Properties:

  • Static Property ContextMenu As String (ReadWrite)

The menu will pop up when the user requests the context menu for the system tray icon by clicking the mouse button. You need to have at least an empty menubar created in your project.

  • Static Property Icon As String (ReadWrite)
  • Static Property ToolTip As String (ReadWrite)
  • Static Property Visible As Boolean (ReadWrite)

Events in the event class:

  • Sub SystemTray_OnEvent(Event As String)

Event may contain

  • PrintClicked

or

UnknownUnknown reason
ContextThe context menu for the system tray entry was requested
DoubleClickThe system tray entry was double clicked
TriggerThe system tray entry was clicked
MiddleClickThe system tray entry was clicked with the middle mouse button

Not implemented yet:

  • Static Property GlobalX As String (ReadOnly)
  • Static Property GlobalY As String (ReadOnly)
  • Static Property Width As String (ReadOnly)
  • Static Property Height As String (ReadOnly)

Log

It is recommended to use this class to print out log information during your program's execution. It supports Unicode text.

Implemented since KBasic V1.6 (q).

Methods:

  • Static Sub Print(String)
  • Static Sub PrintHtml(String)
  • Static Sub PrintSql(String)
  • Static Sub Show()
  • Static Sub ShowMaximized()
  • Static Sub ShowMinimized()
  • Static Sub Hide()

Example

Log "Hello World"  ' use of the shortcut call of the Log.Print

Not implemented yet:

  • Static Sub SetWordWrap(Boolean)
  • Static Sub DontOpenAutomatically(Boolean)
  • Static Function Save(FileName As String) As Boolean
  • Static Function IsAlreadyUsed() As Boolean
  • Static Function IsVisible() As Boolean

Actions

Implemented since KBasic V1.76.

Methods

  • Static Sub SetEnabled(ActionId As String, Boolean)
  • Static Function IsEnabled(ActionId As String) As Boolean
  • Static Sub SetVisible(ActionId As String, Boolean)
  • Static Function IsVisible(ActionId As String) As Boolean
  • Static Sub SetChecked(ActionId As String, Boolean)
  • Static Function IsChecked(ActionId As String) As Boolean
  • Static Sub SetStatusTip(ActionId As String, String)
  • Static Function StatusTip(ActionId As String) As String
  • Static Sub SetToolTip(ActionId As String, String)
  • Static Function ToolTip(ActionId As String) As String
  • Static Sub SetWhatsThis(ActionId As String, String)
  • Static Function WhatsThis(ActionId As String) As String
  • Static Sub SetIcon(ActionId As String, String)
  • Static Function Icon(ActionId As String) As String
  • Static Sub SetTag(ActionId As String, String)
  • Static Function Tag(ActionId As String) As String
  • Static Sub SetCaption(ActionId As String, String)
  • Static Function Caption(ActionId As String) As String
  • Static Sub SetText(ActionId As String, String)
  • Static Function Text(ActionId As String) As String
  • Static Sub SetSoundOnEvent(ActionId As String, String)
  • Static Function SoundOnEvent(ActionId As String) As String
  • Static Sub SetGroup(ActionId As String, String)
  • Static Function Group(ActionId As String) As String
  • Static Sub SetKey(ActionId As String, String)
  • Static Function Key(ActionId As String) As String

Events in 'Event' class:

  • Static Sub Actions_OnAction(ActionId As String)

Not implemented yet:

Actions{“FILE_OPEN”}.SetEnabled(True)

Actions{“FILE_OPEN”}.Enabled = True Actions{“FILE_OPEN”}.Enabled = Not Actions{“FILE_OPEN”}.Enabled


Preferences

Implemented since KBasic V1.76.

Predefined preferences

  • Language As String

It is used to determine which language translation should be used on application startup.

Methods

  • Static Function Has(PreferenceId As String) As Boolean
  • Static Sub Remove(PreferenceId As String)
  • Static Function Ids() As Strings
  • Static Sub SetBoolean(PreferenceId As String, Boolean)
  • Static Sub SetInteger(PreferenceId As String, Integer)
  • Static Sub SetString(PreferenceId As String, String)
  • Static Sub SetDouble(PreferenceId As String, Double)
  • Static Function Boolean(PreferenceId As String) As Boolean
  • Static Function Integer(PreferenceId As String) As Integer
  • Static Function String(PreferenceId As String) As String
  • Static Function Double(PreferenceId As String) As Double

Not implemented yet:

  • Static Sub SetStrings(PreferenceId As String, Strings)
  • Static Function Strings(PreferenceId As String) As Strings

Dir

Implemented since KBasic V1.76.

An object to access and manipulate the directories of your system.

  • Click Dir for more information.

File

Implemented since KBasic V1.76.

An object to access and manipulate the files of your system.

  • Click File for more information.

Process

Implemented since KBasic V1.77.

Methods:

  • Static Function Run(String) As Boolean
  • Static Function Run(String, Arguments As Strings) As Boolean
Process.Run("explorer") ' starts the explorer on Windows

Not implemented yet:

QProcess::startDetached


DatabaseDialog

Implemented since KBasic V1.79. Only works for MySQL or PostgreSQL.

Methods:

  • Static Function GetDatabase() As Boolean
  • Static Function GetDatabase(Driver As String, Name As String, User As String, Password As String, Host As String, Options As String, Port As String) As Boolean
  • Static Function Driver() As String
  • Static Function Host() As String
  • Static Function Port() As String
  • Static Function Name() As String
  • Static Function User() As String
  • Static Function Password() As String
  • Static Function Options() As String
If DatabaseDialog.GetDatabase() Then
  Print DatabaseDialog.Driver, DatabaseDialog.Name
End If

Database

Implemented since KBasic V1.79.

Functions are

  • Function MySQL() As String
  • Function PostgreSQL() As String
  • Function SQLite() As String
  • Function ODBC() As String
  • Function LocalHost() As String
  • Function DefaultPort() As String
  • Function DefaultOptions() As String

Write

Database.DefaultOptions

don't write

Options = "DefaultOptions"
  • Function SetCurrentDatabase(Name As String) As Boolean
  • Function CurrentDatabase() As String
  • Function Exists(Driver As String, Name As String, User As String, Password As String, Host As String = LocalHost, Options As String = DefaultOptions, Port As String = DefaultPort) As Boolean
  • Function Create(Driver As String, Name As String, User As String, Password As String, Host As String = LocalHost, Options As String = DefaultOptions, Port As String = DefaultPort) As Boolean
  • Function TestConnection(Driver As String, User As String, Password As String, Host As String = LocalHost, Options As String = DefaultOptions, Port As String = DefaultPort) As String
  • Function Empty(Driver As String, Name As String, User As String, Password As String, Host As String = LocalHost, Options As String = DefaultOptions, Port As String = DefaultPort) As Boolean

Clears alle tables of the current databases. All data is lost!

  • Function Drop(Driver As String, Name As String, User As String, Password As String, Host As String = LocalHost, Options As String = DefaultOptions, Port As String = DefaultPort) As Boolean
  • Function OpenSQLite(Name As String) As Boolean

Always use it for opening sqlite databases.

  • Function Open(Driver As String, Name As String, User As String, Password As String) As Boolean
  • Function Open(Driver As String, Name As String, User As String, Password As String, Host As String = LocalHost, Options As String = DefaultOptions, Port As String = DefaultPort) As Boolean
  • Function Close(Name As String = ””) As Boolean
  • Function IsOpen(Name As String = ””) As Boolean
  • Function LastSQLError(Name As String = ””) As String
  • Function LastSQLCommands(Name As String = ””) As String
  • Function LastSQLCommandFailed(Name As String = ””) As String
  • Function IsTransactionSupported(Name As String = ””) As Boolean
  • Function Transaction(Name As String = ””) As Boolean
  • Function Commit(Name As String = ””) As Boolean
  • Function Rollback(Name As String = ””) As Boolean
  • Function Tables(Name As String = ””) As Strings
  • Function Drivers() As Strings

Not supported yet:

  • Function Copy(Source As String, Destination As String) As Boolean

Table

Implemented since KBasic V1.79.

Functions are

  • Function Exists(Table As String) As Boolean
  • Function Exists(Database As String, Table As String) As Boolean
  • Function Create(Table As String) As Boolean
  • Function Create(Database As String, Table As String) As Boolean

Creates a new table from project definition table file. A table definition with the same name must be in the project file list.

  • Function Create(Table As String, Fields As Array) As Boolean
  • Function Create(Database As String, Table As String, Fields As Array) As Boolean
All create table methods automatically add a field “kbrecordid” to the table as unique record id. If you need another field as primary key, use a custom SQL statement and execute it with Query.Run(“SQL statement”)
  • Function Empty(Table As String) As Boolean
  • Function Empty(Database As String, Table As String) As Boolean
  • Function Drop(Table As String) As Boolean
  • Function Drop(Database As String, Table As String) As Boolean
  • Function Delete(Table As String, Where As Array) As Boolean
  • Function Delete(Database As String, Table As String, Where As Array) As Boolean
  • Function Update(Table As String, Update As Array, Where As Array) As Boolean
  • Function Update(Database As String, Table As String, Update As Array, Where As Array) As Boolean
  • Function Insert(Table As String, Insert As Array) As Boolean
  • Function Insert(Database As String, Table As String, Insert As Array) As Boolean
  • Function FieldNames(Table As String) As Strings
  • Function FieldNames(Database As String, Table As String) As Strings
  • Function PrimaryKeyName(Table As String) As String
  • Function PrimaryKeyName(Database As String, Table As String) As String

Before V1.89, it returns “kbrecordid” always.

Not implemented yet:

  • Function Copy(Source As String, Destination As String) As Boolean
  • Function Copy(Database As String, Source As String, Destination As String) As Boolean

Records

Implemented since KBasic V1.79.

Functions are

  • Function Open(TableOrSql As String) As String
  • Function Open(Database As String, TableOrSql As String) As String
  • Function Open(Table As String, Where As Array) As String
  • Function Open(Database As String, Table As String, Where As Array) As String
  • Function Open(Table As String, Where As Array, OrderBy As Array) As String
  • Function Open(Database As String, Table As String, Where As Array, OrderBy As Array) As String
  • Function Close(RecordsId As String) As Boolean
  • Function Requery(RecordsId As String) As Boolean
  • Function First(RecordsId As String) As Boolean
  • Function Next(RecordsId As String) As Boolean
  • Function Previous(RecordsId As String) As Boolean
  • Function Last(RecordsId As String) As Boolean
  • Function GoTo(RecordsId As String, Position As Integer) As Boolean

First record is at Position = 1.

  • Function Length(RecordsId As String) As Integer

Returns -1, if length could not be returned.

  • Function Position(RecordsId As String) As Integer

First record is at Position = 1.

  • Function FieldNames(RecordsId As String) As Strings
  • Function Value(RecordsId As String, Field As String) As Variant

All following functions are not implemented yet:

  • Function PrimaryKey(RecordsId As String) As Integer

Currently, it returns the value of “kbrecordid” always.

  • Function PrimaryKeyName(RecordsId As String) As String

Currently, it returns “kbrecordid” always.

  • Function Insert(RecordsId As String) As Boolean
  • Function Update(RecordsId As String) As Boolean
  • Function Delete(RecordsId As String) As Boolean
  • Function ClearFields(RecordsId As String) As Boolean
  • Function SetField(RecordsId As String, Field As String, Value As Variant)
  • Function Open(Tables As Strings, Where As Array) As String
  • Function Open(Database As String, Tables As Strings, Where As Array) As String
Records{RecordId, "name"} = "hello"
Records{RecordId, "age"} = 43

Print Records{RecordId, "name"}
Print Records{RecordId, "age"}

Query

Implemented since KBasic V1.79.

Functions are

  • Function Run(QueryNameOrSql As String) As Boolean
  • Function Run(DataBase As String, QueryNameOrSql As String) As Boolean

Runs a sql statement from project definition query file, if file name is given, else it runs QueryNameOrSql as sql statement. A query definition with the same name must be in the project file list.

Check out Records as well.

  • Function Command(Command As String) As Dictionary
  • Function Command(DataBase As String, Command As String) As Dictionary

Useful for running generic database commands, e.g. having a sqlite database:

       Dim a As Dictionary = Query.Command("PRAGMA database_list;")
       
       Dim ss As Strings = a.Keys()
       dim i as integer
       For i=0 to ss.length()
         Print( ss.String(i))
         Print( a.String(ss.String(i)))
       Next   

static_objects.txt · Last modified: 2013/04/09 22:58 (external edit)