Difference between revisions of "Development/Languages/KBasic"

Jump to: navigation, search
(New page: {{note| KBasic is still under development. }} KBasic is a powerful programming language, which is simply intuitive and easy to learn. It is a new programming language, a further BASIC dia...)
 
Line 1: Line 1:
 
{{note| KBasic is still under development. }}
 
{{note| KBasic is still under development. }}
  
KBasic is a powerful programming language, which is simply intuitive and easy to learn. It is a new programming language, a further BASIC dialect and is related to VB.NET™, Visual Basic®, Visual Basic for Application® and Java™. It combines the best features of those tools and comes with built-in backward support for those tools and QBasic® as it is 100% syntax compatible to VB6, VBA and QBasic®.
+
KBasic is a programming language, which is simply intuitive and easy to learn and is related to VB.NET™, Visual Basic®, Visual Basic for Application® and Java™. It combines the best features of those tools and comes with built-in backward support for those tools and QBasic® as it is 100% syntax compatible to VB6, VBA and QBasic®. Additionally, it comes with support for VB.NET™ syntax, functions and similar objects and classes.
 
+
Additionally, it comes with support for VB.NET™ syntax, functions and similar objects and classes.
+
 
+
  
 
The purpose of KBasic enabling BASIC developers to write desktop applications using the powerful technologies provided by Qt, KDE and related frameworks. For now the Qt API is covered.
 
The purpose of KBasic enabling BASIC developers to write desktop applications using the powerful technologies provided by Qt, KDE and related frameworks. For now the Qt API is covered.

Revision as of 11:46, 14 January 2009

noframe
 
Note
KBasic is still under development.

KBasic is a programming language, which is simply intuitive and easy to learn and is related to VB.NET™, Visual Basic®, Visual Basic for Application® and Java™. It combines the best features of those tools and comes with built-in backward support for those tools and QBasic® as it is 100% syntax compatible to VB6, VBA and QBasic®. Additionally, it comes with support for VB.NET™ syntax, functions and similar objects and classes.

The purpose of KBasic enabling BASIC developers to write desktop applications using the powerful technologies provided by Qt, KDE and related frameworks. For now the Qt API is covered.

 Class Walzer
   Public var As integer
 End Class 
 
 Const globalConst = 1
 Const globalConst2 As Integer = 2
 
 Dim globalVar As Integer = 4
 Dim globalVar2 As test
  
 globalVar2 = test.Entry
 
 ' global scope 
 
 Enum test
   Entry = 666
   Entry2
   Security = Entry
   securus
   secura
   securum
 End Enum
 
 Type book  
   bkname As String * 100
   
   isbn(1000) As Integer   
 End Type
 
 Type address
   books(50) As book   
   age As book   
   Name[9] As Integer   
 End Type 
 
 
 Sub globalSub()
   Dim localVar = 99    
 End Sub
 
 
 ' module scope
 
 Module module1 
 
   Public Type address2    
     age As Integer     
   End Type 
 
   Public Type module_type    
     element AS integer
   End Type   
 
   Public Enum module_enum    
      Entry
      Entry2
      Security = Entry
   End Enum 
 
   Const moduleConst = 7  
 
   Public publicModuleVar As Integer  
   Private privateModuleVar As Integer  
                  
 
   Sub moduleExplicit()
     
     Dim localVar = module1.publicModuleVar  
     Dim localVar2 = module1.moduleConst
     
  '   Dim localVar3 As module1.module_enum '  full type name not allowed after AS
     Dim localVar3 As module_enum
     localVar3 = module1.module_enum.Entry
     'Dim localVar4 As module1.module_type     '  full type name not allowed after AS
     Dim localVar5 As module_type     '  full type name not allowed after AS
   End Sub 
 
   Sub moduleImplicit()
     dim localVar = publicModuleVar
     dim localVar2 = moduleConst 
     dim localVar3 as module_enum
     localVar3 = module_enum.Entry
     Dim localVar4 As module_type
     Dim localVar5 As module_type
     Dim localVar6 = module1.publicModuleVar
     
      
   End Sub 
 
   Sub moduleSubWithDefaultArgument(ko as integer = 6)
     Dim localVar = ko
   End Sub 
 
   Sub moduleSubWithOptionalArgument(Optional ko As Integer)
     If Not IsMissing(ko) Then
       dim localVar = ko      
     End If
   End Sub
   
   Sub moduleSub()
     Const localConst = 6 
     dim n = localConst
   End Sub 
 
   Sub moduleSubWithArgument(i as integer)
     dim localVar = i
   End Sub 
 
   Sub moduleSubWithArgumentShadowing(i2 as integer)
     Dim localVar = i2
     Dim i2 = localVar + 99
     dim i3 = i2
   End Sub 
     
   Sub subOverloading ( )
     print "sub1"
   End Sub 
   
   Sub subOverloading ( i as integer = 1)
     print "sub2"    
   End Sub
 
   Function moduleFunction() As String
     
     subOverloading()
     subOverloading(88)
     
     return "hello"
   End function 
 
   function moduleFunctionRecursive(byref i as integer) as integer
     if i > 6 then return 1i
 
     i = i + 1
     return moduleFunctionRecursive(1)i)
   End function 
 
 End Module
 


 Class Salsa inherits Walzer
 
   public Enum class_enum
      Entry
      Entry2
      Security = Entry
   End Enum 
 
   public type class_type
     element AS integer
   End Type 
 
   const classConst = 4
 
   public publicInstanceVar as integer
   Private privateInstanceVar As Integer 
   'Protected protectedInstanceVar As Integer 
 
   Static Public publicClassVar As Integer' = 8 
   'dim publicModuleType as module1.module_type
   dim publicModuleType2 as module_type
 
   ' parent constructor call inside constructor
 
   Sub meExplicit()
     dim localVar = Me.publicInstanceVar '  it is the same with Parent
     dim localVar2 = Me.publicClassVar  
     dim localVar3 = Salsa.publicClassVar 
     dim localVar4 = Salsa.classConst 
     Dim localVar5 = classConst
     
     'Dim localVar5b = Me.classConst 
 '    left
 
     Dim localVar6 As class_enum 
     localVar6 = Salsa.class_enum.Entry 
 '    Dim localVar7 As Me.class_enum   '  full type name not allowed after AS
     dim localVar8 as class_type 
   End Sub 
 
   Sub meImplicit()
     dim localVar = publicInstanceVar
     dim localVar2 = publicClassVar 
     dim localVar3 = classConst 
     Dim localVar4 As class_enum 
     dim localVar5 as class_type
 
   End Sub 
   
   Sub classSub()
     const localConst = 6
     dim n = localConst
   End Sub 
 
   Sub classSubWithArgument(i as integer)
     dim localVar = i
   End Sub 
   
   Function classFunction() As String       
     return "hello"
   End Function 
 
   
 End Class
 
 
 
 CLASS rumba
 
   Public latein AS INTEGER


   PUBLIC SUB dance_rumba()
     Print "rumba!!!" 
     'print mySalsa.var
   End Sub 
 
   ' default constructor 
 
   Constructor rumba ()
     print "constructor"
   End Constructor
 
   Constructor rumba ( _latein as integer)
     Print "constructor2" 
     latein = _latein
   End Constructor
 
   Destructor rumba ( ) 
     print "destructor"
   End Destructor
   
   Static Sub myMsgBox(ByRef m As Double)  
     m = m + 1  
   End Sub 
  
   Static Sub myMsgbox2(Optional m As Integer)
     If IsMissing(m) Then
       m = m + 1  
     Else
       Print "do nothing"       
     End If
   End Sub 
 
   Static Function monique(ByRef i As Integer, ByVal h As Double, ParamArray b() As Variant) As Integer  
 
     For i = LBound(b) To UBound(b)
       Print b(i)     
     Next i  
   
     Return i
     
   End Function  
 
 
   static SUB structByReference(byref m AS address)
     m.name[2] = 71  
   End Sub 
 
 END CLASS
 
 
 DIM j(5 TO 10) AS address
  
 
 j(3).namer(6) = 123
 j(1).age.isbn(10) = 1000
 j[2].namer[1] = j(3).namer(6) + j(1).age.isbn(10)

 

 'Dim Emp As rumba = New rumba
 DIM r AS NEW rumba
 
 r.dance_rumba()
 
 'With r
 '  .dance_rumba()
 'End With


 Print globalVar ' accessable from everywhere 
 Print globalVar2 ' accessable from everywhere 
 Print globalConst ' accessable from everywhere 
 publicModuleVar = 99
 module1.publicModuleVar = 99
 
 'moduleFunctionRecursive(1)
' module1.moduleFunctionRecursive(1)
 
 Print publicModuleVar
 Salsa.publicClassVar = 111
 Print Salsa.publicClassVar
 print moduleConst 
 
 DIM m = 1 AS INTEGER
 

More information


KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V.Legal