'The KBasic Book' of 1st quarter 2006

THE KBASIC BOOK
YOUR GUIDE FOR THE DEVELOPMENT
OF YOUR

KBASIC APPLICATIONS

Page 1 of 143

'The KBasic Book' of 1st quarter 2006

First Edition
This edition applies to release 1.0 of KBasic and to all subsequent released and modifications until otherwise indicated in new editions. Make sure you are using the correct edition for the level of the product. The term „KBasic“ as used in this publication, refers to the KBasic prodcut set (January 2006).

Page 2 of 143

'The KBasic Book' of 1st quarter 2006

About this book
Welcome to 'The KBasic Book', your guide for the development of your KBasic applications. In this book you find all necessary information to build successfully your KBasic programs. If you completed the book, you will be able to write fast simple or complex KBasic programs whether with Qt-features or in simply standard BASIC only, and whether with or without modern graphic user surface with forms. It will assist you for nearly all problems of the programming everyday life. If you begin with KBasic perhaps you will relax with this book at a peaceful place and read the first chapters learning about the programming language. Later then, in a free moment, you will probably want to try out the examples of this book. However, the principal purpose of this book is to be lain beside the keyboard, in order to serve you as fast and-practical reference during programming. The less experienced KBasic programmer receives an extensive introduction to the programming language KBasic. The object orientated and other features of KBasic are explained by numerous examples of practical use of the most important objects and elements of KBasic. You will find a complete reference of the programming language inside KBasic's integreted development environment (KBasic Software Atelier) and therefore this book comes without a detailed reference. In the KBasic IDE you will find the complete and detailed listing of all objects, their events and procedures, methods and characteristics as well as a complete reference of all operators and commands. Apart from precise syntax definitions you will find a detailed explanation of the available parameters in each case there.

Page 3 of 143

Thanks to everyone on the Internet. In its spare time he goes dancing.berndnoetscher. in addition. This book is meant for people. who submitted corrections and suggestions. and I could not have done it without you: Thank you all! Page 4 of 143 . Java or Visual Basic developers. absolute programming beginners become easily get along with it. who want to switch to KBasic or want to extend their abilities heard that there is a new cool programming language for Linux and Windows and which they want to get in Besides this. About The Author Bernd Noetscher is software developer and the main developer of the KBasic programming language.'The KBasic Book' of 1st quarter 2006 Why You Should Read This Book This book is interesting for people with some BASIC background knowledge. who • • • want to learn a simple and powerful programming language for Linux and Windows (or Mac OS X in the future) are experienced C/C++. who bought KBasic Professional or has supported me otherwise and a big thanks goes to my parents. Special thanks goes to Nadja. you have been tremendousuly helpful in improving the quality of this book. you will feel very home. reads many books and plays piano. This book • Is the one you must have if you are doing serious development with KBasic • gives you a solid background in the fundamentals of KBasic • takes you step by step through the features of the languages Note Of Thanks I am very grateful to all people. His private webside is www. If you should be an experienced Visual Basic developer. who helped me to complete this book.de Supporter Thank you! Nadja Hepp for the proof reading of the the book and for beta tester and other supporters. He is also interested in theatres and cinema. my girlfriend and to everyone.

Only if we know them. In order to reach such high aim. Thank you very much. Thanks! Please note that we cannot help you with technical problems related to the topic of this book. This series will cover language references. We estimate your opinion and would like to know. introductory volumes and API references and also advanced topics of programming in KBasic. Too. We obliged us to document this exciting new technology with a set of new manuals.com – we would like your positive comments. Please write to info@kbasic. If we have made any mistakes. what pleases you or which better we could make. and that due to the high volume of mail we receive. Page 5 of 143 . is not good anymore! Not to stop to get better means for us. we can correct these mistakes. like databases and networks. because our primary goal is the satisfied customer. then write email to info@kbasic. into the bussines and among the developers. we need your help. we might not be able to reply to every message. to satisfy our customers' wishes.com. New set of manuals about KBasic KBasic was developed by KBasic Software and has aroused much interest in the Internet. If you found an error in a example program or in the text.'The KBasic Book' of 1st quarter 2006 Give Us Feedback I ask you to help me to improve this book. please tell us. As reader you are the most important commentator and critic of my book. Who who do not want to better anymore.

kbasic. Here the example: Dim i As Integer Important references and keywords are italically deposited: Arguments Sources for further information The manufacturer side of KBasic: www.'The KBasic Book' of 1st quarter 2006 Conventions used in this book / Way of writing normal text appears in writing Arial.google.com Information covering programming in BASIC: Internet archives about Visual Basic 6 for example.com Page 6 of 143 . search the Internet using www. Here is an example here: This is normal text Syntax and source code code appear in writing Courier New and grey background.

.................................................................... 22 Introduction to the KBasic programming language.............................................................................'The KBasic Book' of 1st quarter 2006 Table of Contents First Edition.......... 24 Interpreted.......................5 New set of manuals about KBasic................................................................. 21 Something You Need to Know..............................................................................................4 About The Author............................................................ 16 Why you should learn to program?.................................................................................................................................................................................................................................................................. is not good anymore!................................................ present and future..............................................................................................................................................................................................................................................................................................................6 Introduction................................................23 What is KBasic?...................................2 About this book............................................................................................................................................................................................................................................................................ 23 Briefly and well in a sentence.......... 19 Attack of the Bugs......................4 Note Of Thanks.................................................................4 Who who do not want to better anymore...................... 23 KBasic's past............................................................... 4 Supporter...................................15 The big mystery..................................... 23 Warning................................................................................................................................................................ 20 Is Programming difficult?................ 21 How much KBasic do I need to know to use it?........................................................................................... 18 Compilers and Interpreters.............................................................................................................. 24 KBasic is object-orientated........ 25 Page 7 of 143 ............................................................................... 23 Examples...................... 18 All Kinds of BASIC................5 Conventions used in this book / Way of writing................................................ 16 What is a Computer Program?..................................................................... 16 Programming Languages.....................................................................6 Sources for further information............................ 18 History of the Name............................................................................................................................................................................... 19 The Programming Process........................................................................................................... 3 Why You Should Read This Book...................................................... 24 KBasic is easy to learn....................................................... 4 Give Us Feedback.......

...........................................................................41 Declaration of Variables / Explicit declaration.................................... 46 Page 8 of 143 .......................................................................... and news?... 26 Why KBasic succeeds.................................................................34 Software development with KBasic........................................... 43 Use of the 'Public'-Statement................................................. 31 Starting KBasic.............................................................................. 28 Rapid application development............................................................... 37 Inheritance of classes............................................ 35 Object orientated programming with KBasic..................................................32 On which platform is KBasic available?.............................................................................................................................. 38 KBasic-Syntax............................................. 32 What is the difference between KBasic and Visual Basic 6?........................................................................................................................................................................... 45 Use of the 'Option Explicit'-statement (supported within 'Mode OldBasic' and 'Mode VeryOldBasic' only).......................................... 26 KBasic is fast............................................................................. 44 Use of the 'Static'-Statement...........'The KBasic Book' of 1st quarter 2006 Stable..................................................................40 Multi-Line statements............................................................................................................................. 30 Installation of KBasic / Installation description / System needs..........................40 Variables and DataTypes................35 Event controlled programming vs........................... 44 Use of the 'Protected'-Statement................................... 44 Use of the 'Private'-Statement.......................................................................................................................................................................32 Can I import existing Visual Basic 6 programs automatically?................ 41 Declarations of variables in different scopes...............33 KBasic is not only one programming language but also three...........37 Objects and classes.................... 26 A Simple Example............................. 45 Declaration of variables automatically / implicit declaration............................................ 30 KBasic Personal Version. ....................................... 32 Where can I find more information about KBasic? Examples....................................... 35 Three Programming Steps............................................................................................................................................................................ traditional programming....................................................................................................................................................................................................................................................................................................................................30 KBasic Professional Version.............................................................. documentation..... 29 How can I get KBasic?........................... 32 KBasic-Syntax.................................................................................................40 Statements and expressions.................. 31 FAQ......................................................................... 35 How does a event controlled application run?..............................................................................................................................................

.................................................................................................................................................................................................................... 57 Increment and Decrement...................................................................... 51 Suffix of variables................................................................................................................................ 61 Editing source code................................................ 63 Create a class...................................... Lifetime of variables........................................................................................................... 58 String concatenating.............................................................................................................................................................................................................................................. 64 Classes are not executed.................................................................................................... 58 Other Operators...................................................................49 Simple Data Types................................. 51 Type Variant..................................................................................................................................................................................... 62 Use of New...................................................................................................................................................... 63 Releasing objects automatically.....56 Operators for calculating.......................................................................................52 Way of naming................................................................. 59 Avoiding name collision.......................................................... 51 Comments...................................................... 57 Bitoperators............................. Assignment-statement.............................................. 66 Page 9 of 143 ..............................................................53 Literals......................................................................................................................................................................................................................................................................................................................................................... 59 Operator order...................................................................................................... 49 User defined types......................................................................................................................................................................................................................................................................... 57 Logical operators (Boolean Operators).. but methods are...54 Expressions........................... 64 Accessing class-variables and instance-variables............................. 65 Calling methods.........................................................................................................................................................................54 Constants........................... 64 Class-methods and instance-methods................... Place of declaration.............................................................................................................................55 Operators and Operands........ 64 Accessing objects.............................................................'The KBasic Book' of 1st quarter 2006 Local variables.................................... 56 Assignment-operators......................................................... 63 Releasing objects manually.......................................................................................................................................................................... 61 Working with objects.............................................................................................................................................. 62 Several Constructors................................................................... 62 Create new objects............................................................................................................................................................. 62 What happens when using 'New'?..................... 57 Comparision....................................... 63 'Null' (or 'Nothing')............... 46 46 47 47 Data Types..................................................................... 50 Class types/Objects:...............................................................................................................

.... properties.. 70 Casting of objects and simple data types............. 66 Summary: Objects...................................... 88 Optimize For................................................................................................................................................................................................................................ 87 With-Anweisung....... 90 Page 10 of 143 ............................................................................ 76 Scope modifiers.................................................................................................... 87 Unconditional jumping.............................. 71 Subclassing and inheritance.. 88 For Next....................................................... 71 Comparing objects................................................................ 79 Changing the lower bound........................................... 74 Dynamic-searching of methods.................................................................... 83 Single decision ............... 66 Creating object variables...................................................... 74 Calling an overrided method................... 81 Change the size of a dynamic array.................. 90 For Each........................................................................................................................................................................................................................................................................................................................ 80 Use of multidimensional arrays.................................................................................................................................................................................................................................................... 74 Hidding data.......... 69 Second time use of 'Parent'......... 78 Accessing array elements............................................................ 77 Arrays.......................................................................................................................................................... 73 Hidden Methods.................................................................................................................................................................................................................. 84 Select Case............................... methods and events........................................................................................................................................................................................................................ 88 Loop-statements....................'The KBasic Book' of 1st quarter 2006 References to objects................................................................................................................. 80 Save 'Variant'-values in arrays.................................. 69 Use current instance or object / Me / Parent.............................................If................................................................. 81 Array-reset / array-delete.......................................................................................................................................... 76 Abstract Classes and Methods......................................................................................................................................................................... 66 Copying objects................. 78 Different kinds of arrays................................................................. 72 Constructor chaining...................... 82 Control of the program flow.......................................................................................... 87 Choose – short select case................. 71 Asking about objects and classes.........................................................................................................................................................83 Decisions...................................................................................................................................................................................................................................................................................................................................... 83 IIf – short if..... 71 Implicites Upcasting und downcasting............................................................... 77 Overview about the builtin KBasic classes................................ 68 Assignment of objects to an object-variable................................ 68 Declaration of an object variable......................................................................................... 73 Overriding methods.......................... 79 Getting lower and upper bound............................................................................Next-Loops............................................................................................................................................................................. 73 The default constructor............................................. 85 Switch – short select case.................................................................................................. 79 Explicitly declaring the lower bound............................................................................................................................................................................................................................................................................................................................................................................................. 78 Declaration................................................. 73 Hidden Variables.................. 66 Comparision of objects.........

............................ 102 Leave procedure.............................................................. 108 Private module scope............................................................................................ 95 While................. 104 Data Types of functions.................................. 105 Properties.................................................................................................................. 95 Explicitly leave a loop................................................................... 91 Do While..........'The KBasic Book' of 1st quarter 2006 Other kind of loops........................................................................ 104 Event procedures..............................................................................................................................................................................Loop...............................End Type)....................................................................................................End Enum)..............................................................................98 Sub-Procedure................................................................................................................................................ 97 Procedures................ 111 Page 11 of 143 ... 94 Do.................... 99 Arguments...............................................................................................................106 Conversion..................................................................108 Local scope........................................................................................... 94 Do Until............................................................................................................................................................................................................................................................................ 98 Function-Procedure ............ 104 General procedures......................................................... 103 Overloading of procedures..............................................End While..........Loop....... 96 Explicitly leaving without Testing condition............................................................................................................... 105 Function Return.....................................110 Enumeration (Enum..................... 102 Call of procedures with same name................. 109 Public module scope....... 95 While Wend............................... 92 Do................................................................................................ 96 Nested control structures............... 99 Named and optional arguments......................................................................................................................................................110 Classes........................................................................................................................................................ 101 Call of sub-procedures and function-procedures.......................................................................................................................................................................................................................... 104 Functions..... 109 User Defined Data Type (Type............................................................................................................................................Loop Until......................................................................................................................................... 103 Use of brackets while calling a function-procedure............................................. 103 Writing recursive procedures........................................................................... 101 Add comments to a procedure......................107 Modifiers / Scopes........................ 102 Calling procedures with more than one argument.................................................................................................................................... 111 Classes unlike procedures are not executed........................................................ 111 Edit Class........ 102 Hints for calling procedures.................................................................................................................................................................................................................................................................................................................................................................... 100 Writing function-procedure...........Loop While..................................................................

................................... 131 OpenGL.... 131 Commercial software...............................................129 What are the main functions of the virtual machine?............... 122 Exception at the end of a procedure..................................................................................................115 Global Modules.....................128 Migrating from VB6 to KBasic............................................................... 125 Editor................................................................................................................................... 121 Try.................................................................................................................................................................................................................................... 123 The KBasic development environment...................................................................................................................................................................................................................................................................................... 131 License issues................................................................................................................. unlike procedures are........................ 129 Network and TCP/IP..... 125 Debugger.................................................. 115 Edit Module............................... 125 Collection............................................................................................................................................... 121 Finally......... 115 Error handling............................'The KBasic Book' of 1st quarter 2006 Module................................125 Windows............................................................................................................................................................................................................................................ 121 Define and generate exceptions......................................................126 Projects................................................................................................126 Central meaning of forms........................................................................................................................................................................................................................................... 126 Procedure in forms............................................................. 127 Compatibility VB6 = KBasic................................................................................................................. 129 Qt-Bindings....................................................................................... 126 Forms....................... 121 Exception handling..................................................................129 GUI...................................................................... 131 About Trolltech................ 132 Page 12 of 143 .........................119 Exceptions..................................................... 120 Exception-objects..................................................................................................................................................................................................128 KBasic's virtual machine.......................................................................126 Classes and objects of KBasic.......................... 121 Catch............... 125 Toolbars........................................ 121 Declaration of exceptions.............................................................................................................................................................................................................................................. 115 Modules are not executed............................................................................. 130 SQL .................................................................................................................................................................................................................................................................................. 130 XML .....................................................................................................................................................................................

............ 138 Data Type.............. 139 Long..................................... 135 Command arguments for KBasic........................................................................................................................................................................... 140 Page 13 of 143 ................................................................................................................................................................................. 138 Decrement............................................................................................................................................................................................................................................................................................................ 138 Double............................................................................................................................................................................................................................................................................................................................. 139 Literal................. 133 Keywords.......... 137 Array............................................................................................................................................................................................................................................................................................................. 139 Local Variable........................................................................................................................................................................................ 138 Debugging................... 138 Form....................................................................................................................................................................................................................................................................................... 139 Infinite Loop............................................................................. 137 Conditional Branch........................................................ 139 Logic Error.......................127)....................................................................................................................................................................................................................................................................................................................... 140 Machine Language........................................... 138 Empty String..................................... 137 Arithmetic Operations.......................................................................................................................................................... 133 Builtin Functions............................................................................................. 139 Increment................ 139 Initialize........ 138 Floating Point........ 137 BASIC............................................................................................... 137 Boolean........ 138 File.................................... 137 Bit...................................... 137 Breakpoint................................................................................................................................................................................................................................................ 139 Interpreter...........................136 Appendix ...................................................................................................................................................................................................................................................................... 137 Concatenate.......................................................................................................................................................... 139 Logical Operator.................. 139 Global Variable.................................................................................................. 140 Loop Control Variable........................ 134 Types............................................................................................................................................................................................... 138 Event................................................................................................................................................................................................................................................ 138 Constant.................................. 138 Executable File..... 134 ASCII-Codes (codes 0 ..................................................................................................................... 137 Boolean Expression..........................................................................................'The KBasic Book' of 1st quarter 2006 Lexical Unit.................................................................. 139 Integer............... 137 Byte.................................................................................................................... 137 Compiler........... 137 Branching............................................................................................................................................................................................................................................................................................................................. 140 Mathematical Expressions.............................................. 137 Argument................................ 138 Function............. 140 Loop.................................................................................................................................................... 133 Operators.................................................................................................................

............................................................. 141 Scope..................................................................................... 140 Numerical Value......................................................................................................................................... 142 Subprogram....................................................................................... 141 Single.............................................................................................. 141 Relational Operator................................................... 140 Parameter................................................................... 142 User Interface................. 142 Variable............................................................................................ 141 String.............................................................................................................................................................................. 140 Procedure................................................................................................................................................................................................................................ 143 Page 14 of 143 ....................... 140 Numerical Literal............................................................................................................................. 141 Source Code.............................................. 141 Property........ 142 Variable Scope..................................................... 141 Program............................................. 140 Object.......... 142 Variant.............................................................................. 141 Program Flow..................................... 141 Programming Language.... 141 Return Value...............................................................................................................................................................................................................................................................................................................................................................................................................................'The KBasic Book' of 1st quarter 2006 Method..................................................................................................................................... 142 Unconditional Branch....................... 142 String Literal......................................... 142 Impressum....................................................................... 141 Read-Only Property................................................................................................................................................................................................................................................... 140 Order of Operations.................................................................................................................................................................................................................................................................................................................................................................................................. 141 Runtime Error.....................................................................................

In either case. not difficult. if you did not hold KBasic for an important new technology. rewarding and. or you might realize that you know as much about programming a computer as you do about building a plane.'The KBasic Book' of 1st quarter 2006 Introduction You heard probably already much about KBasic. Whatever your ideas about programming.. it might help to have a basic understanding of what it is all about. or you would not have got this book to begin with. You would not read this book. it is worth it. You get new gray hairs every time you try to write a simple script file? If you feel this way. You propably have some ideas about what a program is and how it works. 'The KBasic Book' is here to prove that programming your computer is fun. Before you get started with developing computer programs. most important. After reading this introduction. waiting to get out. You might have found computer programming not only intimidating but downright frightened. Page 15 of 143 . Now it provokes you to write your own KBasic programs. you may find that your knowledge about programming are pretty good. this introduction gives you the knowledge... Have you ever wanted to know how a computer program works? Did you ever want to sit down at your keyboard and create digital magic on your computer’s screen? If so. there might be a computer programmer somewhere inside you. You now already probably downloaded yourself the Personal Edition of KBasic and played a little with the sample programs..

You might have a better one. your Page 16 of 143 . until it reaches the end of the program. thousands. a computer can do absolutely nothing on its own. Without programmers. which in turn provides instructions to the computer. when you sit yourself down in front of a word processor and hack out a letter to your loved person. you will find out this means computers can only do tasks that humans already know how to do. you must learn to write programs. In all those cases. That is not to say when you use your computer you are programming it. it is as true as the sky not red. When you put hundreds. Frankly. You are only using the commands contained in the program. Developers. you will probably find this secret hard to believe. of course. after you get started with programming. Each command does only a very small task.'The KBasic Book' of 1st quarter 2006 The big mystery The computer-programming world has a well-kept mystery. You probably use your computer for many activities besides word processing. you will find it can be both fascinating. such as organizing data in a spreadsheet. The bottom line is that if you want to give commands directly to your computer. one by one. The computer follows these instructions or commands. are the people who tell computers what to do. you run a program. you are not giving commands to the computer. Only you know what it is about computer programming that makes you want to learn it. or even hundreds of thousands of these commands together. You are about to uncover a interesting fact. but that they can perform endless calculations in seconds. You will not hear programmers talking about it. or maybe even for playing computer games. Nevertheless. computers are as useless as cars without gas. Why you should learn to program? There are as many reasons for learning to program as there are people in the world. If you have been using a computer for any time at all. As a computer user. But some reasons are you want to • • • • • learn programming for work or school be able to write the programs you really need learn more about how computers work impress your friends or girlfriend or even boyfriend You are looking for a fun and rewarding hobby These all are good reasons. such as printing a name on the screen or adding four numbers. If you think for a minute. you are at the top of the heap. interesting and addictive. Each line in a computer program is usually a single command that the computer must do. but whatever your reason. So why are computers are great? The good thing about computers is not that they are smart. Computers are stupid. Computers can do only what they are told to do. What is a Computer Program? A computer program is just a list of instructions that tells a computer what to do. which was written by a programmer. It is the computer program. that actually tells the computer what to do. For example.

All these software packages allow you to create computer programs with BASIC. of which KBasic is only one.'The KBasic Book' of 1st quarter 2006 computer can do great things: calculate mathematical problems very fast. print a document. the computer language upon which KBasic is based. instead thinking as a machine you can think as an human being. Page 17 of 143 . KBasic enables a programmer to visually assemble a program’s window from parts in a toolbox. which was developed not to help computers. The BASIC acronym stands for Beginner’s All-purpose Symbolic Instruction Code. which is entirely composed of numbers like 1 or 0. However. How it is possible that the computer can understand and run BASIC? The solution is. there exist many kinds of computer languages. therefore. including Java. you are also loading a compiler. Even KBasic uses this spelling. But programming languages like BASIC allow people to write programs in an English-like language.. As you see in the next paragraph. when you load KBasic. BASIC actually started out as an acronym.. KBasic programs are a dialect of the BASIC computer language. must be converted to machine language before the computer can understand them. Your computer would not have any idea what to do with your program. Programming Languages Computers do not understand German or English or any other human language. All Kinds of BASIC There are many versions of the BASIC language. or play 'SimCity'. But all computer languages have one thing in common: They can be read by humans and. Moreover. without the compiler’s interpretation of your programs. However. the the BASIC interpreter changes into machine language so the computer can understand it. History of the Name Sometimes. All in all. KBasic replaces many of the numbers used by machine language with words and symbols we humans can more easily understand and remember. but they all implement the BASIC language slightly differently. computer programs can be written in one of many different programming languages. which is a special program that takes the words and symbols from a KBasic program and translates them into machine language the computer can understand. So it is much easier for you to communicate with your computer as an software developer. They cannot even understand BASIC. Newer versions of DOS came with QBasic. which is why you also see the name spelled in all capital letters. You can also go down to your local software store and buy Visual Basic. draw pictures. Computers understand only one thing. of the versions of BASIC mentioned here. KBasic enables you to write Linux applications and not applications for Windows only (Mac OS in the future). C++ and BASIC. but to help people make sense out of the numerical nonsense machines think in. machine language. A BASIC program uses symbols and words (and a few numbers) that people can understand. you see the name of the BASIC language spelled with lowercase letters like this: Basic.

3. Only when a program crashes or does something else unexpected can we hope to find those errors that hide in programs. such as Java and KBasic. Most of the steps in the programming process are repeated over and over again as errors are discovered and corrected as you can see. 2. Create the program using KBasic’s toolbox and source code editor. The following list outlines these possible steps: 1. It is important to do the fine-tuning. Most of us are lucky if we can remember our presidents' names. Come up with a program concept and sketch out on paper how it might look on the screen. convert a program to machine language one line at a time as the program runs. without a compiler or interpreter. such as some types of BASIC. 4. Run the program and see how it works. Go back to step 2. use a compiler to convert the entire program all at once before any of the program runs. Even experienced programmers cannot write error-free programs or the program is extremely short. most computer programming languages have a compiler. After you start writing full-length programs. The Programming Process Now that you know something about computer programs. An executable program is actually a machine language program that is ready for your computer to read and understand. which is a large information base for all kind of developers. 5. In any case. Save the program to disk. all programming languages must be converted to machine language in order for the computer to understand the program. You will find some ideas in the Internet. our minds are incapable of remembering every detail required to make a program run perfectly.. It is also possible to write computer programs in other ways as described above. Other languages. because there exist some kind of mixed forms of both like Java or KBasic is. Programmers often spend more time fine-tuning their programs than they do writing them initially.. Writing a KBasic program requires development steps similar to those you use when writing a paper or report. With few exceptions. because we humans are not as logical as we like to think. Page 18 of 143 . though it can be a long process. Computer experts say there is no such thing as a program without bugs. Fix programming errors. 6. how do you go about writing one? Creating a computer program is easy. But today it is also difficult to distinguish between compilers and interpreters. A compiler changes your program into an executable file that can be run directly.'The KBasic Book' of 1st quarter 2006 Compilers and Interpreters Some computer languages. you will see how true this statement is. Moreover.

you must have good knowledge of how your computer works. step by step. the Internet. and even your friends and colleagues. if you want to make programming a career. sometimes these programs need simple to extensive modifications and this is where real challenges to your programming expertise occurs. or even computer games. yes and no. and program bugs. you got this book. The KBasic language is logical. You can drop these programs into KBasic and have an apllication ready to use. For example. And. whether you are interested in writing utilities. Page 19 of 143 . Still. Additionally. you might be a little uncomfortable. After all. All you need is the time: • • to read this book and the ambition to write a few programs of your own. Actually. and easy to understand. you will discover programming in KBasic is not as difficult as you might have thought. you must have spent many years learning the skills of professional computer programming. It is easy to learn to write little programs with KBasic. However. which took dozens of programmers many years to write. small applications. he or she must be certain that he or she has squashed as many bugs as possible. compilers. there is a lot you can do with KBasic. English-like. How much KBasic do I need to know to use it? It is possible to develop KBasic programs without having to write any lines of source code. consider a word-processing program such as OpenOffice. No one warned you about such mysterious topics as machine language. However. you can write many useful and fun programs. what you will learn in this book is enough programming for just about anyone who is not planning to be a professional programmer. Is Programming difficult? After reading all that is involved in writing and running a computer program.'The KBasic Book' of 1st quarter 2006 Attack of the Bugs Bugs are programming errors that stop your program from running correctly. such as books. Is programming easy or not? Propably. which means to correct many errors as possible. interpreters. because it promised to teach you computer programming in KBasic. you have much to learn that is not covered in this introductory book. To write such complex software. With only minimal practice. There are many places to obtain KBasic programs. Before a programmer can release his or her program to the public.

KBasic’s compiler does this conversion Writing a program is a lot like writing a text document. Many of the princible and concepts of KBasic are based upon those found in C++. a basic understanding fo structured query language SQL and client -server models is necessary to build more complex database-aware KBasic programs. it is important to know what computer programs are and how they work. You should remember the following points: • • • • • • A computer can do only what a human instructs it to do There are many computer languages. Page 20 of 143 . There are also some vast differences between KBasic and C++ that you should know about. If you are using databases. You must write several drafts before the program is complete and ready Programming with KBasic’s is as easy or as difficult as you want it to be What makes it more easy for you to understand KBasic: You should have a basic understanding of object -oriented programming such as C++. as well as make it easier to locate errors in your programs. The language you learn in this book is a form of BASIC A computer program is a list of commands that the computer follows from beginning to end A BASIC program must be converted to machine language before the computer can understand it. Such background knowledge will help you to understand why KBasic does some of the things it does. as well.'The KBasic Book' of 1st quarter 2006 Something You Need to Know Before you dig into writing your own programs with KBasic.

'The KBasic Book' of 1st quarter 2006

Introduction to the KBasic programming language
Hello and welcome to the KBasic programming language. This chapter is concerned with • what exactly KBasic is • why you should learn KBasic, the characteristics and advantage opposite to different programming languages • first steps inside KBasic, which background knowledge is needed and some basic knowledge • how to write your first KBasic program What is KBasic? KBasic is a powerful programming language, which is simply intuitive and fast easy to learn. KBasic also represents (developed for Linux and Windows) a further bridge between Linux and Windows. KBasic a new programming language, a further BASIC dialect, is related to Visual Basic 6 and Java. More exactly said KBasic s an objectoriented and event-controlled programming language, developed by KBasic Software (www.kbasic.com), is particularly designed for the needs for Qt-developers and has thus a strength in the Qt-application development. For C/C++ developers BASIC has generally a bad reputation as child programming language that is not true becomes clearly with this book. With KBasic you can write nearly all applications, which perhaps would have been written by you in C/C++, if there were not KBasic. Briefly and well in a sentence KBasic is a easy-usable, object-oriented, interpreted, stable, platform-independent, fast and modern programming language. Warning In order to have compatibility to future version of KBasic, you should avoiding certain old elements of the KBasic language, which are still supported for historical reasons. Use instead the modern elements of the language. You can find more details in the respective help entries. Please consider also the references to the migration from Visual Basic 6 at the end of this book. In addition, only the new, current and modern language features are described in this book, since many language elements are only supported for historical reasons by KBasic, e.g. 'GoSub', 'DefInt', 'On Error GoTo' are outdated elements of the language and therefor are not described in this book. Examples The examples in this book are in English. Page 21 of 143

'The KBasic Book' of 1st quarter 2006 KBasic's past, present and future KBasic was originally developed as open source software. The project was started by Bernd Noetscher in summer 2000. After many disappointments, because of lacking support by volunteers, he decided to develop the programming language as a commercial product for Linux and Windows to guarantee that the high requirements for the product are completely fulfilled. At present, KBasic version 2.0 is under construction, which is more user-friendly, more efficient, and has more programming libraries and new object-oriented features. What is still needed to know about KBasic?

KBasic is object-orientated That means for you as a programmer that you concentrate on the data and on the methods in your application. How to manipulate the data, instead of thinking only in procedures. If you are familiar with procedural programming in BASIC, you will probably get the conviction that you must change the kind, how you write your programs, if you use KBasic. But you do not have to use it that way. You can program further with procedures only. If you get to know with it how powerfully this new object-oriented paradigma is, you will get used to it, because you will see how easy it is to develop re-useable complex application programs clearly and in a modular way. KBasic is object-oriented regarding the binding to C++ programming libraries such as Qt, or builtin KBasic classes, with true inheritance. Contrary to other programming languages KBasic is designed from the beginning as an objectoriented programming language. So most things in KBasic are objects; the simple data types, like numeric, strings and boolean values, are the only exceptions. Although KBasic is designed in such a way, that it looks similar to VB6, you will notice that KBasic avoids many problems of VB6 in an elegant way.

KBasic is easy to learn KBasic is an easy language. A design aim of KBasic is the simple use. Fast development, easier error tracing and easy to learn. KBasic is modelled after standard BASIC, is syntax compatible to Visual Basic 6 apart from the Visual Basic components and is because of that very familiar. Thus the migration is simply and fast. KBasic contains object-oriented ideas of Java and C++, whereby confusing elements were omitted. KBasic uses (as in Java) references instead of pointers on objects, in addition the garbage collector manages completely automatically the memory allocation as simple as possible for the programmer. You do not have invalid pointers and memory leaks, instead you can spend your time in the development of your application's algorithm and its use. KBasic is actually a complete and an elegant programming language.

Page 22 of 143

'The KBasic Book' of 1st quarter 2006 Interpreted KBasic produces pseudo code instead of machine code. In order to run a KBasic program you can use the KBasic development environment (IDE) or the menu entry 'Make Runtime' (only in the Professional version). KBasic is thus a interpreted programming language. KBasic pseudo codes is an architecture-independent format: the code was designed to run programs efffizient on different platforms.

Page 23 of 143

KBasic is in the middle of these languages. you can place all your error processing routines at one place. e. Though KBasic is not as fast as a C compiled program. KBasic is a typed language. The exception handling is one other new possibility: KBasic offers the feature to write more stable programs. KBasic is 20 times slower than C. Actually. Similarly. Of course. which excludes the danger to make memory useless and overwrite data. On one end are highlevel fullinterpreted languages like PHP and UNIX-shells. than highlevel programming languages. which makes it easier to manage and fix errors. Why KBasic succeeds Page 24 of 143 . In addition. so that it is more easier to write reliable software. you should keep in mind. that this speed is fast enough for nearly all kind of GUI applications. but have the easiness and portability of those languages. which enables KBasic to do very detailed examinations of the potential type inconsistencies in your KBasic program. which occurs like an error. It is still possible to write unreliable software. One of the most important characteristics regarding the reliability is the memory management. However KBasic eliminates certain kinds of programming errors. When you use the try/catch/finally statements. KBasic's garbage collector prevent from memory leaks and other malicious errors with dynamic memory allocation and deallocation. An exception is a signal for a exceptional program condition. On the other end are the fully in machine language compiled programming languages. But instead of running away. the KBasic interpreter examines at run time different things. which often wait for the user to input something. but are not very portabel or relying. Studying the power of KBasic it is important to think about the placement of KBasic between the other programming languages. it is a platform-independence environment. These languages are very useful to create a draft. The performance of KBasic's performance is much better. KBasic is fast KBasic is an interpreted programming language.'The KBasic Book' of 1st quarter 2006 Stable KBasic is designed to have the possibility to write very reliable durable software. too. KBasic makes quality control not unnecessarily. So KBasic is more strictly typed than standard BASIC. which provides the ability to write stable programs for Windows and Linux (or Mac OS in the future). Therefore. These languages provide extreme fast programs. but they are slowly executed.g. it will be never as fast as a machine-code compiled language. whether arrays and strings are still within their borders. like C. KBasic does not support pointers.

programming languages have suffered form the attitude that you should abandon everything you know and start from scratch with a new set of concepts and a new syntax. KBasic is very similar to VB6.'The KBasic Book' of 1st quarter 2006 Traditionally. a lot of that baggage was valuable. not a complete new syntax and programming model. you can continue to be productive with what you already know while moving into the world of object-oriented programming. applying the features gradually as you learn and understand them. Page 25 of 143 . This may be true. but instead the existing mind base. If you are functioning VB6 programmer and must drop everything you know about VB6 in order to adopt a new language. in the long run. As everyone has his or her own mental model of programming. Whereas if you can leverage off of your existing VB6 knowledge and expand on it. This may be one of the most important reasons for the success of KBasic. But in the short run. The problem with learnig a new language is producitvity. arguing that it is better in the long run to lose all the old baggage that comes with it. It allows you to continue creating useful code. No company can afford to suddenly lose a productive software engineer because he or she is learning a new language. you immediately become much less productive for many months. most of your existing VB6 code is still viable in KBasic. until your mind fits around the new praradigm. The most valuable elements may not be the existing code base. this move is messy enough as it is withouht the added expens of starting with a new language. In addition.

_@ @ \ " /@ _. @ :=: @ .'_..'./ " ". now let us go on to the next chapter. Here is the all loved favorite „Hello World“: ' program beginning CLS Print Print Print Print Print Print Print Print Print Print Print Print Print Print Print Print Print Print "Hello World!" " " " " " " " " " " " " " / `. `=. let us stop discussing abstract prhases and let us study a concrete KBasic code example. After running it in KBasic you will see a nice butterfly on your screen.' '-._`.' = @./ " \..: = :._ .'@`.' \" '.@ `'.'/ " \ '=.-' : = : '-. _._@_/ " / @ @_.'.`@`.=` .(*). \ / .' @.-': = :'-.==. Ok._.'='.: = :.@_.' @.' @._.. \ / . . \ / . you just did your first kbasic program!" Input these lines into a new KBasic code window.'@ / " \.@ `.'The KBasic Book' of 1st quarter 2006 A Simple Example Enough! Now.=' / " \ @ './ " \`. what it is all about KBasic.@ = `.._@.-' '.'" \ @`._ @\ " /`'@ @ .@ `. Page 26 of 143 .@ @`'`\ " \.'` @.-: = :-.==.' @ / " \_@_. you have a good insight.@ `.

a program element is one of the following: • Project: the top-level program element in KBasic. Specifically. In the Form designer you point and click to: • design the user interface for your programm • specify the behavior of the user interface elements • define the relationship between the user interface and the rest of your programm In addition to its visual programming features. A project contains classes. class or method Page 27 of 143 . modules and forms. • Form: the KBasic visual programming feature • Class/module: the KBasic language construct.'The KBasic Book' of 1st quarter 2006 Rapid application development You can use KBasic for visual programming features to quickly develop KBasic applications. In KBasic. KBasic gives you the ability to do quickly many tasks. • Importing code from the file system and exporting code to the file system KBasic gives you the programming tools that you need to develop industrial-strength code. • Sub/function/method: the KBasic language construct. you can: • use the completely intergrated visual debugger to examine code while it is running • browse your code at the level of project. Classes contain methods and other statements. including: • creating new program elements.

kbasic. You can get it directly form its maker www. roughly $25 US Dollar). and a license. where you can purchase it for 24. The buyer get two program versions: one for Windows and for Linux.95 Euro (inclusive shipping costs.com KBasic Personal Version There is also a free downloadable Personal Edition. with which you can try all of the program examples of this book.com/download. write an email to: sales@kbasic. If you have got related questions.html Page 28 of 143 . which is for Windows and Linux and the right to write as many commercial programs as it is wished without paying fees.com. Download of the Personal Edition on: www.'The KBasic Book' of 1st quarter 2006 How can I get KBasic? KBasic Professional Version You can buy KBasic Professional.kbasic.

Officially supported are: • Windows XP/2000 • Linux with KDE >= 3. True Color Starting KBasic You can start KBasic by doing one of the following: • on Linux. and viewing the contents of program elements. This window is used for accessing other windows. select KBasic in the program menu Now that you are up and running: After you start KBasic.'The KBasic Book' of 1st quarter 2006 Installation of KBasic / Installation description / System needs KBasic is easy to install. creating program elements.3 (or Qt >= 3.3) KBasic will not run on the following systems in the future: • Windows 95/98/Me You need at least 64 MB RAM and your CPU should run at least at 400 Mhz. the main window of KBasic appears. Screen resolution: 1024*768. has got an installer and needs all in all about 200 MB space on your harddisk. 32bit.3.3. Page 29 of 143 . select KBasic in the program menu • on Windows.

com. forms or only functions or subs. e. (e. KBasic provides addtional object orientated features and extension like direct Qt support. Meanwhile you can manually copy your files and open them in KBasic. Other users like Macintosh-users have to wait for the planned release of KBasic for their system. Besides this.g. to inherit from them and to create objects from classes.kbasic. A KBasic program contains of one or more classes. Furthermore. KBasic contains all syntax elements of VB6 and supports controls and other components very equal to VB6. modules. there existed versions of KBasic for Linux and Windows. Lots of Visual Basic 6 websites or BASIC archives listen useful program examples. it is not needed. which can easily used inside KBasic with some minor changes. documentation. One of the main differences between KBasic and VB6 is that KBasic is a true object-orientated programming language with the possibility to define classes. which would need such functionality. Visual-Basic 6 is fully supported as its syntax is fully supported. Can I import existing Visual Basic 6 programs automatically? KBasic will include a VB6-converter in the next major release of KBasic.g. because KBasic is a platform-independent programming language and therefore there do not exist any platform-related dependance. Furthermore. Changed sizes are: 'Boolean' is 1 Byte. '#ifdef' and '#if'). On which platform is KBasic available? At the time of writing this book. except that their size might changed. you can get news and new information on www. what makes it easy for VB6-developer to learn KBasic. Page 30 of 143 . the simple data types are the same. and news? First read this book. The pre-processor or the mechanism of exception handling. KBasic does not support a pre-processor. Where can I find more information about KBasic? Examples. Theoretically. 'Integer' is 32bit and 'Long' is 64bit in KBasic. global functions or subs and global variables. Programming examples are many out there in the Internet.'The KBasic Book' of 1st quarter 2006 FAQ What is the difference between KBasic and Visual Basic 6? KBasic is very equal to VB6. But there are also some important differences between KBasic and VB6. but this is planned for the future. As in VB6 it is possible to have a global namespace.

. Option Compare Text Syntax of the 'Dim'-Statement Dim VarName[([Indexes])] [As Type] [. which are needed to correctly use the sub. thirdVar Page 31 of 143 . context]) Arguments. All arguments must be separated by a comma. VarName[([Indexes])] [As Type]] . Example: Syntax of the MsgBox-Function MsgBox(prompt[. The following statement defines that text will be compared and sorted without case sensitive. title] [. 0. You must write them exactly in the same order they occur in the syntax. Example: MsgBox("The answer is right!". you do not have to ignore the position written in the syntax. what you have give the MsgBox-Function is the one for the showing the text: 'prompt'. function or statement in the KBasic help entry shows all elements. Option Compare {Binary | Text} In the syntax of the 'Option Compare'-statement: { } together with | means that one of the elements must be written. function or statement. In order to use the arguments defined with their position. The following statement creates three variables: myVar. "window with answer") If you would like to use a argument with its name. The only needed element is VarName (the name of the variable). Dim myVar. The only argument. helpfile. 'Dim' is a keyword in the syntax of the 'Dim'-Statement.. Example: MsgBox(title:="window with answer". prompt:="The answer is right!") Some arguments are written inside of {} in the syntax of functions or subs. How you can understand those information shows the following lines. Arguments for functions or subs can be used with the help of their position or their name. (Do not write these [ ] in your KBasic code). are optional. You can write these named arguments in any order you wish. nextVar.(Do not write these { } in your KBasic code). which are inside of [ ].'The KBasic Book' of 1st quarter 2006 KBasic-Syntax The syntax of sub. These variables are declared as 'Variant'-variables automatically (or 'Double' in 'VeryOldBasic Mode'). nextVar and thirdVar. use the name of the argument and colon and equals sign (:=) and the value of the argument. buttons] [.

Only z has the 'Integer' data type. if you want to declare an array variable. The following statement declares a dynamic array named myArray. y. If you declared the data type of the variable explicitly. Default is 'Option KBasic'. you should declare every data type of each variable explicitly. Through one of the following command you can switch KBasic into one mode: • If you want to use KBasic newest features use (default) Option KBasic • If you want to use old VB6 code use Option OldBasic • For very old BASIC code like QBasic you should use: Option VeryOldBasic It is possible to use all three modes in one of your program. Dim myArray(100) Dim myArrayModernStyle[200] KBasic is not only one programming language but also three. Dim x As Integer. Variables without declared data type get the default data type. one module uses one mode and the other module of your program use another mode. it will help KBasic to optimize the RAM-usage and will help you to find errors in your code. Dim x. The indexes of the array are optional. e. Just place one of these lines in top of your module. Page 32 of 143 .'The KBasic Book' of 1st quarter 2006 The following example declares a variable of type 'String'. z As Integer X and y get in the data type 'Variant' in the following statement. which is 'Variant'.g. y As Integer. Dim myAns As String If you want to declare many variables in one line. z As Integer You have to put ( ) or [] (modern style).

key pressed) or by your code (e. Compile the program into an executable file that can be run as a standalone application (able to run without being loaded into KBasic – only Professional Version of KBasic). just like any other application you may have installed on your computer. The application waits for the next event Some events automatically raise other events. The three steps are as follows: 1. which makes the program do what it is supposed to do 3. Three Programming Steps Creating a simple KBasic program is easier than goosing a running cat. More information are provided in the help of KBasic Software Atelier. 3. you can write for this event an event-procedure. after which you will have a program that can be run outside of KBasic’s programming environment. How does a event controlled application run? A event is an action.'The KBasic Book' of 1st quarter 2006 Software development with KBasic A typical KBasic-Application consists of forms. A user starts the application 2. In order to get a control to react on an event. which leads to the execution of the event procedure. procedure-built program is running. The user does some action and your program reacts on that. which should be executed. You can react on such events by assigning KBasic-code to such events. which are recognized by your forms or controls. You need only complete three steps. traditional programming When a traditional. In event controlled applications an action is done by the user or system event. The application starts with the firts code of line and goes through its source codes as the developer has defined. which together are your application.g. if your code opens a form). Create the program’s user interface 2. event 'Open'. Objects in KBasic knows some predefined events and reacts on them automatically. module and classes and other objects. Event controlled programming vs. Write the program source code. ignoring the events. This can be done by the KBasic Software Atelier Binay Compiler. The order in which the code is executed depends on the order of the events. which occurs depending on the user actions. the desired event code is executed 4. and also changing values in controls or clicking on buttons by the user generate events. The event can be raised by an user-action (e. Forms and their controls. The form or control in the form receives an event. This is the principle of graphical user interfaces and event controlled programming. If needed some procedures are called. the application itself controls the parts of the program.g. A typically application is running like the following: 1. Page 33 of 143 . If there is a event-procedure for the event.

'The KBasic Book' of 1st quarter 2006 Of course. there are many details involved in each of these three steps. Page 34 of 143 . You might even go back to step 2 from step 3 if you discover problems after compiling your program. you will also frequently go back from step 2 to step 1 to fine-tune your user interface. you will complete these steps in the order in which they are listed above. especially if you are writing a lengthy program. However. As you work.

Object orientated is an issue. cars consist of many objects like window. you do not must be scared. Object orientated programming means that every object is part of another object. It contains issues like • • • What are classes and objects and how are they related to each other The behaviour and attributs of classes and objects Inheritance of classes and how the design of programs are affected Objects and classes KBasic is an object orientated programming language. constants or variables. which are the instances of a class. which has been used so many times. If you do not know any concepts here. that it has simply no concrete meaning at all. An instance of a class is also called an object of a class. Object orientated means in KBasic terms following ideas: • • • • • • • Classes and objects in KBasic Creating objects garbage collection to release unused objects The difference between class-variables and instance-variables and the difference between class-methods and instance-methods The extension of classes in order to create a sub-class (child-class) The override of class methods and polymorphism when it comes to calling methods Abstract classes If you are a Java-developer or a experienced developer in another object orientated programming language. Therefore. but many objects window or steering weel. you will know many of the concepts of KBasic. which contains to a class. steering weel and so on.'The KBasic Book' of 1st quarter 2006 Object orientated programming with KBasic Object orientated programming is one of the most important concepts of the last years and has become a most used technique. There is only one class (building plans) for window or steering weel.. constants. like in real world.) • Methods Parent-class means that all attributes and methods of the parent-class are also in the new class addtionally to attributes and methods you declared in this new class. objects are created when your code is running by KBasic using your classes! Every class has got the following elements: • Parent-class • Attributes (variables. Page 35 of 143 . there exist a class window and a class steering weel. because it is not very difficult to get along with objects and classes at all. Classes exists when you write your code. Exactly.. Attributes can be properties.

Like in Java. In the far future. Instance-variables are like local variables of a procedure. Page 36 of 143 . Constants are declared in the declaration area of a class. which are working on those data. A class is a collection of data and methods. Inheritance of classes Inheritance is the important part of the object-orientated programming. it is done exactly like declaring variables. Instance-method or instance-variable means that they can only be used together with an object. all objects in KBasic are created with 'New'. Classes can give all its elements to its childs. KBasic supports single inheritance. This is like in Java. instance-variable only exist at lifetime of an object. Data and methods are used to describe the contenct and the behaviour of an object. the methods actually provide an object's behavior and define how that object interacts with other objects in the system. it will be possible to use interface to do many things you could do with multiinheritance. Class variables are good for communication between different objects with the same class. or for keeping track of global states among a set of objects.'The KBasic Book' of 1st quarter 2006 Methods are procedures and functions of a class. Class-variable are global and available at any time. Classes can contain constants as well. which is called inheritance. It is not possible to inherit from many classes. Whereas classes and objects provide the framework. Methods are arguably the most important part of any object-orientated language. Local variables only exist after calling the procedure. and class and instance variables provide a way of holding that class's or object's attributes. Variables and methods can be related to a class (1time in memory) or can be instance-related (so many as instances of that class exist) in the declaration of a class (outside a method): • Instance-variable Dim instanceVar Instance-method Sub instanceSub() Class-variable Static staticVar Class-method Static Sub staticSub() • • • Class-method or class-variable means that they can be used without any created object. which means that every class inherits one parent class.

'The KBasic Book' of 1st quarter 2006 Objects are instances of a class: You can not do much with a single class, but much more with an instance of a class, a single object, which contains of variables and methods. That is exactly meant: Object-orientated means that the objects are the centerpiece, and not procuderes and some variables.

Page 37 of 143

'The KBasic Book' of 1st quarter 2006

KBasic-Syntax
If you want to read and write programs fast, you have to know the syntax of KBasic. The syntax defines how to write programs. It defines how to write each language element, how they work together and how to use them. So on the following pages, you will get know all of these language elements.

Statements and expressions
Statements are a complete action in KBasic. It can contain keywords, operators, variables, constants and expressions. Every statement can be categorized by one of three:
• • •

Statements as declaration or definition for class, module, variable, constant, procedure, function, method, property Assignment statements, which assign a value or expression to a variable or constant, or property Executable statements, which do some action. These statements can execute a method, function, procedure or loop or condition. Executable statements often contain conditional or mathematical operators (even complex expressions).

Multi-Line statements
Normally, every statement fits into one line, but sometimes is more readable to put one statement in many lines. If so, you can use the line continous underscore (_). In the following example the (_) is used:
Sub field() Dim myVar As String myVar = "Bernd" MsgBox Prompt:="Hello " & myVar, _ Title:="Hello" End Sub Print „Hi“: Print „Ho“

You can write many statements in one line using the colon (:). For example:

Page 38 of 143

'The KBasic Book' of 1st quarter 2006

Variables and DataTypes
While computing expressions it is often needed to store values for a short time. For example, you would like to calculate different values, compare these values, and depending on those values, doing different operations. But in order to compare values you need to store them. Storing means not to save on disk, but in memory, because you need the values only at runtime of your program. KBasic uses variables to store values at runtime of your program. After stopping running your program all variables (even objects) are deleted. A variable can change its value at any time. You can change its value by assigning an expression, another variable or a contstant to it. A variable is a space in memory used by KBasic to store values, so variables are not stored in a file. Like a file, a variable has a name (used to access the variable and to identify it) and also a data type, which specify the kind of information a variable holds. KBasic knows instance-variables, class-variables, global variables and local variables. Instance-variables are part of an object, class-variables are part of a class, global variables can be used everywhere and local variables are part of a procedure, function or sub (also called method in classes). Declaration of Variables / Explicit declaration Before you can use variables, you must declare them, which means you must define the name and the data type of a variable. The 'Dim'-statement declares a variable. 'Dim'-statements are one of many variable declaration statements, which lightly differs from the others. Other declaration statements are 'Redim', 'Static', 'Public', 'Private', 'Protected' and 'Const'.
Dim myName As String

Variables can be declared everywhere in procedures, functions and subs, and not only at the top of procedures, functions and subs. But most time there are at the top.
Sub doEvent() Dim myName As Integer End Sub

Every line of your source code can contain many declaration statements for many variables. Which data type the variables have, depends on the way you declare the variables. If you give every variable explicitly a data type specifier, the default data type for variables will not be used. The default data type depends on the mode you have chosen for your program. In 'KBasic Mode' and 'OldBasic Mode' it is 'Variant', in 'VeryOldBasic' it is 'Double'.
Dim firstname, sirname, lastname As String

Page 39 of 143

you have to write it for every variable. In the following statement all variables are declared as 'Integer'. Dim intX As Integer. sirname. you have two ways: Either Dim name = „sunny sun“ As String or Dim name As String = „sunny sun“ If many variables are declared in one line. In order to do so. age As Integer If you would like to use a data type. otherwise the default data type would be used. Dim name. only lastname has the value „sunny sun“. intZ As Integer Variables can have a start value for initial. lastname = „sunny sun“ As String Page 40 of 143 . intY. Dim intX. intZ As Integer In the following statement intX and intY are declared as 'Variant' and intZ as 'Integer'. intY As Integer.'The KBasic Book' of 1st quarter 2006 name is type 'Variant' sirname is type 'Variant' lastname is type 'String' Or explicitly with different types: Dim myName As String.

If it is a string. name. functions. or the following characters like @.z) or underscore (_) as your first character never use whitespace ( ). but you can declare age in a procedure and in a module the same time. and the same declaration in a module. like keywords or builtins ('If' or 'Print') Declarations of variables in different scopes You can place a declaration statement inside a procedure.g. method in order to declare a variable in local scope. For example. if you have the declaration of a variable named price in a procedure. a nullstring is used with length 0 (““). 'If'). The scope of a variable cannot changed at runtime of your program. like keywords (e. e. you can not declare variable age two times in a procedure. „ in your names. class-variable. in fact you can write it differently in every line. in which the orginial language element would be expected. all uses of this variable in the procedure are related to the local variable price. Variant is 'Empty'. dot (. all uses outside the procedure are related to the global variable price. so that your program will not compile. Some exceptions exist. variables or arguments in KBasic: • • • • • • Use a letter (A-Z. do not use names. the name may contain numbers. KBasic does not make a difference if a variable name is written in lowercase or uppercase. Additionally. subs. but you can have different variables with the same name at different places. you cannot use variables with the same name in the same scope. $. only underscore (_) is allowed.. classes etc. builtins (e.g. &. if it is a numeric variable. you have always write the name of methods the way it is mentioned in the Qt-documentation. which is 0. the default value is used. Important! Normally. but must not start with a number generally. a. explanation mark (!). Dot. 'Print'). you must not use reserved words. but to be compatible for future versions you should always write your variable names equally. Object variables are set to 'Null'. instance-variable in the declaration section of a class or module. you can place a declaration in order to declare global-variable. comma and other non-writtable characters must not be used. because it would lead to a name collision. sub. Use the following rules.). function. A variable named sName with type of 'String' is declared in the following example: Dim sName As String Page 41 of 143 . The place of the declaration determines the scope of the variable.'The KBasic Book' of 1st quarter 2006 If no value is assigned by declaration. because they are declared in different scopes (at different places). #. which are already used by predefined elements of the KBasic lanuage. naME are releated to the same variable. Names of variables must not be longer than 128 characters and must not use all characters possible. If you use the Qt-bindings.g. So Name. constants. if you want to name procedures.

all sub-classes methods). but not outside the module (in fact it is declared as 'Private' implicitly). which means where are accessable from everywhere. you can use it in all procedures of the module. it is treated as 'Private'-Statement. Public sName As String Use of the 'Private'-Statement You can use the 'Private'-Statement in order to declare private variables in module scope or class scope. Propably. all class methods. all module procedures. Example: Public sName As String Use of the 'Public'-Statement You can use the 'Public'-Statement in order to declare public variables in module scope or class scope. It is useful if you want to underline the inheritance hierarchy of your classes. you want to use the 'Private'-Statement in order to have cleaner and more readable code. which means where are accessable only from the same scope (class scope. which means where are accessable only from the same scope (module scope. Is this statement part of a modul declaration section. Private myName As String If the 'Dim'-statement is used in module scope or class scope. Use of the 'Protected'-Statement You can use the 'Protected'-Statement in order to declare protected variables in class scope. class scope. then it is possible to use this variable in the same procedure only. Protected myName As String Page 42 of 143 . you can use the keyword 'Public'. sub-classes. all class methods).'The KBasic Book' of 1st quarter 2006 If this statement is part of a procudure. In order to have the possibility to use it everywhere.

'Private'). Declaration of variables automatically / implicit declaration For historical reasons. A class-variable exists only one-time at runtime. in which all variables are declared automatically. • • • Static inside a class. it is not destroyed by leaving the procedure. which means that a variable once it has been declared. Important! You should not use this mode. Good programming style is to declare all variables with their types.'The KBasic Book' of 1st quarter 2006 Use of the 'Static'-Statement Static has three different meanings. Static outside a class. The next time the procedure is entered. a local static variable is only one-time declared when using recursive calls of a procedure. unless you use some old BASIC code. which means that it can be used without instance (objects) of this class. You can add the keyword 'Static' to other keywords ('Public'. 'Protected'. the value of the variable still exists. Therefore. which makes it more easy for others to understand your code. a local static variable is only one-time declared when using recursive calls of a procedure. but before a procedure (sub or function) or method If you use a 'Static'-statement before the keyword 'Sub' or 'Function' all local declared variables are declared as 'Static' variables. when using a variable name. write the following line in top of your program: Option OldBasic Option Explicit Off Page 43 of 143 . You also avoid typing errors. the value of the variable still exists. the variable is declared as class variable. which you still want to use without changing it. Static outside a class. In order to activate implicitly declaration. which means that the variable once it has been declared. but outside a method If you use a 'Static'-statement instead of a 'Dim'-statement. when you type the name of a variable (meaning the same variable) differently by mistake. It is supported within a special mode. the variable is declared as local static variable. it is possible to use variables without declaration. depending in which context it is used. it is not destroyed after leaving the procedure. which has not been used before. The next time the procedure is entered. Therefore. but inside a procedure (sub or function) or method If you use a 'Static'-statement instead of a 'Dim'-statement.

'The KBasic Book' of 1st quarter 2006 Use of the 'Option Explicit'-statement (supported within 'Mode OldBasic' and 'Mode VeryOldBasic' only) As mentioned in the paragraph before. you should write on top of all module and class files 'Option Explicit On'. Furthermore. another file is set 'Option VeryOldBasic'. All implicitly declared variables have got the data type 'Variant' ('Option OldBasic') or 'Double' ('Option VeryOldBasic'). Variables of type 'Variant' need more space in memory than most of the other data types. By the way. It is like 'Option Excplicit On'. Assignment always includes a sign (=). Dim yourName As String yourName = InputBox("What is your name?") Page 44 of 143 . Another advantage is that using declaration avoids name collisions or typing errors. you wish to use. the 'KBasic Mode' is default set in all programs. So that a compilation error is raised. If you are using the 'KBasic Mode'. just only use a assignment statement or expression with the proper variable name. The following example shows an assignment. you can mix the modes in your program. number etc. Local variables The value of a local variable is available inside the procedure only. If you want to explicitly declare within 'Option OldBasic' or 'Option VeryOldBasic'. So that it is possible to have a the same variable name for different variables in different procedures. you can implicitly declare a variable in KBasic. without name collision. when a varialbe name is not declared or was misstyped. you have to declare all variables. Important! You have to declare dynamic arrays or fixed arrays all time. Example: Sub test1() Dim i As Integer i = 1 End Sub Sub test2() Dim i As Integer i = 19 End Sub Assignment-statement Assignment-statements give or assign a variable a value or expression with variables. You cannot access these value from outside of the procedure. You are free to set 'Option Explicit Off' for the old modes. One file is set 'Option OldBasic'. constants. Your program is faster when you explicitly declare your variables with the smallest data type possible.

it is just the same. e. Dim Cool As Boolean Dim myName As String Cool = True Name = „Julie“ Cool contains 'True'. after reentering the procedure all variables are created again after their 'Dim'-statement. Is a variable outside its scope. it contains the initialized value at program start. If you do not change the value of a variable during its lifetime of a program. If a procedure is executed. If you use static-declared variables in procedures. it has no value anymore. which they belong to. Local variables exists till the procedure is left. They always exist only one-time in memory at runtime. Just omit it. you can use it. If you use instance-variables you have to consider that they only exist together with their instance (object). So a variable declared in a sub contains a assigned-value until the sub is left.g.'The KBasic Book' of 1st quarter 2006 MsgBox "Your name is " & yourName You do not need the 'Let'-keyword. 'Set' is not needed in KBasic and must not be used. they only exist one-time in memory besides of many times when the procedure is two-times or more called using the recursive technique. If the same sub is called again. the value is set to the initialized value again. Lifetime of variables The lifetime of variables is the time in which the variable exists or has got a value. After the declaration of a variable. Page 45 of 143 . If you use global-declared module variables or classvariables. The value of a variable can be changed during its lifetime. a variable exists after its 'Dim'-statement. make an assignment (=). An example shows how to 'Let': Let yourName = InputBox("What is your name?") The 'Set'-statement is used in VB6 in order to assign an object to an object-variable. It is outdated and optional. name contains 'Julie' after the assignment.

.. Dim Name [= Expression] [As Type] Dim Name [As Type] [= Expression] [Public | Protected | Private | Dim | Static] Name [= Expression] [As Type] Page 46 of 143 . Name[([Index])] [As Type]] . Syntax: Dim Name[([Index])] [As Type] [.'The KBasic Book' of 1st quarter 2006 Place of declaration You should declare every variable and every procedure inside a class or at least inside a module.

You can use one of the following data types: • • • • • One of the simple data types (e. If you declare a variable you must also give it a data type.g.'The KBasic Book' of 1st quarter 2006 Data Types Data types describe the kind of date to be stored inside a variable. Qt-binding-class) User defined class User defined data type User defined enumeration Page 47 of 143 . KBasic supports all VB6 data types and much more. 'Integer') Name of builtin class (KBasic class.

Type suffix is (%). you should not use it for enumerations like in VB6. Byte / 1 / 0. it loose the precision.767 Integer / 4 / -2^31 bis 2^31 –1 they are stored as 32 bit numbers (4 Bytes).. Type suffix is (&). better use the new approach with the 'Enum'-keyword.'The KBasic Book' of 1st quarter 2006 Simple Data Types They can store numbers and text. Values can be -32. Anyway. Simple data types are called simple.768 or 32. Values can be -2^63 >= and <= +2^64. meaning it loose information! The following table contains all KBasic supported datatypes with their needed space in memory. 1 = white and so on.768 or 32. Long / 8 /-2^63 bis 2^63 –1 they are stored as 64 bit numbers (8 Bytes). Every simple data type has borders. You can use Integer variables to simulate enumerations. because they are builtin in KBasic and are not complex like classes. which show how small can be the smallest number and how big can be the biggest number to be stored. Values can be -2^31 >= and <= +2^32. but which can only be 'True' or 'False'. Like 0 = black. Data Type / Size / Value • • • Boolean / 1 / 'True' or 'False' they are stored as 8 bit numbers (1 Byte).767 or between -32. which can be >= 0 and <= 255 Short / 2 / -2^15 bis 2^15-1 they are stored as 16 bit numbers (2 Bytes). Int16 / 2 / Signed Integer with values upto 2^16 Int32 / 4 / Signed Integer with values upto 2^32 Int64 / 8 / Signed Integer with values upto 2^64 UInt16 / 2 / Unsigned Integer with values upto 2^16 Uint32 / 4 / Unsigned Integer with values upto 2^32 Uint64 / 8 / Unsigned Integer with values upto 2^64 • • • • • • • • Page 48 of 143 .255 they are stored as 8 bit numbers (1 Byte) without a sign. If a value is too big.

only.477.685.94065645841247^-324 till 1.337.“ Character / 2 / reserved for future. Type suffix is (@).685. The dynamic string gets smaller or bigger when assigning new values. Classes / see Object User defined data type / see next chapter size depends on its elements • • • • • • • • • • Page 49 of 143 . Currency / 8 they are stored as numbers (8 Bytes). 1993# oder #1 Jan 93#.5808 or 922. Type suffix is ($). Values can be between -1. Normally.402823^38 or -1. Dynamic strings can be upto 2^31 characters long. Values can be between -3. Object / 4 / + size of the object they are stored as 32bit references (4 Bytes).79769313486232^308 bis -4. myStringVar = „1234 Names symbols .!/& keywords IF ? . Strings with fixed length and with dynamic length. strings or string arguments are dynamic strings.402823^38 Type suffix is (!).337. only. A date literal must be like #January 1. Double / 8 / they are stored as floating numbers (8 Bytes) with double precision. Values can be between -922.79769313486232^308 Type suffix is (#).'The KBasic Book' of 1st quarter 2006 • String / size depending on string length / unlimited There are two types of strings. Fixed strings are used together with 'Type'-keyword.477.5807. Single / 4 / they are stored as floating numbers (4 Bytes) with single precision.401298^-45 till 3. Fixed strings are used together with 'Type'-keyword.203. String / fixed length / length of string Fixed strings can be upto 2^31 characters long. Type suffix is ($).203. Variant / 40 A 'Variant' variable is always 40 bytes big.401298^-45 or between 1. Date / 8 they are stored as numbers (8 Bytes).94065645841247^-324 or between 4.

procedure or variable.'The KBasic Book' of 1st quarter 2006 User defined types They have been heavily used in the 80's and 90's.. The following example creates two variables of type 'Variant': hisVar = 3 Dim myVar Dim yourVar As Variant Page 50 of 143 . too. the reference to that object). If you would like to have early binding. the binding is done at runtime (late binding). You can force early binding using a cast statement. like TextBox. but today they step behind ordinary objects. Variables of type 'Variant' can contain strings.. This variables are object variables of data type 'Object' and have 4 bytes in size. Though. Accessing variant data types is slower. If you use a variable in 'VeryOldBasic'-Mode it has no 'Variant' but 'Double'-data type. Unlike in VB6. boolean values or even numerical values. a object variable can contain any object (actually. End Type Class types/Objects: Variables can store objects (actually. Type Variant The data type 'Variant' is automatically used. you can use a class which inherits the object class. if you do not specifiy a data type for an argument. Syntax: Type Name Name [(Index)] As Type . time values. dates. User defined types are a group of variables with different types stored in one variable. But there is an exception. references to objects). constant. assignment of objects to an object variable do not need the 'Set'-keyword. The '='-statement is recognized by KBasic correctly. These types can be simple data types or even user defined types. The size of 'Variant' is 40 bytes.

Additionally. 'Long' is (&). 'String' is ($).'The KBasic Book' of 1st quarter 2006 The first statement implicitly declares a variable (automatically). Historically. 'Double' is (#). 'Currency' is (@). you can append a special symbol showing the variable's data type. 'Single' is (!). • • • • • • Integer type sign for Long type sign for String type sign for Single type sign for Double type sign for Currency type sign for 'Integer' is (%). KBasic supports this old style of programming for historically reasons. Page 51 of 143 . Example: Dim i% ' Integer variable Dim l& ' Long variable Dim s$ ' String variable The following type symbols are supported. a 'Variant' can store the following values: • • 'Null' 'Empty' Suffix of variables Names of variables can be used to determine their data types.

Comments are printed in green on screen. you declare and name many elements like procedures (functions and subs). The symbol ‘ and REM e.g. normally. KBasic ignores all comments while running your program. KBasic knows four ways to write comments. For these elements. there are rules how to name them. dots. Keywords (e. REM this is a comment ‘ this is a comment. variables and constants and so on. If you want to write a comment. The rules are: All names • must start with a letter • must contain letters. with predefined meaning. Comments are useful for describing procedures or statements. Page 52 of 143 . describe how your program works. too and like in Java /* comment begin and comment end */ /** docu comment begin and docu comment end */ Comments are extremely helpful when it comes to understand your program by you or other software coders. A complete list of reserved words is appended at the end of this book.g. 'Mid') and operators (e.g. Additionally. Way of naming When you code in KBasic. which is part of KBasic. builtin-functions (e.g. So comments. The comment symbol (') is used in many places in this book. KBasic ignores all comments while compiling and running your program. write the symbol (') and directly after that the text of the comment. 'If' or 'Then').'The KBasic Book' of 1st quarter 2006 Comments The comment symbol (') is used in many code lines in this book. even commas are forbidden • must not be longer than a defined length • must not contain reserved words A reserved word is a word. numbers or the sign (_). 'Mod'). Comments can explain a procedure or a statement.

symbols and names. Integer. the expression gives or must give a value back. „hello“ • Unicode is supported in future. so that KBasic can recognize it as String. Expressions Expressions stand for values. 4453 • Hex &HAA43 • Binary &B11110001 • Octal &O1234 • Single (Dezimal) always English formatted 21. 12. Values with 0 are 'False'. true. 2. Int32. They can contain keywords. There are no escape sequences like in C++. which represents a value.235421. Examples for expressions are: • • • 1 + 9 (number operator number) myVar (variable) myVar TypeOf Object (variable keyword classname) Expressions can return a value or not. operator. Int16. A double („) inside a string is interpreted as single („). Uint16. E. 1993# • String Is simply text.3@ • Date / Time always English formatted #January 1. Values with -1 are 'True'. variables.32. There are different numerical literals. Uint32. Int64. -44. 0. • Byte. Short.344. Long. Uint64 1. They can be used using builtin-functions. Boolean Either 'True' or 'False' When you cast a numerical value to Boolean. A literal is a number or string.23 • Currency always English formatted 45. „Hi“.g. constants or even other expressions. but it must start with a („) and end with a („).21 • Double (Dezimal) always English formatted 212. If an expressions is right of an assignment statement (=). -435. Page 53 of 143 . a KBasic program contains of literals.'The KBasic Book' of 1st quarter 2006 Literals Besides keywords.

Constants Constants are like variables except that they cannot change their values. Short. It is exactly the same. Uint32. String or Variant. This 'Const'-Statement declares a constant conAge as public with data type 'Integer' and a value of 34.. when the expression is used as a parameter in a function call. you have to place the 'Const'-statement inside this procedure (normally. [Public | Protected | Private] Const Name [As Type] = Expression Page 54 of 143 . Const conAge As Integer = 39. MyProcedure(1 + 9) Expressions are calculated at runtime and represents a value. Single. Example: Const border As Integer = 377 This 'Const'-Statement declares a constant border with data type 'Integer' and a value of 337. Long. Integer. Int32. Uint64. Uint16. The result can be used to assign it to a variable or in other expressions we have seen above. There are the same rules for declaration of constants as for variables. conSalary As Currency = 3500 This 'Const'-Statement declares constant conAlter and conSalary. one of the first statements). In order to declare a constant inside a procedure.. Double. Public Const conAge As Integer = 34 Constants can contain all simple data types. Syntax: Const Name = Expression Const Name [As Type] = Expression [. Date. Int16.'The KBasic Book' of 1st quarter 2006 myVar = 1 + 9 1 + 9 is 10 and this expression value (10) is stored in myVar. To declare a constant as accessable for all procedures. which is one of the following: Boolean. Int64. Byte. Name [As Type] = Expression] . When you declare a constant you assign a value to it. Currency. which cannot be altered during lifetime of your program. you have to put it in the module (or class). A 'Const'-statement have the same scope as variable do. where the procedures are. You can also declare many constants in one line.

e. There are different kind of operators. if the result should be a number or string. The result is floating point.g. e. If you add a number and a string KBasic cannot be sure everytime. Operators are '+' or '-' for example. 9 means positive 9 Calculating operators are: • + Addition Useful to add two numbers or strings. like -9 means negative 9. Operands are numbers. strings or variables (or expressions). 29 / 5 • Mod Modulus. so operators are useful to perform operations like add or substract.g. So it is better to use the & Operator instead of + for strings.g. The minus (-) can be used to negate values. it will be possible to use operator overloading inside KBasic classes like it is possible in C++. 45 Mod 10 So a Integer-Division results into an 'Integer' value. also known as remainder of Integer-Division Give you the remainder of a result of an Integer-Division e. e.5 is 2 ' is 5 Page 55 of 143 . +9 means positive 9.g. Example: x is 10. e.g. y is 4 Print Print Print Print Print Print x x x x x x + y – y * y / y \ y Mod ' ' ' ' ' y is 14 is 6 is 40 is 2. Operators for calculating They are used for calculating of two operands. KBasic supports operator overloading for the Qt-Bindings. 3 + 4 • . 2 / 5 • \ Integer-Division The result has data type 'Integer'. 5 – 7 • * Multiplikation Useful to multiply two numbers e.g.Subtraktion Useful to subtracte a number from another number or to get the negative value of a numeric expression. In future. Every of those operators needs two operators.'The KBasic Book' of 1st quarter 2006 Operators and Operands KBasic supports all VB6-Operators and much more. 33 * 7 • / Division Useful to divide two numbers.

you can additionally use further C/C++-comparision operators like ==-Assignment.1) /= Divide-Assignment (e.g . var *= 1 is like var = vara * 1) If you use the Qt-Bindings.g. additionally. the result has the data type of the operand (= expression) with more precision. KBasic will support more than the normal assignment operator (=). Increment and Decrement C++ knows two operators.-' are supported for the Qt-Bindings only now. you can additionally use further C/C++-assignment operators like |= Or-Assignment.g.g. var += 1 is like var = vara + 1) -= Subtract-Assignment (e. But you can write instead var = var + 1 likewise var = var – 1. x >= 3 If you use the Qt-Bindings.g.'The KBasic Book' of 1st quarter 2006 Normally.g .g. x = 3 ♦ <> Unequal e. -1) instead in the future. +1) or DEC(var) (decrement. it supports the extended assignment operators. x <= 4 ♦ >= Bigger or equal e. See Qt-Binding documentation for more details. x <> y ♦ < Smaller e. var /= 1 is like var = vara / 1) *= Multiply-Assignment (e. Assignment-operators At the time of writing. Like C++. var -= 1 is like var = vara . x > 4 ♦ <= Smaller or equal e.g.g . See Qt-Binding documentation for more details.g. '++' and '. += Add-Assignment (e. Comparision KBasic has got different operators to compare expressions: These operators do comparision between two operands (expressions) and the result is 'True' or 'False': ♦ = Equal e. Page 56 of 143 . x < 3 ♦ > Bigger e. Or use INC (var) (increment.

which work very equal.'The KBasic Book' of 1st quarter 2006 Logical operators (Boolean Operators) They are useful for doing bit operations. But you can write instead SHL(number of digits) or use SHR(number of digits) in the future. Page 57 of 143 . The result ist 'True' if one of both expressions is 'True'. Bitoperators ♦ And and e. 'Or'. 'Not' inverts a bit of byte. ♦ Not not e. ♦ Or or e. Furthermore. Or the result ist 'True' if one of both expressions is 'True'. BitXor. See Qt-Binding documentation for more details. BitOr. 33 Or 8 Useful for doing logical disjunctions of two expressions. ♦ AndAlso Both operands (expressions) must be 'True' ♦ OrElse One of the operands (expressions) must be 'True' But you can also use bit-operators instead of 'AndAlso' or 'OrElse'. Not 5 Useful if you would like to negate expressions.g. 'Xor' and 'Not' are supported for compatibility reasons. 'OrElse').g. 4 And 6 Useful for doing logical conjunctions of two expressions. A result is -1 ('True'). you can additionally use further C/C++-shift operators like << or >>. The result is 'True' or 'False'. If you use the Qt-Bindings. KBasic supports true logical operators for decisions ('AndAlso'. The result ist 'True' if both expressions are 'True'. when all bits are set (binary 1111 1111) or 0 when all bits are not set (binary 0000 0000).g. combining bits together. 77 Xor 3 The result ist 'False' if both expressions are 'True'.g. which are better sometimes. ♦ BitAnd. ♦ Xor exclusive or e. BitNot are the same as 'And'. Unlike VB6.

The result is data type 'String'. If they are many powers in one expressions. always use '&' for string concatenating. you can additionally use further C/C++-operators like the following. all other + of that expression are treated as strings. when using +. Page 58 of 143 . ♦ New creates a new object using a class ♦ ( ) or [ ] accessing indexes of arrays or argument holder for procedures ♦ . they are processed from left to right. But '+' is different if one operand is of different type than 'String'. there exist two operators: '+' and '&'.'The KBasic Book' of 1st quarter 2006 Other Operators ♦ ^ Power Useful if you want to use power. dot operator needed for calling methods or elements in types or enumerations ♦ & String concatenating Useful to append one string to another ♦ Eqv means x Eqv y = Not (x Xor y) ♦ Imp means x Imp y = Not (x And Not y) ♦ Is (in the future) Useful to find out if two objects are based on the same class. ♦ ++ increment ♦ -. For that. Therefore. ♦ Like (in the future) Useful to compare two strings (using a pattern). If string and pattern are matching the result is 'True'. if you want to be sure. See Qt-Binding documentation for more details. ♦ '+' ♦ '&' Example: Name + „is a „ + color + „bird“ If the first operand a string. If you use the Qt-Bindings.decrement ♦ [ ] index access ♦ |= or-assignment ♦ &= and-assignment ♦ | or ♦ ! not ♦ == is equal ♦ != unequal ♦ ^= power-assignment ♦ << shift left ♦ >> shift right String concatenating It is also possible to add two strings (to append one string to another).

--. which means in which order are the operators executed of an expression. (unary +). because / is calculated before +. e. X = (10 + 10) / 2 results in 10 and not 15. ++. Normally. because + is calculated before / thanks to the braces. which means '*' is executed before 'And' as example. !. The qt-bindings operators are inlcuded as well (in braces): ♦ . Here is the overview about operator order/priority from top to bottom. x = 10 + 10 / 2 results in 15 and not 10. e.()[] ♦ Not. an expression is executed from left to right. BitNot. (unary -) ♦ New ♦ ^ ♦ * / \ Mod ♦ +-& ♦ Imp Eqv ♦ < > <= >= = Is Like == != ♦ And BitAnd (& C/C++ And) ♦ Or Xor BitOr BitXor (| C/C++ Or) (^ C/C++ Xor) ♦ AndAlso ♦ OrElse You can always use braces () to change the order. Page 59 of 143 .g.g.'The KBasic Book' of 1st quarter 2006 Operator order KBasic also supports die operator order of VB6.

not to forget the scope modifiers ('Public'..aSub(Module1.. 'Protected'). module scope.'The KBasic Book' of 1st quarter 2006 Avoiding name collision A name collision occurs. class scope. Page 60 of 143 . global scope. You can find and replace inside your source code as in a word processor and so on. You have got an cursor showing the current position. 'Private'. You can have name collisions in the following situations: • • If an identifer can be access from different scopes If an identifier has different meanings in the same scope Most name collisions can be avoid by using full qualified names of identifiers. Example: aModule. when you would like to use a name.Var1) Editing source code It is not much different of editing a text in a word processor. You can avoid name collisions by knowing the concept of scopes. There are different types of scopes in KBasic: procedure scope. which has been already defined in KBasic (or even by KBasic itself = keywords). where you can type in.

Syntax: objectVariable = New ClassName[(Arguments)] Page 61 of 143 . The matching constructor of that class is executed. This variable only has the data type of an object and represents only a reference to an object. The following issues need to be discussed: • How can I create a class? • How can I create an object (instance) of a class? • How can I use class-variables. or you create it from your own defined class. but often you have arguments. which creates an object (by giving it the desired class name) and returns a reference to the new object. The class has a special procedure called constructor. which is stored in a variable of the class type. which have to be written inside braces. which still have to be created. Use of New A variable. A constructor should never explicitly return values using the keyword 'Return'. which should contain the object and is declared. It is the way of creating objects as it is in Java or C++. which is called by 'New'. Example: s = New Control() You do not need to write the braces.'The KBasic Book' of 1st quarter 2006 Working with objects Because KBasic is an object-orientated programming language. constructors are called by KBasic automatically when you create a new object with 'New'. class-methods. Creating objects is done by using the special keyword 'New'. nor is the keyword 'Sub' or 'Function' used. 'New' is followed by the class name of which type the new object is. when you would like to use or declare constructors: • The name of the constructor must match the name of the class it means • The return value is always an instance of that class (implicitly). Unlike regular procedures. you propably would like to know how to use these features. Yet another example: s = New Timer(begin. This constructor does some inital work for an object and returns a reference to the new created object. does not create the object at once. end) What happens when using 'New'? Using 'New' creates a new instance (or object) of a class. instead. you cannot call a constructor by calling it directly. when you create an object. There is no return type declaration necessary. There are two important things to consider. instance-variables and instancemethods? • How can I convert an object into another object? Create new objects Either you create an object based on a builtin class of KBasic.

'Null' can only be assigned to object variables. are automatically deleted by KBasic. You can do so. which means that every class can have different constructors with different arguments. So you can concentrate on coding the real algorithm. This happens when no object variable references to such an object. by using the 'Null' keyword. which does it automatically (called garbage collection). because the object variable has been deleted automatically by leaving the current procedure or the value has been explicitly set to 'Null' by you. which are no longer referenced. Example: Class test1 Constructor test1() End Constructor Constructor test1(i As Integer) End Constructor Constructor test1(i As Integer. by using different constructors for the same class. because KBasic has a well-known mechanism.g. which means you do not need to explicitly delete or free the object. Just assign 'Null' to the desired variable. you would like to use an object in different ways or doing the initial stuff in different ways. Releasing objects manually But you can also explicitly free or release objects. E. which means that the object variable has no reference yet. Releasing objects automatically If you do not need a object variable (or object) anymore. you can just forget about it.: objectVar = Null objectVar = Nothing Page 62 of 143 . myVar = Null Objects.'The KBasic Book' of 1st quarter 2006 objectVariable = New ClassName() objectVariable = New ClassName Several Constructors Sometimes. 'Null' (or 'Nothing') is a reserved word. m As String) End Constructor End Class 'Null' (or 'Nothing') The default value for object variables is 'Null'.

Create a class To define a class is easy. you can just forget about it.. but no methods. To declare a class inside a form-module-file is not possible.. though actually it contains a class. KBasic does not run any class.'The KBasic Book' of 1st quarter 2006 This means you do not care about releasing objects.variable This syntax is quite the same as accessing elements of user defined types ('Type' . This is much different to C++ and other programming languages. Accessing class-variables and instance-variables Accessing varaibles is done by using the dot operator (. but methods are A new created class only contains the declaration part (class name and parent name). classmethods. every class is a child of the special class 'Object' directly or indirectly through another class. 'End Type'). These must be created by you. Normally. instance-methods) and of course some properties and constants. but the methods inside the class.). The declaration of a class consists of a class name and the parent class name. Classes are not executed. A class can inherit from another class (be child of that class). And it is possible to declare many classes in on class-file.variable Page 63 of 143 . sometimes destructors. Example: classeName. Accessing objects Accessing objects is done by using the dot operator (. Class oak Inherits tree Parts are: • Variables/ Constants / Properties / Types / Enumerations • Constructors • Destructors • Functions • Subs End Class A class can only be declared inside a module-file (not recommended) or inside a class file.). Example: myObject. furthermore you have constructors. which inherits from class 'Form' implicitly. some variables (class-variables and instance-variables) and procedures (methods.

the method is by default an instance-method.'The KBasic Book' of 1st quarter 2006 When accessing class-variables. You cannot use 'Me' or 'Parent' inside classmethods.instanceVariable = 99 Class-methods and instance-methods Like variables. End Sub Page 64 of 143 .instanceVariable Important! Class-variables only exist one time.classVariable objectName. Example: Static myClassVariable As Integer Private myInstanceVariable As String Another example: myClass. Class-methods are like global functions. Got it? If you declare a variable inside a class. you can use the keyword 'Static' to define a classmethod. when accessing instancevariables you use the name of the object variable: className. Class-methods are always present.. When you define a method.. when its object is present. If you do not. because there is no object. methods can also be class related or object related. Example: Static Sub myClassMethod() . However. you use the class name.. instance-variable are part of an object of a class.. you can mark a variable with the keyword 'Static' if it should be class-variable.classVariable = 23 Dim o As myClass Accessing inside a method: o. so a instance-variable exists how often objects exists of that class and only at lifetime of an object. so it is not important how many objects of that class exists. The class itself exists only one time. instance-methods are only present. It is like a global variable. If you leave it out. it is by default a instance-variable. The class is available while running your program at any time. so the class variables too. End Sub Sub myInstanceMethod . You can use the class-variables without having created an object of that class before.

myObject. This will be the equals method. KBasic will provides objects with a compare method.myMethod() References to objects Using the =-Assignment you can assign a reference of an object variable to another object variable. and not if both variables' objects have the same content. Instead you have to provide proper methods in the classes. Page 65 of 143 . In future. Important! 'Set' known from VB6 is not allowed and not needed to assign objects in KBasic. Comparision of objects Another issue that object are given by references is. KBasic will provides objects with a clone method. Example: Dim i As tree Dim s As tree i = New tree s = i Both variables references the same object then. In future. Copying objects Because objects are not passed by values in procedures. you use the dot opertator (.) to access the methods.'The KBasic Book' of 1st quarter 2006 Calling methods Again. because it is obsolete. which can compare an object. that the =-comparision operator tests if two object variables reference the same object. which will be able to copy objects. Instead you have to provide proper methods in the classes. which can copy an object. Both variables references the same object then. which will be able to compare objects. an assignment of an object does not copy an object.

property name. which stores a value like size. color or position of an object. A collection contains different objects of the same object type like collection for forms contains all forms of your application. See the proper help entry of a property for more details.'The KBasic Book' of 1st quarter 2006 Summary: Objects. and contains executable code. you can access it through using the collection name and the desired method.Close End Sub If the collection contains methods useable for all elements of that collection. In order to use such an element you can use the collections provided by KBasic for such objects.Add(newEntry) End Sub A property is part of an object. If you want to change it.ActiveForm. Sub changeName(newTitle) myForm. which can be called at any time. properties. Accessing by index: Sub myClose() Forms(1). You can change the value of a property. Sub closeAll() Forms. a dot (. a form or report. for example a table. Getting a property value: Sub getForm() formName = Screen.Close End Sub Accessing by name: Sub closeForm() Forms("myForm2"). and the new property value. Elements of a collection can be accessed by an index or name.Close End Sub A method is part of an object. methods and events An object is an element of an application. equal sign (=).).Caption = newTitle End Sub Some properties are only readable. Sub addNewEntry(newEntry As String) Combo1.Caption MsgBox formName End Sub Page 66 of 143 . you have to write the object name.

Example with normal object type and specific object type: Page 67 of 143 . or specific object type (like 'Form'. with data type object is useful. by using the 'New' keyword to create a new object or an existing object Declaration of an object variable To declare an object variable. 'Protected' or 'Static'). 'Private'.g. then a special procedure. call a object method or property. which references an object. Event procedures can be called by system events or manually by your program like normal procedures. Assign an object to the object variable. must be of type 'Variant'. 'Font'. like it would be the object itself. when you do not know which object type you would like to have in a generic sub for example. How to create an object variable? 1. it has the default data type 'Variant' (using without declaration is possible only in OldBasic Mode!). you can use the 'Dim'-statement or another declaration statement like ('Public'. it is useful to declare the object variable with the same data type the object has. If you know the specific object. The declaration of an object variable. without declaration. an event procedure is executed. which is recognized by an object. Sub CheckBox1_Click(m As Mouse) Print "Hi" End Sub Creating object variables You can think of an object variable.. You can access the object through a object variable. e.'The KBasic Book' of 1st quarter 2006 An event is an action.. if someone clicked with the mouse or pressed a key. or 'Object'. Declare a object variable 2. A variable.) Some declaration of objects examples: ' Object1 as Variant Dim Object1 ' Object1 as general Object Dim Object1 As Object ' Object1 as Font-Object Dim Object1 As Font When you use an object variable.

'The KBasic Book' of 1st quarter 2006 Dim Objekt1 As Object Dim Objekt1 As Sample ' Object ' Sample The declaration of specific object types has some advantages like type checking. Normally. 'Me' is very useful if you want to give the object to another procedure outside the current class.. Example: Dim Object1 As Object = New Object ' creation and assignment When you assign the value 'Null' to an object variable. Example: If Not Object1 Is Null Then ' object variable references an object . Page 68 of 143 . where it should be used. Some examples: Object1 = Object2 Object1 = Null ' object reference ' set no object reference You can combine the declaration of an object variable with the creation of an object. All methods of that object can access the current object. In general. 'Me' and 'Parent' is like an implicitly declared instance-variable of that object. more readable or faster code execution. End If Use current instance or object / Me / Parent The keyword 'Me' references the current instance (or object). 'Parent' means the current parent object. you avoid mistakes like accidentally changing the object using the object variable. Assignment of objects to an object-variable Using the =-statement lets you assign objects to an object variable. in which the code is currently executed. it is the current class (user defined class or form class).. which 'Me' references. An object variable can have the value of 'Null' (or 'Nothing') or an object reference. when you use the keyword 'New' and the =-statement. which has contained an object reference before.

Example: Class movies Protected sMovieName As String Sub printName print sMovieName End Sub Constructor movies(s As String) sMovieName = s End Constructor End Class Class movies2 Inherits movies Constructor movies2(ByRef s As String) Parent. Normally. the right constructor is used to call the parent constructor automatically. If a parent class contains several constructors. Rnd * 256) End Sub changeObjectColor(Me) ' statement inside the object Second time use of 'Parent' There is another meaning of 'Parent'. if you do not explicitly write it down.movies(s + "2") End Constructor End Class Dim k As Integer = 9 Dim m As New movies2("final fantasy") m. But this statement must be the first statement in a constructor of a child class.'The KBasic Book' of 1st quarter 2006 Example: Sub changeObjectColor(Object1 As Object) Object1.BackColor = RGB(Rnd * 256. you can explicitly determine the parent constructor to be called by using the 'Parent' keyword with the desired constructor of the parent class.printName() Page 69 of 143 . because the constructor of a parent class must be called before any other action of a child can happen. Rnd * 256.

which you use to compare these objects. if both variables points to the same object. the object 'h' contains lesser methods. you have to provide proper methods inside the classes. variables and so on as object 'm' and is therefore extended: Dim m As Control Dim o As CommandButton ' control is parent class o = m Upcasting. it either will be reduced (upcasting) or extended (downcasting). the object 'o' contains more methods. the expression becomes 'True'. Asking about objects and classes Determining types of objects at runtime: If TypeOf myObject Is myClass Then Returns 'True'. While casting an object. too. While using objects. if the class name is the seeked name. variables and so on as 'm' and is therefore reduced: Dim h As Control Dim k As CommandButton ' control is parent class h = k Explicitly upcasting and downcasting is also possible: TODO2 Comparing objects If you use = with object variables in an expression. to bottom follow the child classes.'The KBasic Book' of 1st quarter 2006 Casting of objects and simple data types There exist some functions for casting simple data types like 'CInt'. or 'False' if it is different Syntax: TypeOf objectVariable Is ClassName Page 70 of 143 . Implicites Upcasting und downcasting Downcasting. there is a possibility to cast objects in a parent or child class. the class 'Object'. In order to compare both objects' variables or contexts. The inerhitance hierarchy shows which object is a child object of another object. On top is the parent of all objects.

Using the keyword 'Inherits' tells KBasic which parent class it should use for the new class: Class movies Protected sMovieName As String Sub printName print sMovieName End Sub Constructor movies(s As String) sMovieName = s End Constructor End Class Class movies2 Inherits movies .'The KBasic Book' of 1st quarter 2006 Subclassing and inheritance There is another possibility to extend your own classes or even KBasic classes. variables and so on. which means that you have a parent class and use it as a template for a new class. Inheritance is very powerful and an important feature of object-orientated programming languages. so that the algorithm of the parent class will use the new method in the new class instead of the original method in the parent class. End Class Page 71 of 143 .. in which you add new methods.. If you want to change the behaviour you can also override a method of the parent class (have the same name and arguments). All elements like methods and variables of the parent class are automatically inside the new class (hidden) and can be accessed and used (depending on the declaration in the parent class). This is called inheritance.

because it is not automatically visible anymore.) and the method name: Parent.myVariable myVariable ' access parent variable ' access me variable Hidden Methods An existing method. every class has got a parent class. you have to write 'Parent'. all classes forms together a class hierarchy (or inheritance hierarchy). KBasic looks after the first statement in this constructor. KBasic does it implicitly hidden. dot (. It is called hidding. which call the parent constructor automatically. though it is possible to access both mehtods with the same name. If you would like to access the parent method. It is called hidding. Constructor chaining When you declare a class. because it is not automatically visible anymore. If a class does not have a constructor. The hidden default constructor can always be overridden by you. then follows the child constructors of the child classes. Everytime you construct a object. it follows all constructors of all parent classes up to the parent class 'Object'. you have to write 'Parent'. Hidden Variables An existing variable in a parent class can be overloaded by a variable in the child class through inheritance. if there is no explicitly call for the parent constructor. though it is possible to access both variables with the same name. like a variable. KBasic inserts implicitly a standard constructor. If you create a constructor. return type. So the first constructor called is the constructor of 'Object'. dot (.) and the variable name: Parent. The parent method is now overridden.myMethod() myMethod() ' access parent method ' access me method Page 72 of 143 . This means that the call of constructors is like a chain. KBasic guarantees that the class can be used to create an object. Overriding takes place if the child class has a methods with the same methods signature (name. It is like a tree. The default constructor If a class does not call a parent constructor explicitly.'The KBasic Book' of 1st quarter 2006 Because. Hidden methods are so called overridden methods. with a root (parent class 'Object') and many twigs (many child classes). same arguments) like the parent class has. in a parent class can be overloaded by a method in the child class through inheritance. which is called when using this class without arguments. All constructors are connected together. because it automatically inserts a hidden default constructor with no arguments. If you would like to access the parent variable. and insert a automatically constructor call for the parent class.

because it could be coded in a way that it must be dynamically be searched at runtime. by casting its type to the parent type or use the keyword 'Parent'. But be careful. KBasic cannot know which methods in which class should be called. that you do not mix up overridding with overloading. which takes place when you call functions or procedures of a module. because variables are different used in child and parent class (they actually use there own variable). but with different method signature (different return type or arguments). it is not different when it comes to overridding of methods and hidding of variables. So if this method is called within the child class. by casting its object variable to the parent type or use the keyword 'Parent'. You can easily access hidden variables.i + 1 ' accessing A. the new defined method is used.f() + i ' accessing A.'The KBasic Book' of 1st quarter 2006 Overriding methods Overridding takes place if the child class has a method with the same method signature (name. The parent method is now overridden. even by the parent methods used by the child class. KBasic nearly equally treads variables and methods in a class. Overloading means having many methods with the same name in a class.F() End Functon End Class Page 73 of 143 . return type. This is so called late binding. Calling an overrided method You can easily access overridden methods. Overridding methods is a very important technique in object-orientated programming. The difference is interally meaning. same arguments) like the parent class has. Dynamic-searching of methods While compilation.i Return Parent. which means it is not so fast as early binding. Example: Class A Dim i As Integer Function f() Return i End Functon End Class Class B Inherits A Dim i As Integer ' this variable hides i in A Functon f() ' this method overrides f() in A i = Parent. while methods are used only of the child class (both parent and child class use the same method!).

cry" End Sub End Class Class body Inherits being Constructor body() Print "body.'The KBasic Book' of 1st quarter 2006 If you override a method you have two methods.cry" End Sub End Class Dim l[10] As being l[3] = New being l[4] = New face l[5] = New body ' polymorphism l[3].cry() Page 74 of 143 . The old can be accessed explicitly by using 'Parent' and the new by using 'Me' or the standard call of a method. The old in the parent class and the new in the child class.cry() l[5].Constructor!!!!" End Constructor Sub cry() Print "body.cry() l[4].cry" End Sub End Class Class face Inherits being Constructor face() Print "face.Constructor!!!!" End Constructor Sub cry() Print "being.Constructor!!!!" End Constructor Sub cry() Print "face. A further example: ' class example Class being Constructor being() Print "being.

which are externally visible. which are accessable by all others and you have private methods and variables. Reducing variables by hidding spares time. Scope modifiers In order to hide variables or methods. you have to document it. Hidding them leads to small and smart classes with a few variables and methods visible to others. Further reasons for hidding data are: • Internal variables. which should be only be used by the class itself and those public methods.'The KBasic Book' of 1st quarter 2006 Hidding data Hidding data (variables and constants.) is a very important technique in objectorientated programming as well.. You have public methods and variables. mixing up the API for other coders etc. • If a variable is visible.. you have to declare them as 'Private': Class plane Private wings As Integer Private Funcion countWings() . It means that not all data in a class can be access by other modules or classes.. This helps to reduce mistakes when using internal data of a class by other classes or modules or in general doing bad programming style.. End Function End Class ' only visible within this class ' only visible within this class Page 75 of 143 . in which the data is present. so that it is only visible within this class. but through methods of the same class.

but it could be useful. which should be used and accessable from everywhere. is automatically declared as abstract. but not outside. it is automatically declared as public. which means that you cannot create an object of that class. An abstract class must contain at least one abstract method. It is also possible to mark a complete class as abstract. but can be used as an template for child classes. The code should be included in the child classes. which means if you do not write 'Public' in front of your variable or method. Child classes now are forced to implement this method with some code in it. you do not use abstract methods or classes. • An abstract class cannot be used to create an object. which should only be used in the class. Abstract Classes and Methods It is possible in KBasic to define methods. but no code. containing an abstract method. because this class contains declarations. Besides 'Private'. Public means that every part of your program (any other class or module) can access and use the public declared part of your class (variable or method). there exist 'Public' and 'Protected' as scope modifier. non-private methods and variables are always visible to child classes. if all abstract methods have been overridden with a code implementation. Normally. It is non-abstract now. which means that the methods of this class can only use this private variable. which than can be used after the 'New'-keyword. TODO2 Page 76 of 143 . Protected is useful if the variable or method should be visible to child classes and the class in which they are declared only. which have no code insight. The default modifier is 'Public'.'The KBasic Book' of 1st quarter 2006 A private variable is visible for the class in which it has been declared. Some tips for using scope modifiers • Use 'Private' for methods and variables. • Use 'Public' for methods and variables. when you do not have code in a method of a parent class. • If a child class of an abstract class does not override all abstract methods it become an abstract class. • A child class of an abstract class can be used to create an object. Some rules dealing with abstract: • Every class. but must be present in the parent class for design reasons. Abstract methods are sometimes useful. Overview about the builtin KBasic classes KBasis has got classes and components like Qt or Visual Basic 6 has got. Private methods and varaibles are not visible to child classes of the class in which they are declared (in fact there are present in memory of that object. This technique is called abstract declaration. but not visible).

when you do not need them anymore. you will probably know the concept of arrays. Different kinds of arrays There are two types of arrays. So it is useful to use dynamic arrays.] As Type Example: Dim i(100) As Integer Page 77 of 143 .'The KBasic Book' of 1st quarter 2006 Arrays If you have worked with other programming languages. but they are placed as one block in memory. because you can use loops to use or access thousands of variables (the arrays). Index To Index. each element of it can contain a different data type. These variables have one name.. Arrays have bounderies. Static arrays are always in memory. All elements of that chain have the same data type and can be accessed by an index. which are only different in one issue: one have a fixed size while compiling and the other can change its size dynamically at runtime. If an array has the data type 'Variant'.. or only one element of the array. . but different index. • • Dynamic array change the amount of indexes at runtime Static array fixed amount of indexes It is possible that you do not know the length of an array while coding. 'Static'. Using arrays leads to better code (cleaner. Declaration Declaration of an array using 'Dim' and length declaration in ( ) or [ ]: Syntax: Dim variableName(Index) As Type Dim variableName[Index] As Type Dim variableName[Index. Arrays are variables. So that they can be distinguished. Index. 'Public' or 'Protected'). Arrays are declared the same way other variables are declared (use 'Dim'. more flexible).] As Type Dim variableName[Index To Index] As Type Dim variableName[Index To Index. . Another advantage is that you can free memory.. or you would like to change its size at runtime. You can use the array as one block. which looks like a chain.. 'Private'. when you use dynamic arrays. an upper and a lower bound. The elements of an array lie between those boundaries.

10 (including 10. which stand for the index.(Dimension]) Default: An array with declared 10 elements is counted from 0. in fact it will be always one more).. can be calculated at runtime. The expression. when you write an integer expression in braces () or [] after the name of an array: i(3) = 10 Access with position.(Dimension]) LBound is used for the lower bound: LBound (arrayVar [. This is an further feature of KBasic to avoid program crashes. you will run into an error. so that if it is to small or to big.'The KBasic Book' of 1st quarter 2006 Creates an array with 100 'Integer'-variables. Page 78 of 143 . which means that 0 and 10 are useable indexes and there are 11 elements delcared. In other words any numerical expression is allowed: N = 100 Dim i(n) As Integer Getting lower and upper bound UBound is used for the upper bound: UBound (arrayVar [. The position is 1 in the example: i(1) = 0 The index is always checked. Accessing array elements You can access an element of an array.

'The KBasic Book' of 1st quarter 2006 Explicitly declaring the lower bound Dim i(50 To 100) As Integer This creates an array with a lower bound of 50. How to create a multidimensional array is shown in the following example: Dim i(100. 1 To 10) As Single Page 79 of 143 . to change the default index of an array element from 0 to 1. Example: Dim curCosts(1 To 365) As Currency Dim sWeekday(7 To 13) As String Use of multidimensional arrays KBasic supports multidimensional arrays as well. In the following example the first accessable index will be 1: Option Base 1 Dim curCosts(365) As Currency You can change the upper bound of an array using the 'To'-keyword. 50. Example: Dim curCosts (364) As Currency Sub createArray () Dim curCosts (364) As Currency Dim intI As Integer For intI = 0 To 364 curCosts (intI) = 20 Next End Sub Changing the lower bound You can use the 'Option Base'-statement on top of an class or module file. The amount of dimensions is limited to 32. 400) The following statment declares a two-dimension array: Dim sngMulti(1 To 5.

g. First you can create an array with data type 'Variant'. 1 To 10) As Single ' set values of array For intI = 1 To 5 For intJ = 1 To 10 sngMulti(intI. intJ) Next intJ Next intI End Sub Save 'Variant'-values in arrays There are two ways to create arrays with elements of type 'Variant'. e." Change the size of a dynamic array Declarate the array using the 'Dim'-statement and without index expression. intJ As Integer Dim sngMulti(1 To 5.'The KBasic Book' of 1st quarter 2006 An array with two dimensions is like a matrix. Example: Print "Data " & varDaten(0) & " has been stored. Example: Dim varDaten As Variant varData = Array(" Christiane Roth". If you use arrays with two dimensions or more. The first argument can be thought as the rows and the second as the columns. but with braces () or []. you can easily use the 'For-Next' loop to iterate and access the elements of that array. Just use the index. Dim a() As Integer Page 80 of 143 . intJ) = intI * intJ Print sngMulti(intI. Sub changeArray () Dim intI As Integer. 26) Accessing the array is the same for both methods. Example: Dim varData(3) As Variant varData(0) = "Christiane Roth" varData(1) = "60529 Frankfurt" varData(2) = 26 But you can also use the 'Array'-Function. "60529 Frankfurt". which returns an array of type 'Variant' to create an array.

b) Syntax: Redim variableName(Index) Redim variableName[Index] Redim variableName[Index.] Redim variableName[Index To Index] Redim variableName[Index To Index. or value 0 (numerical types). KBasic set the values to 'Empty' (when type is 'Variant'). you use 'Redim' all values of the array are deleted. The amount of dimensions cannot be changed with 'Redim'. If it is a dynamic array. 33) .'The KBasic Book' of 1st quarter 2006 Reserve the right count of array elements with 'Redim' (in the future). or value 0 (numerical types). You can also use variables instead of literals (in fact every expression is permitted): Redim Matrix1 (a. Erase array1[. if it is 'String' with fixed size. Every time.] Array-reset / array-delete The command 'Erase' deletes arrays and frees the memory of arrays. too. if it is 'String' with fixed size. Example: Function calc() As Integer Dim Matrix1 () As Integer Redim Matrix1 (22. The statement 'Redim' can only be used inside procedures. Index. Every 'Redim'-statement can change the number of elements. or ASCII-0. .. It have the same syntax as 'Dim'... or „“ (if 'String'). or „“ (if 'String'). . the memory will be freed. Object types will be 'Null'. KBasic set the values to 'Empty' (when type is 'Variant').. and also the lower and upper bound of that array. if you do not use the keyword 'Preserve'. Object types will be 'Null' The memory is not freed. or ASCII-0. array2] When using static arrays all values of the array are deleted.. Page 81 of 143 . Index To Index..

'The KBasic Book' of 1st quarter 2006

Control of the program flow
The statements, which make the decision and loops, are known as control structures. Decisions It means the use of conditional statements in order to decide to do something. Conditional statements tests if a given expression is 'True' or 'False', after that statements depending on the test are executed. Normally, a condition uses an expression, in which a comparision operator is used to compare two values or variables. KBasic supports all VB6 conditional statements and much more. Single decision - If It is used to execute a set of statements, if a condition is set ('If'-statement). If the condition is 'True' then the statements after the 'Then' are executed and the statements after the 'Else' are skipped. If the condition is 'False' then the statements after the 'Else' are executed instead. If the item after 'Then' is a line number then a goto is executed. If the condition is 'True' and there is no 'Then' statement on the same line, statements are executed until a line with an 'End If' is found. If you run in 'KBasic Mode' the expression must be a boolean expression, otherwise any other numerical expression is allowed. Syntax:
If Expression Then Statement If Expression Then Statement : Else Statement If Expression Then LineNo If Expression Then LabelName: If Expression Then [Statements] End If If Expression Then [Statements] Else [Statements] End If If Expression Then [Statements] ElseIf Expression [Statements] Else [Statements] End If If Expression Then

Page 82 of 143

'The KBasic Book' of 1st quarter 2006
[Statements] ElseIf Expression [Statements] ElseIf Expression [Statements] Else [Statements] End If If Expression Then [Statements] ElseIf Expression [Statements] End If

'Else' introduces a default condition in a multi-line 'If'-statement. 'ElseIf' introduces a secondary condition in a multi-line 'If'-statement. 'End If' ends a multi-line 'If'-statement. 'If' evaluates 'expression' and performs the 'Then'-statement if it is 'True' or (optionally) the 'Else'-statement if it is 'False'. KBasic allows multi-line 'If'-statements with 'Else' and 'ElseIf' cases, ending with 'End If'. This works as zero is interpreted to be 'False' and any non-zero is interpreted to be 'True' Example:
Dim i As Integer Dim n As Integer If i 1 Then n = 11111 ElseIf i = 2 * 10 Then n = 22222 Else n = 33333 End If

IIf – short if It returns a value of two values depending on an expression. Example:
testing = IIf(Test1 > 1000, "big", "small")

Syntax:
IIf(Expression, ThenReturnExpression, ElseReturnExpression)

Page 83 of 143

'The KBasic Book' of 1st quarter 2006 Select Case The 'Select Case'-statement is much more complicated than the 'If'-statement: In many occasions, you may want to compare the same variable (or expression) with many different values, and execute a different piece of code depending on which value it equals to. This is exactly what the 'Select Case'-statement is for. It introduces a multi-line conditional selection statement. The expression given as the argument to the 'Select Case'-statement will be evaluated by 'Case'-statements following. The 'Select Case'-statement concludes with an 'End Select'-statement. As currently implemented, 'Case'-statements may be followed by string values, in this case complex expression can be performed. So the test expression can be 'True', 'False', or a numeric or string expression. Executes the statements after the 'Case'-statement which matches the 'Select Case'-expression, then skips to the 'End Select'-statement. If there is no match, and a 'Case Else'-statement is present, then execution defaults to the statements following the 'Case Else'. Syntax:
Select Case Expression Case Expression [Statements] Case Expression [Statements] End Select Select Case Expression Case Expression [Statements] Case Expression To Expression [Statements] Case Is Expression [Statements] Case Else [Statements] End Select

Example:
Dim i As Double Dim n As Integer i = 4 Select Case i Case 0 n = 0 Case 1, 2 n = 1122

Page 84 of 143

'The KBasic Book' of 1st quarter 2006 Case 4 TO 10 n = 441000 Case Is = 9 n = 9999 Case Else n = 999999 End Select Page 85 of 143 .

want to use labels. you do not have to worry about how to use them. "Bible". This type of branching can be accomplished by using the 'GoTo'-instruction. without a condition. "Casanova") Print s Syntax: Switch(Expression. Dim s As String s = Choose(1.. "troi") Print s Syntax: Choose(Expression. i = 2. however. "deux". programmers can also use unconditional branches. ReturnExpression. however. Example: Dim s As String Dim i As Integer i = 1 s = Switch(i = 1. ReturnExpression[. Because line numbers in KBasic programs are now obsolete (anyway. Expression. 'GoTo' is always executed. ReturnExpression[. ]) Choose – short select case It returns one value from a list of values depending on the index. . . "un". ReturnExpression. You may. 'GoTo' do a unconditional jump... there are supported). ]) Unconditional jumping Most of this chapter has been dedicated to conditional branches. If you recall.'The KBasic Book' of 1st quarter 2006 Switch – short select case It returns a value depending on an expression. Syntax: GoTo {LineNo | Label:} GoTo myExit: GoTo nextStep: Page 86 of 143 . which forces program execution to branch to a specific line number or label..

So your code becomes more readable and more changeable in elegent way. you are able to group assignments or statements. Loops repeats commands depending on a condition.Font. other repeats for all elements of a collection. Normally.Bold = True End With End Sub You can write a 'With'-statement inside another 'With'-statement: Sub setValue () With j(3) .isbn ( 99 ) = 333 End With End With End Sub Loop-statements The statements. other loops repeat commands while a condition is 'False'. For Next This loop is useful.e . It also reduces redundant code. Furthermore. which references the same object.bkname = "Frankfurter Zoo" With .e. which controls decisions and loops in KBasic. So it defines a loop that runs for a specified number of times. when you exactly know how often statements should be repeated. Some loops repeat commands while a condition is 'True'. Sub formSection () With myClass. are named control structures as already know.Value = 30 . there are other loops repeating a fixed number of times. but in many cases it is useful and needed to run a command several times until a defined state has been reached. . Syntax: For counter = start To stop [Step stepExpression] [Statements] Next [counter] Page 87 of 143 .'The KBasic Book' of 1st quarter 2006 With-Anweisung A very useful statement is the 'With'-statement. With the 'With'-statement. every command is executed only one time.

If you use 'Exit For'. . 'stop' and 'stepExpression' are integer expressions. If you wish to count in different steps than the default value of 1. Next ctr ' Output: ' ZZZZZ ' ' ' ' Example 2: Here we use STEP The resulting string is the same as in example 1 Dim ctr As Integer As Integer ctr = 1 To 50 Step 10 Print "Z". . 'For Next' loops will run fastest when 'counter' is an integer variable and 'start'. 'stop' is a numerical expression that determines the ending value at which the loop will stop. use 'stepExpression' to determine a specific value for incrementing the counter. however this is depreciated as it can lead to confusion when nesting several ' 'For Next' loops. Usually this is used in connection with an 'If' clause (If something Then Exit For) to exit the loop before its specified end. ' Example 1: Dim ctr As Integer For ctr = 1 To 5 Print "Z". Next ctr ' Output: ' ZZZZZ Page 88 of 143 . 'start' is a numerical expression that determines the starting value of the loop countings. this will exit the 'For Next' loop at once and continue with the line following to the 'Next' statement. The indication of 'counter' may be left out for the 'Next' statement.You can count backward by using 'stepExpression' with a negative incrementation value. Notes: . The 'Next' statement is the lower end of the loop and increments 'counter' by the value given by 'stepExpression' or by 1 if no 'stepExpression' incrementation is defined. which is used to store the current counter number while the loop is running. remember to end the loop last initiated (see example) or else an infinite loop will occur.'The KBasic Book' of 1st quarter 2006 'counter' is a numerical variable.The speed of 'For Next' loops depends on the kind of variables you use.Take extra care when nesting 'For Next' loops. The loop will be repeated as long as the value of 'counter' is smaller/greater than or equals the value of 'stop'.

Example: Dim rabbit As Integer ' counter of type Integer For rabbit = 0 To 3276 Next rabbit Dim hedgehog As Variant For hedgehog = 0 To 3276 Next hedgehog ' counter of type Variant. It is normally a fact that: The smaller the data type. the faster it can be used. In the first example.. The "y" loop is the INNER one and thus will end first: Dim x.Next-Loops You ought to use counter variables of type 'Integer' than of 'Variant'. because 'Integer' is much faster. For Each TODO2 Page 89 of 143 . Next y Print "-" Next x ' ' ' ' ' ' ' ' ' ' ' Output: Line 1 ZZZZZLine 2 ZZZZZLine 3 ZZZZZLine 4 ZZZZZLine 5 ZZZZZ- Optimize For. Variables of type 'Variant' are always slower used than the directly used data type.'The KBasic Book' of 1st quarter 2006 ' ' ' ' Example 3: These are nested loops. y As Integer For x = 1 To 5 Print "Line" + Str$(x) For y = 1 To 5 Print "Z". you see it runs faster..

" End Sub Sub SubAfter() Counter = 0 myNumber = 9 Do myNumber = myNumber Counter = Counter + Loop While myNumber > MsgBox "Loop has been End Sub . or you can test the condition after the commands of the loop have been executed at least one time. all commands are executed at least one time only. how often a command should be repeated. There are two different ways to use the keyword 'While' in order to test a condition within a 'Do. when you are not sure. because the condition is not true. Sub SubBefore() Counter = 0 myNumber = 20 Do Until myNumber = 10 myNumber = myNumber .. they exist different keywords: 'Do'. Therefore. You can test the condition before the commands inside the loop are executed. or you can test the condition after the loop has been entered (see procedure 'SubAfter' in the following example)..1 Counter = Counter + 1 Loop MsgBox "Loop has been executed " & Counter & " time(s). Sub SubBefore() Counter = 0 myNumber = 20 Do While myNumber > 10 myNumber = myNumber .. If you set 'myNumber' to 9 instead of 20. The loop will be repeated as long as the condition is 'False'..Loop'-statement. 'While'. If the condition is 'True' ( in the following procedure 'SubBefore') the commands inside the loop will be executed. 'Until' or ('Wend') . 'Loop'." End Sub Sub SubAfter() Counter = 0 myNumber = 1 Do Page 90 of 143 .1 Counter = Counter + 1 Loop MsgBox "Loop has been executed " & Counter & " time(s)." Two possibilities allow you to use the keyword 'Until' in order to test a condition of a 'Do. Inside procedure 'SubAfter'. no command inside the loop will be executed.Loop'-statement. You can test the condition before the loop (see procedure 'SubBefore' in the example).1 1 10 executed " & Counter & " time(s).'The KBasic Book' of 1st quarter 2006 Other kind of loops You can use the following loops.

.'Do' launches the loop and must be the first statement . Page 91 of 143 . .'While' lets the loop repeat while the condition is 'True' ." End Sub Do While.'Iterate Do' jumps directly to the 'Loop'-condition Syntax: Do While Expression [Statements] Loop Examples: In the first example..condition a numeric or string expression with a result of 'True' or 'False' .'Exit Do' exits the loop at this very line and lets the program continue behind the 'Loop'-statement .'The KBasic Book' of 1st quarter 2006 myNumber = myNumber + 1 Counter = Counter + 1 Loop Until myNumber = 10 "Loop has been executed " & Counter & " time(s).'Loop' ends the loop and must be the last statement . the loop will be repeated as long as 'xyz' remains 5: Do While xyz = 5 (lines of code) Loop Please note that the lines of code will never be executed if 'xyz' is not 5 when entering the loop.Loop A group of statements enabling you to define a loop which will be repeated until a certain condition remains 'True'.

Sometimes it is overseen that a variable checked for the outer loop is changed within the inner loop and thus the outer loop will never end: Do While counter < 10 (lines of code) counter = 0 Do Page 92 of 143 . the 'Exit'-statement may be helpful: Do (lines of code) If abc = 0 Then Exit Loop (lines of code) Loop While xyz <> 5 This means. Now you may use 'Iterate' instead: Do (lines of code) If abc = 0 Then Iterate Loop (lines of code) Loop While xyz <> 5 This means. it will skip the rest of the code lines within the loop and jump directly to its "Loop While xyz = 5". Note: Please be careful when nesting several loops within each other. if 'abc' becomes zero at anyone moment within the loop. The rest of the code lines will be skipped. you may move the condition to the end of the loop: Do (lines of code) Loop While xyz = 5 Now the lines of code will be executed at least one time before the loop checks for the value of 'xyz' and decides whether to exit or repeat execution.'The KBasic Book' of 1st quarter 2006 To overcome the problem of "never executed code". Sometimes it is necessary to skip the rest of the code lines but nevertheless stay in the loop to be repeated. You may use the condition with a number of expressions like 'And' and 'Or': Do While x < 10 And y < 10 (lines of code) Loop It will repeat while x and y are smaller than 10. Now the loop can check for the value of xyz and decide what to do. If there is a second condition which may arise somewhere within the loop making it necessary to exit the loop before the lines of code within it end. it will exit the loop. if 'abc' becomes zero at the 'If'-statement within the loop within the loop.

x = 5 Do While x = 5 Print x Loop Do. The same might happen with a 'For.'The KBasic Book' of 1st quarter 2006 counter = counter + 1 Loop While counter <> 5 Loop It would be a good idea to use a separate variables for each loop. Example: x = 0 Do Print x x = x + 1 Loop Until x > 3 Syntax: Do [Statements] Loop Until Expression Do....Loop Until It repeats until a condition is set.Loop While It repeats while a condition is set. Example: x = 0 Do Print x Page 93 of 143 .. be careful not to interchange the different loops: Do While counter < 10 (lines of code) For i = 1 TO 5 (lines of code) Loop Next i This will result in an error because 'Loop' has to appear after 'Next'.Next' loop within: Do While counter < 10 (lines of code) For counter = 1 To 5 (lines of code) Next counter Loop Moreover...

.Wend'-loop. The loop ends with 'Wend'.. and execution reiterates through the loop as long as the expression is 'True'. Example: While True Print 1234 Wend Syntax: While Expression [Statements] Wend While. x = 0 Do Until x > 3 Print x x = x + 1 Loop Syntax: Do Until Expression [Statements] Loop While Wend 'While' initiates a 'While.'The KBasic Book' of 1st quarter 2006 x = x + 1 Loop While x < 3 Syntax: Do [Statements] Loop While Expression Do Until.. While True Print 1234 End While Page 94 of 143 .Wend'. but with slightly different keywords as you have noticed. It reiterates through the loop as long as the expression is 'True'..End While It is the same like 'While.....Loop A group of statements enabling you to define a loop which will be repeated until a certain condition remains 'True'.

a loop condition is tested. As a result the current loop condition will be tested again. you have to use 'Iterate For'. after every loop iteration. • • 'Iterate For' – manually test loop condition of a 'For'-loop 'Iterate Do' – manually test loop condition of a 'Do'-loop Syntax: Iterate For Iterate Do Page 95 of 143 . You can manually exit a loop by using the 'Exit Do'-statement. a loop is left. you have to use 'Exit For'. You can manually test a loop condition by using the 'Iterate Do'-statement. As a result the current loop will be left. when its condition allows it. Syntax: Exit For Exit Do Explicitly leaving without Testing condition Normally. • • 'Exit For' – leave a for loop 'Exit Do' – leave a do loop For example. If you want to test 'For'-loop conditions.'The KBasic Book' of 1st quarter 2006 Syntax: While Expression [Statements] End While Explicitly leave a loop Normally. you could use 'Exit Do' in a 'If'-statement or 'Select Case'-statement. if you want to leave a infinity loop. But sometimes it might be useful to test the loop condition much earlier. But sometimes it might be useful to exit a loop much earlier. If you want to leave 'For'-loops.

g. which are always intended and formatted). Page 96 of 143 .'The KBasic Book' of 1st quarter 2006 Nested control structures You can embed control structures into other control structures. This is called nested control structures. you can put a 'For'-loop into 'If'-statement. but you should indent every control structure line. You can embed as many control structures as you want. e. so that your code is more easier to read (see the examples in this book.

each designed to demonstrate a single programming technique. When you start writing real programs. Because functions return values. they also become harder to organize and read. then it calls the related event-procedure.] [Statements] End Sub Page 97 of 143 . KBasic source code is inside a procedure.g. . expressions or constants. using procedures. which are given to the sub-procedure while calling it. the result of a complex math operation.g. e. e.. without return value. • • • • Sub (inside a module or class) Sub-procedure contain commands and statements. however. Syntax: Sub Name([Arguments]) [Statements] End Sub Sub Name([Arguments]) [Throws Name. Many builtin-functions of KBasic have arguments. A procedure is a set of commands inside the written words 'Sub' and 'End Sub' or 'Function' and 'End Function'. Sub (inside a class) better named as method. Is like a function-procedure Sub-Procedure A sub-procedure can have arguments. Variables. Function-procedures always return a value. There are different types of procedures. professional programmers developed something called modular programming. To have a solution for this problem. your programs have been pretty short. Is like a sub-procedure Function (inside a class) better named as method with return value. A procedure is like a small program within your main program.'The KBasic Book' of 1st quarter 2006 Procedures Probably. When KBasic notice that an event of a control occured. Functions like subs can have arguments.. you will discover that they can grow to many pages of code. Functions (inside a module or class) Function-procedure contain commands and statements. they can be used in expressions. normally. Event-procedures are always sub-procedures. but do not return a value or cannot be used in expressions. When programs become long. An event-procedure is related to a form or control.

. you must not write any expression. when the statements and commands of a procedure are executed. Syntax of arguments: Name As Type [ByVal | ByRef] Name As Type [ByVal | ByRef] Name [As Type] [ByVal | ByRef] Name [()][As Type] [ByVal | ByRef] [Optional] Name [()][As Type] [= Expression] Page 98 of 143 . All statements and commands are executed only after calling the procedure. Arguments have names. .. you can separate them by a comma (. But you must be sure the arguments you specify in the procedure’s call exactly match the type and order of the arguments in the procedure’s sub line. It looks like it and leads to automatically declared variables. Though.'The KBasic Book' of 1st quarter 2006 Function-Procedure A sub-procedure can have arguments. separate the arguments with commas. Function-procedures return values.g.] [Statements] End Function Arguments For all practical purposes. a procedure can have as many arguments as you like. variables. variable inside the braces. Every argument is like a variable declaration. If you have many arguments.g. The procedure’s sub line should list the arguments in the same order they are listed in the procedure call. when calling it. To use more than one argument in a procedure. keep in mind that the arguments are passed to the procedure in the order in which they appear in the procedure call. You can pass one or more arguments to a procedure. which are given to the sub-procedure when calling it. Abs). e. Many builtin-functions of KBasic have arguments (e.). If a procedure does not have arguments. expressions or constants. Syntax: Function Name([Arguments]) [As Type] [Statements] End Function Function Name([Arguments]) [As Type] [Throws Name.

'The KBasic Book' of 1st quarter 2006 Type can be one of the builtin types (scalar types). which is normally 'Variant'. birthDate := #2/28/79#. 26. The variable is no affected. Named arguments are also useful. and the expression the argument should have. intAge. birthDate As Date) Print strName. the default value is used. #2-28-79#) If you use named arguments. One way is to name the arguments. End Sub If you do not give a optional argument to a procedure. when you use procedures with optional arguments. 'Variant' or object/class type. Optional arguments are not always present in the procedure. If you use 'ByRef' it is changed! Named and optional arguments Thre are two ways to give arguments to a procedure. 'ByRef' and 'ByVal' are modifiers. it assume the default type. Arguments – the normal way: Named arguments: PassArg(intAge = 26. If you call a procedure. colon (:) and equal sign (=). strName := "Frank") PassArg(Frank".. you are able to list the arguments as you like. birthDate End Sub A named argument contains the argument name. Page 99 of 143 . and one argument is a variable and the matching argument is declared 'ByRef'. Example: Sub passArg(strName As String. Optional arguments can have default values as seen in the following example: Sub optionaleArg(str As String. It is probably more readable. If you do not tell KBasic the type. intAge As Integer.. Optional strCountry As String = "Germany") . So if the commands inside the procedure changes the value of the argument. So you do not have to give it the procedure. the other is the position relevant (default). It depends on if they have been given to the procedure. then KBasic do all operations on that argument on the given variable and does not copy the variable's value. 'ByVal' leads to a copy of the variable's value.

but it also can return a value. End Sub Writing function-procedure A function-procedure contains commands and statements.. strCountry As String = "Germany") .. which is used in an assignment statement (old style).32) * 5 / 9 End Function Main() Page 100 of 143 . A functionprocedure can also have arguments. strCountry End If End Sub You can call the procedure above with the following lines: optionaleArg(str := „test1“. Example: Sub Main() temp = InputBox(Prompt:= _ "Fahrenheit?") MsgBox "Fahrenheit = " & Celsius(temp) End Sub Function Celsius(fGrad) Celsius = (fGrad . A function-procedure is like a sub-procedure.' and before 'End Function'.. _ Optional strCountry As String = "Germany") If IsMissing(strCountry) Then Print str Else Print str. which is the new style. That is the only difference between them. strCountry := "Germany") optionaleArg(str := „test1“) Arguments with a default value are also possible as seen in the following example: Sub optionaleArg(str As String.. which are after 'Function . But you should use the keyword 'Return' for return values. A value can be returned by using the function name as an variable.'The KBasic Book' of 1st quarter 2006 It might be useful to check the argument with the 'IsMissing'-function: Sub optionaleArg(str As String.

There are other kinds of comments. it might be useful to comment this new or changed code. If it is a different module. Comments starts with ('). Example: Sub Main() MultiBeep 56 DoMessage End Sub Sub MultiBeep(no) Dim counter As Integer For counter = 1 To no Beep Next counter End Sub Sub DoMessage() Print "Tee time!" End Sub Main() Add comments to a procedure When you create a new procedure or change some code. you will find more information about them in the previous chapter about comments. all arguments must be placed inside braces. when it is executed. They only help to understand the code for other developers. Call of procedures with same name You can call a sub-procedure. you have to write the name of the sub-procedure to call. Those comments have no effect on the program. The keyword 'Call' is not needed. This character tells KBasic to ignore all text until end of line has been reached. You ought to use procedures to organize and split your code. and all needed arguments. If you use it. Example: Sub Main() Module1. in order to get it more readable.myProcedure() End Sub Page 101 of 143 . it might be useful to use module name to address the sub-procedure. from everywhere you want.'The KBasic Book' of 1st quarter 2006 Call of sub-procedures and function-procedures In order call a sub-procedure within another procedure.

you need a variable. Example: answer3 = MsgBox("Are you satisfied with your income?") If you do not need the return value." End If End Sub Use of brackets while calling a function-procedure In order to get the return value of a function-procedure. be sure that you change all places the class or module is used into the new name. 43100) Call costs (380950. • Leave procedure You can leave the procedure at every line inside of a procedure.5 * income <= 1. In order to avoid name collisions. You could use the file replace in the KBasic menu. 49500) ' old style End Sub Sub costs (price As Single. For that. else KBasic will run into an error. income As Single) If 2.8 * price Then Print "House to expensive. you ought to give your procedures unique names. you can ignore it and use the function-procedure like an ordinary sub-procedure.'The KBasic Book' of 1st quarter 2006 Hints for calling procedures • When changing the name of classes or modules. Sub Main() costs (99800. Syntax: Exit Sub Exit Function ' inside a function-procedure Calling procedures with more than one argument The following example shows calling a sub-procedure with more than one argument." Else Print "House is cheap. Example: MsgBox "Task done!" Page 102 of 143 . you can use the keywords 'Exit Sub' inside a sub-procedure or 'Exit Function' inside a function-procedure.

Fakulty = Fakulty(N . But in KBasic procedures are not only distinguished by their name. sburoutine. If an error raises. by checking the arguments. but different arguments is called overloading. Example: Function Fakulty (N) If N <= 1 Then ' end of recursive Fakulty = 1 ' (N = 0) no more calls Else ' Fakulty is called again ' wenn N > 0. But in some situations recursive procedures might be useful. Example: Function doError(Maximum) doError = doError(Maximum) End Function These error can be hidden. KBasic tries to check out what procedure you mean. Do not mix it up with overriding. Overloading of procedures In other languages. It might be useful in some situations. If you call a procedure and there are two or more procedures with the same name. Better use loops inside loops than recursion calls. it consumes memory again. when two procedures are calling each other once and once again or if no break out condition is used. check the break out condition. Page 103 of 143 .Try to minimize memory consumption: • • • Release unused variables Avoid data type 'Variant' Check the logic of the procedure. to be sure if it works as expected. When procedures calls themselves it is named recursive procedure. the name of the method (or function.1) * N End If End Function You ought to test a recursive procedure. or procedure) is enough to distinguish it from other methdos in the program. but also by their arguments and depending to an class or module. Defining procedures with the same name.'The KBasic Book' of 1st quarter 2006 Writing recursive procedures Procedures have limited memory. so if a procedure calls itself.

. you could create one subprocedure. place it in a module.. place it there. If you need several event-procedures to perform a task. when you did it explicitly. and so to duplicate code.] [Statements] End Function Page 104 of 143 . If it is related to the entire program. General procedures KBasic calls an event-procedure after an event occured. You can create normal procedures in forms or modules. that a form or control has raised an event. Functions Functions are very similar to subs. but functions returns a value and can be used in expressions. both are procedures. Normal procedures are only called. If the normal procedure is related to a form only. Syntax: Function Name([Arguments])[As Type] [Statements] End Function Function Name([Arguments])[As Type] [Throws Name. which is called inside the event-procedure. It is a better way as copy all code in each event-procedure. . it automatically calls the related event-procedure within a form.'The KBasic Book' of 1st quarter 2006 Event procedures When KBasic recognize.

If you do not define a return type. Data Types of functions Like variables has data types. For more information of using procedures see the chapter before. Function Return If you would like to set the return value of a function and exit the function as well. you also define a return type. which is the data type of the function. With this statement you immediatly leave the function. You should also define a return type for every function. Syntax: Return Expression Page 105 of 143 . When you define a function. The definition of a function-procedure is done using the keyword 'Function'. the default data type is assumend. function-procedures have data types as well. you should use 'Return'. which is 'Variant' normally.'The KBasic Book' of 1st quarter 2006 The arguments of a function-procedure are used as the arguments of a subprocedure.

and with properties you are able to check values or conditions. Those properties are builtin in KBasic. In fact. For example.'The KBasic Book' of 1st quarter 2006 Properties Most objects and controls have properties. which contains the value of the property. when you try to access the property. when I use a variable instead you may ask? Well. a 'CommandButton' control has a property called 'Caption'. the other writes the property (Set). Lots of other controls. whereas others are associated with only a single control or object. which you can think of as nothing more complicated than attributes. Additionally. One property-procedure reads the property (Get). You can code that the value of the property is always correct. For details you ought to check out the examples. but it might be useful to check something when accessing a variable. Syntax: Property Set Name(Argument) [Statements] End Property Property Get Name As Type [Statements] End Property Property Name As Type Get [Statements] End Get Set(Argument) [Statements] End Set End Property Page 106 of 143 . you have to declare a variable. It is like data hidding. but it is also possible to define your own properties within your user defined class. as you have already learned. such as the familiar 'Label' control. also have a 'Caption' property. it is easier to access a variable. which come with KBasic. Some properties are common in KBasic. Why should I use a property. which determines the text that appears in the button. Defining a property is like defining a procedure. a property contains of two property-procedures.

There exist some conversion builtin-functions for any data type: y% = CInt (expression) y% = CLng (expression) y! = CSng (expression) y' = CDbl (expression) y@ = CCur (expression) y = CVar (expression) y = CBool (expression) y = CByte (expression) y = CShort (expression) y = CDate (expression) ' ' ' ' ' ' ' ' ' ' returns returns returns returns returns returns returns returns returns returns Integer Long Single Double Currency Variant Boolean Byte Short Date Page 107 of 143 . Most time it is automatically done for you without notice. But sometimes it might be important to force a conversion. you do not have to change a data type of a expression. because your calculating would be else wrong.'The KBasic Book' of 1st quarter 2006 Conversion Normally.

The following example demonstrates how a local variable may be used. when you would like to organise your program or want to avoid name collisions of variables. from which place in the source code files. When you refer to a variable within your method definitions.variableName' to refer to the instance variable. So be sure that you understand all of it! Scopes tell KBasic. and just variable tu refer to the local varable. There are different scopes (abstract places in code): • • • • • • • Procedure scope Global scope Private module scope Public module scope Private class scope Protected class scope Public class scope Scopes are useful. a constant. or a procedure can be used. Another way to get around this paritcular problem. and then. KBasic checks for a defintion of that variable first in the current scope. Local scope A variable declared inside a procedure is not useable outside the procedure. Because of the way KBasic checks for the scope of a given variable. is to use 'Me. By referring explicitily to the instance variable by its object scope you avoid the conflict. The easiest way to get around this problem is to make sure you do not use the same names for local variables as you do for instance variables. This can introduce subtle and confusing bugs into your code. KBasic then checks for a definiton of that variable as an instance or class variable in the current class. when a variable. If that variable is not a local variable. only the code of the procedure in which the variable has been declared. then in the outer scopes of the current method defintion. however. it is possible for you to create a variable in a lower scope such that a definition of that same variable hides the orginal value of that variable. actually. can use it. finally.'The KBasic Book' of 1st quarter 2006 Modifiers / Scopes This is a very important aspect of the KBasic programming language or modern programming language in general. one of them has a variable declared: Sub localVar() Dim str As String str = "This variable can only be used inside this procedure" Print str Page 108 of 143 . in each parent class in turn. There are two procedures.

Example: ' add to the declaration section of your ' module the following lines Public str As String All procedures are as default 'Public' except the event-procedures. If you want to have a normal procedure as 'Private' write the keyword 'Private' before the declaration of that procedure. Default is 'Private'. it is visible to the entire program (all modules and classes). when you use the keyword 'Dim' to declare variables. Example: ' add to the declaration section of your ' module the following lines Private str As String Sub setPrivateVariable() str = "This variable may be only used inside this module" End Sub Sub usePrivateVariable() Print str End Sub Public module scope When you declare a variable as 'Public' inside a module it is global visible to all parts of your program. it is only visible to its module. in which it is declared. Because KBasic automatically writes 'Private' for every event-procedure declaration. Page 109 of 143 .'The KBasic Book' of 1st quarter 2006 End Sub Sub outOfScope() Print str ' causes an parser error End Sub Private module scope If you declare a variable as 'Private'. If you declare it as 'Public'.

.End Type) It has been very useful in times. Every name has a constant value.End Enum) It is a new way of grouping constants.'The KBasic Book' of 1st quarter 2006 User Defined Data Type (Type.... It is like a class. It is a list of names.. but without methods. Class Static Block Page 110 of 143 . End Type Enumeration (Enum. Syntax: Enum Name Name [= Expression] ... End Enum TODO2 $End End Stop Destructor Signal Slot IsArray . which are related to the same subject.. All kind of data types are allowed to be used inside a user defined data type. even other user defined data types are possible to be included. Syntax: Type Name Name [(Index)] As Type . when object-orientated programming have not been be available. many different variables are holded together...

Methods are executable inside classes. A class can contain: • declarations. when you use them. You can create as many procedures as you want. Signal/Slots-Methods These are special methods.g. Classes unlike procedures are not executed A class consists of a declaration part only. to write source codes from different forms at one place. which are only useful together with the Qt bindings. but you should not do that. Syntax: [Abstract] Class Name Inherits ParentClassName Page 111 of 143 . Additionally. Every class consists of the declaration part and the methods you have inserted. sub-procedures without return value or functionprocedures. You can archive your code within classes. • • • You can put several classes or modules in one file. Properties are accessable without the need to write braces. You can find and replace inside your source code as in a word processor and so on. types. where you can type in. so you need a place to write the source codes down outside the forms. You KBasic code is stored in classes or modules. while all source code is inside the form module of that form.. See the documentation of the Qt bindings in the KBasic IDE for more information. enumerations and constants Methods (also called procedures) which are not assigned to a special event or object. Edit Class It is not much different of editing a text in a word processor. which is useful for your forms. But if the application grows bigger and bigger it might be useful. Properties Are variables. which contains a methods. Here comes the classes. Methods are executed if the proper event is raised. Create a class. You have got an cursor showing the current position. for variables. a class contains no main program.. which are accessed through two special methods (get and set method). You have to create the methods for yourself. e.'The KBasic Book' of 1st quarter 2006 Classes A simple application can contain a form. or if another part of your program has called a method.

End Enum . [Public | Protected | Private] Constructor Name([Arguments]) [Statements] End Constructor .........'The KBasic Book' of 1st quarter 2006 [Static] Dim Name As Type [Static] Public Name As Type [Static] Protected Name As Type [Static] Private Name As Type Const Name As Type Public Const Name As Type Protected Const Name As Type Private Const Name As Type . [Public | Protected | Private] Property Name As Type Get [Statements] End Get Set(Argument) [Statements] End Set End Property .. [Public | Protected | Private] Type Name Name As Type . [Public | Protected | Private] Enum Name Name As Type . End Type ...... [Public | Protected | Private] Destructor Name( ) [Statements] End Destructor Page 112 of 143 .

.. [Public | Protected | Private] Signal Name([Arguments]) [Statements] End Signal .] [Statements] End Sub . . End Class Bigger example: Class Salsa Inherits Waltz 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 Dim publicModuleType As module1... [Public | Protected | Private] Slot Name([Arguments]) [Statements] End Slot .......module_type Dim publicModuleType2 As module_type ' parent constructor call inside constructor Page 113 of 143 . ..'The KBasic Book' of 1st quarter 2006 [Static] [Public | Protected | Private] Function Name([Arguments]) [As Type] [Throws Name. [Static] [Public | Protected | Private] Sub Name([Arguments]) [Throws Name.] [Statements] End Function ..

publicClassVar Dim localVar3 = Salsa.class_enum.publicClassVar Dim localVar4 = Salsa.'The KBasic Book' of 1st quarter 2006 Sub meExplicit() Dim localVar = Me.classConst ' Dim localVar6 As class_enum localVar6 = Salsa.Entry ' Dim localVar7 As Me.classConst Dim localVar5 = Me.class_enum ' 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 Static Public Sub test() Throws Waltz Throw New Waltz End Sub Private pvtFname As String Public Property Nickname As String Get Print "Hi" End Get Set ( ByVal Value As String ) Print "Hi" End Set End Property End Class full type name not allowed Page 114 of 143 .publicInstanceVar ' it is the same with parent Dim localVar2 = Me.

A module can contain: • declarations for variables. Procedures are executed if another part of your program has called a procedure.. a module contains no main program. Syntax: Module Name Dim Name As Type Public Name As Type Private Name As Type Const Name As Type Public Const Name As Type Private Const Name As Type Page 115 of 143 . You have to create the procedures for yourself. sub-procedures without return value or functionprocedures. So it is useful to place this code in a global module file. You can create as many procedures as you want. types. You can archive your code within modules.. you propably would like to use the same code in different forms. Edit Module It is not much different of editing a text in a word processor. Put there your procedures. while the complete source code is in one form module.'The KBasic Book' of 1st quarter 2006 Module A simple application can consist of only one form. Every module consists of the declaration part and the procedures you have inserted. When your applications grow bigger and bigger. unlike procedures are A module consists of a declaration part only. You can access them from everywhere in your program. You KBasic code is stored in classes or modules. Additionally. but you should not do that. you often use in forms or event-procedures. You can find and replace inside your source code as in a word processor and so on. e. Modules are not executed. • You can put several classes or modules in one file. where you can type in.g. from where it is accessable by the entire application. Global Modules Global modules are always present. You have got an cursor showing the current position. enumerations and constants procedures which are not assigned to a special event or object.

] [Statements] End Sub ... [Public | Private] Sub Name([Arguments]) [Throws Name. [Public | Private] Function Name([Arguments]) [As Type] [Throws Name. [Public | Private] Type Name Name As Type ..] [Statements] End Function ...'The KBasic Book' of 1st quarter 2006 . End Type .. End Enum ... End Module Bigger example: Module module1 Public Type address age As Integer End Type Public Type module_type element AS integer End Type Public Enum module_enum Entry Entry2 Security = Entry End Enum Page 116 of 143 ...... .. ..... [Public | Private] Enum Name Name As Type .

Entry Dim localVar4 As module_type 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 Page 117 of 143 .Entry End Sub Sub moduleImplicit() Dim localVar = publicModuleVar Dim localVar2 = moduleConst Dim localVar3 As module_enum localVar3 = module_enum.'The KBasic Book' of 1st quarter 2006 Const moduleConst = 7 Public publicModuleVar As Integer Private privateModuleVar As Integer Sub moduleExplicit() Dim localVar = module1.publicModuleVar Dim localVar2 = module1.module_enum.moduleConst Dim localVar3 As module_enum localVar3 = module1.

'The KBasic Book' of 1st quarter 2006 subOverloading() subOverloading(88) Return "hello" End Function Function moduleFunctionRecursive(ByRef i As Integer) As If i > 6 Then Return 1''i ''i = i + 1 Return moduleFunctionRecursive(1)''i) End Function End Module Integer Page 118 of 143 .

Runtime error These kind of errors occur. if no error handler has been defined in the place the error occured. meaning that you have to use the right syntax. but you ought to use the new error handling syntax (exceptions).'The KBasic Book' of 1st quarter 2006 Error handling Developers in any language always wanted to write bug-free programs. dots and so on). which is not allowed in any math expression. KBasic will stop the execution of your program. corrupt fields that do not have the right data in them. Logic error These kind of errors occur. An example of such an error is a division by zero. programs like this do not exist. Old error handling syntax is supported like 'On Error GoTo'. If an runtime error occur. In real programs. Good intenions aside. or because of situations out of the programmer's control. programs that never crash. either because the programmer did not anticipate every situation your code would get into (or did not have the time to test the program enough). erros occur. Maybe you wrote a keyword wrong. or you forgot to write all needed marks (braces. Three possible error sources exist: • • • Error while compiling These kind of errors occur. when syntax and runtime behaviour is ok. when your program is executed. or misused a keyword on the wrong place. Page 119 of 143 . programs that can deal with any situation with grace and that can recover from unusual situations without causing the user any undue stress. when statements are written in a wrong way. You can only be sure that your program works as you want if you test and analyse any result. when KBasic founds an error at runtime. bad data from users. and so on. but the program does not work as intended or exprected.

To create an exception means to signal this special stage. whatever happend" End Catch End Sub Page 120 of 143 . An exception is a signal showing that a non-normal stage has been reached (like an error). Example: Public Sub tt2() Throws samba Try test() Catch (b As rumba) Print "tt2: got you!" b. The exception handling is an important feature of KBasic. doing some commands to deal with this special stage in order to get to normal stage. these sorts of strange events/errors that my cause a prgoram to fail are called exceptions.dance() Finally Print "tt2: will be always executed.'The KBasic Book' of 1st quarter 2006 Exceptions In KBasic. To catch an exception means to handle an exception.

'Finally' has some commands. first the 'Catch'-statement is executed. 'Catch' contains the commands.'The KBasic Book' of 1st quarter 2006 Exceptions are walking from the origin to the next control structure (caller of the current procedure). when you have commands. Example: Sub mySub() Throws myException1. 'Catch'-statements are like a variable declaration. they can contains data and methods as any other class or object. which should be always executed. which is an instance of a 'Object' or any other class.. myException2 ' statements which can raise myException1 or myException2 . like file accessing or database closing. you can define as many 'Catch'-statements as you want.statement and so on. KBasic will show the error to the user and the execution of the program will stop. If you have defined a 'Catch'-statement and 'Finally'-statement and the matching exception is raised. which should run fine. which can raise an exception. that every procedure. Catch After a 'Try' and its commands. Finally 'Finally' is useful. after that the 'Finally'-statement is executed. 'Try' encloses the normal code. which must be always executed even an exception has occured. If it is not catched.. 'Try' does not work alone. Try 'Try' encloses the normal code. First it is tested. if an exception has happened or not. and tries again to find a 'Try-Catch'-statement or a 'Throw'. which should run fine. then it matches.). Because exceptions are objects. must define a exception with an 'Throw'-statement in its declaration. which should be executed. Exception-objects An exception is an object. If not KBasic looks up the caller of the current scope. Exception handling The 'Try-Catch'-statement is needed to catch an exception. It comes always with at least one 'Catch'-statement or 'Finally'-statement. but the exception object is only created. if an exception has been raised. End Sub Page 121 of 143 . Declaration of exceptions KBasic demands. if a 'Try-Catch'-statement or an throw statement has been defined in the current scope (procedure etc.

You often create these object before throwing it. It searches all statements including the place the exception was thrown. To use exceptions is a create way of dealing with errors. After 'Throw' you must write the object to throw. Often you can use a simple error object. Throw New MyException1() Syntax: Throw ExceptionObject If an exception is thrown. Syntax: Try [Statements] Catch (Name As Exception) [Statements] End Catch Try [Statements] Catch (Name As Exception) [Statements] Catch (Name As Exception) [Statements] End Catch Try [Statements] Catch (Name As Exception) [Statements] Finally [Statements] End Catch Complete example: Class rumba Sub dance Print "rumba.'The KBasic Book' of 1st quarter 2006 Define and generate exceptions You can raise your own exceptions using the 'Throw'-statement. it is easy and clean to read. the normal program execution is left. e.dance" End Sub End Class Page 122 of 143 .g. but sometimes it is better to use a new self-created error object. and KBasic tries to find a proper 'Catch'-statement for these exception. All 'Finally'-Statements are executed on these path. using the 'New'-statement.

dance" End Sub End Class Public Sub test() Throws rumba.dance() Finally Print "tt2: will be always executed. samba Throw New rumba ' return rumba = new rumba End Sub Public Sub tt2() Throws samba Try test() Catch (b As rumba) Print "tt2: got you!" b.'The KBasic Book' of 1st quarter 2006 Class samba Sub dance Print "samba. whatever happend" End Sub tt() Page 123 of 143 .dance() Finally Print "tt: will be always executed. whatever happend" End Catch End Sub Public Sub tt() tt2() Catch (c As samba) Print "tt: got you!" c.

whatever happend" End Sub Syntax: Catch (Name As Exception) [Statements] Finally [Statements] End Catch Page 124 of 143 .dance() Finally Print "tt: will be always executed. Write down the needed catch and finally statements. and is something like the old 'On Error GoTo'. Example: Public Sub tt() tt2() Catch (c As samba) Print "tt: got you!" c. It makes it easier to read your code. A try statement is not needed.'The KBasic Book' of 1st quarter 2006 Exception at the end of a procedure It is possible to catch an exception at the end of a procedure. which covers the whole procedure. because the whole procedure is meant.

The source code editor is a tool for editing source code. KBasic provides tools to make designing forms a simple process. change visibility. Editor KBasic has one editor for creating and managing KBasic projects. These windows include: • Form designer – drag and drop controls. • Property window – lists and lets you control the properties for your controls. It is actually an integrated development environment (IDE). For example. and editors that make developing your KBasic application easy. as well as arrange them to this main development area. toolbars. The debugger allows you to watch your programs execute line by line. When a development environment is said to be intergrated. • Project window – work with the different parts of your project in this window. such as editing source code and manipulating classes. you can monitor: • the values stored in variables • which subs/functions/methods are being called • the order in which program events occurred Page 125 of 143 . By using the debugger. and change colors and fonts of your controls. Debugger One of the most powerful tools in the KBasic environment is the integrated debugger. In addition to displaying the error. • Toolbox window – the central place where often used controls can be accessed • Source code editor – it is where you add and customize source code for your project in any phase of the development cycle. Toolbars can be docked in the KBasic window or floated on the screeen. It is the primary tool you use to create your programs. KBasic opens the source file in the text editior and jumps to the exact line in the source code. As your program executes. where the error occurred.'The KBasic Book' of 1st quarter 2006 The KBasic development environment The KBasic development environment contains windows. assign values. Toolbars KBasic provides an extensive set of toolbars. including monitoring the status of your projects at any time. Windows KBasic windows are the eares on your screen that you use to develop your programs. (only the professional version). this means that the tools in the environment work together. You can resize. A large part of application development involves adding and arranging controls on forms. name. the compiler might find an error in the source code. You can use these editor to control the development of your projects. you can observe the various components of the program to see how they are behaving. Its views include objects and files.

KBasic creates a form module automatically.kbasic_form Forms In your KBasic-application forms are not only masks for inputting and changing data. they are the application! By creating your application using forms.kbasic_project file lies and many other files: • • • *.kbasic_class *. a size and a foreground color. but they are the graphical interface of your application. every module can contain other non-event procedures. such as an application window containing a button. you need to create a new project. you work mainly with projects. KBasic provides an easy yet sophisticated system to manage the collection of files that make up a project.kbasic_module *. such as a Timer. Those event procedures react on events raised in the form. you add visual objects/controls to your forms to assemble applications. A project consists of many separate files collected in one project directory. Starting a new application with KBasic begins with the creation of a project. In the eyes of the beholder. and non-visual objects. when you copy a form.'The KBasic Book' of 1st quarter 2006 Collection TODO2 Classes and objects of KBasic There are two types of objects in in KBasic: visual objects. If you delete a form. A visual object is a control and visible at runtime and lets users interact with your application. which are raised in the forms. Central meaning of forms Each form in a KBasic application has got a form module with event procedures. You create a project to manage and organize these files. When developing an appication in KBasic. it has a screen position. too. Projects Projects keep your work together. The project window shows each item in a project. where one *. Some objects can contain other components. So before you can construct an application with KBasic. An invisible object is not visible at runtime. A project is a collection of files that make up your KBasic application. its form module is automatically copied. With KBasic. So you need only to write the event procedures and other procedures. its form module is deleted as well. Additionally. Forms hold your KBasic program together! Page 126 of 143 . Examples of visual objects are forms and buttons. A form module is part of every form. you control the program flow with events.

Because of the procedures are private inside a form module.'The KBasic Book' of 1st quarter 2006 Procedure in forms The procedures in form modules of a form are private procedures of this form. Page 127 of 143 . But the names of procedures in global modules must be equal. or global modules • If KBasic does not find a procedure with the needed name. KBasic uses two rules to recognize the right procedure to execute: • KBasic searches the current form module at first. which has got the same name as a procedure in a global module. reaches this procedure. you can use them only inside the form module. you can use the equaly named procedures in many forms. Calls outside the module run the public procedure. In this case. So all calls inside a module. in which the procedure is declared. it searches the global modules (but not the other form modules) for the needed procedure name. It is possible to create a procedure in a form module.

It comes with truly Java-like object orientation and backward support for VB6 and QBasic. better use the default value of an argument use always 'Do While.'The KBasic Book' of 1st quarter 2006 Compatibility VB6 = KBasic KBasic supports 100% of the syntax of VB6.Loop While' instead of the other loops always write many comments in your source code use in conditions 'AndAlso' and 'OrElse' instead of the binary operators 'And' and 'Or' avoid the use of 'ByRef' with primitive data types to get faster execution speed do not use 'Data' and 'Def*'. Many components are equal as well.Loop' and 'Do .. It is possible to develop Qt applications with well known BASIC syntax in a modern fashion. better use real functions or real subs avoid the use of 'GoTo'.. like 'DefInt' use enumerations instead of many integer constants use constants. better use loops and other control flow language elements 'Let' and 'Set' are not needed use 'For Each'. instead of the use of numeric literals many times in your source code avoid the use of 'GoSub'. when it is possible use 'For i As Integer = 0 To 10 Next'. KBasic combines the expressive power of object-oriented languages like C++ with the familiarity and ease of use of VB6. better use 'Try Catch' do not use 'Nothing'. as it is 100% syntax compatible. better use [ ] do not use 'Option OldBasic' or 'Option VeryOldBasic' do not use 'On Error Goto'. It allows developers with an installed base of VB6 applications to start developing for a mixed Windows and Linux environment without having to face a steep learning curve: KBasic uses the familiar visual design paradigm and has a full implementation of the BASIC language. instead of declaring the counter variable outside of the loop name the variable names without giving them suffixes use always ( ) when you call a sub or function Page 128 of 143 .. Migrating from VB6 to KBasic Some information which might help you to migrate are listed in the following: • • • • • • • • • • • • • • • • • • • • • • do not use ( ) to access arrays.. the same for the destructor do not use 'Call' when calling a sub or function do not use 'Optional' and 'IsMissing' with arguments in subs or functions. better use 'Constructor'. better use 'Null' avoid the use of the data type 'Variant' do not use 'class_initialisize'.

Qt has formed the basis of many thousands of successful applications worldwide. Summarized: The KBasic virtual machine is a virtual computer. Qt is supported on the following platforms: • MS/Windows -. you can access more than 200 of the Qt classes and use and inherit them. g. A pcode is a command with length of 2 bytes. Since its commercial introduction in early 1996. NT 4. in which KBasic programs are executed. Together with KBasic you are able to create modern object oriented applications. ME. SGI IRIX and a wide range of others Page 129 of 143 . and XP • Unix/X11 -. as a machine code statement means for the CPU. Qt is fully object-oriented. OpenGL. How to use SQL modules and so on. 2000. In general means that KBasic-pcode is the same for the virtual machine. It provides application developers with all the functionality needed to build applications with state-of-the-art graphical user interfaces. GUI Qt is a multiplatform C++ GUI toolkit created and maintained byTrolltech. These commands are named as p-code or pseudo code. These environment can execute special commands.'The KBasic Book' of 1st quarter 2006 KBasic's virtual machine The KBasic virtual machine is the environment. called pseudo-codes. that the name 'KBasic' much more means than a programming language.Linux. It means also a complete computer environment. easily extensible. and allows true component programming. TCP/IP. Sun Solaris. The reason is: KBasic contains of two units: KBasic design (the programming language) and KBasic runtime (the virtual machine).95. The KBasic-interpreter is able to execute these pseudocodes. When the compiler compiles a KBasic programm.3. More information is available at www. for tasks such as GUI. It is important to know.0. like using devices Qt-Bindings Qt 3. It is a kind of abstract computer and defines the commands a KBasic program can use. a standard component of all major Linux distributions.trolltech. Therefore. HP-UX. in which KBasic programs are executed. e. IBM AIX. Compaq Tru64 UNIX. control their methods and properties. 98.X is a powerful cross platform toolkit. What are the main functions of the virtual machine? The virtual machine (VM) does the following tasks: • Assign allocated memory to created objects • Deallocate memory automatically • Handle the stack and registry of variables • Access the host system. Network.com. which are generated by the KBasic-compiler from a KBasic program. which is generated by the KBasic-compiler and interpreted by the KBasicinterpereter. Qt is also the basis of the popular KDE Linux desktop environment. SQL and XML. it produces a set of pcodes and saves them.

Mac OS X Embedded -. Network and TCP/IP The network module offers classes to make network programming easier and portable.Linux platforms with framebuffer support. which provide an abstract layer for implementing network protocols and QUrlOperator which operates on such network protocols.The SQL Module uses driver plugins in order to communicate with different database APIs. Finally the third set of network classes are the passive ones. QDns. In addition. specifically QUrl and QUrlInfo which do URL parsing and similar. Since the SQL Module API is database-independent.1 and higher) • Borland Interbase • MySQL (v3 and higher) • Oracle (v8 and 9) • ODBC • PostgreSQL (v6 and v7) • SQLITE • Sybase Adaptive Server • Microsoft SQL Server Driver Page 130 of 143 .'The KBasic Book' of 1st quarter 2006 • • Macintosh -. Supported SQL-Databases are: • IBM DB2 Driver (v7. there are classes like QNetworkProtocol. QNetworkOperation in the Qt base library. first low level classes like QSocket. Essentially. QServerSocket. etc. Several drivers are supplied with Qt and other drivers can be added. which allow you to work in a portable way with TCP/IP sockets. all database-specific code is contained within these drivers. there are three sets of classes. SQL Qt's SQL classes help you provide seamless database integration to your Qt applications.

saxproject.org/DOM/. Commercial software It is also possible to develop commercial software using Qt: but to do so you must buy a commercial license for the Professional or Enterprise Edition. Thousands of commercial companies use commercial editions of Qt to develop the products they sell. More information are available at http://www.com/ Page 131 of 143 . Unix/X11. The Qt OpenGL module makes it easy to use OpenGL in Qt applications.w3. The Free Software Foundation (creators of the GNU GPL) speaks of free in this context as in "free speech".trolltech. and to pass it on (under the same terms).e. to obtain its source. Trolltech's support of open source with the Qt Free Edition has enabled large successful software projects like KDE. not as in "no cost". not money. It provides an OpenGL widget class that can be used just like any other Qt widget. Notice that the term "free" is about rights. SAX is an event-based standard interface for XML parsers. i. More information about the DOM classes in Qt is provided in the Qt DOM classes. DOM Level 2 is a W3C Recommendation for XML interfaces that maps the constituents of an XML document to a tree structure. to modify it. Trolltech supports the free software concept by providing the Qt Free Edition. Details on SAX2 can be found at http://www. License issues Free (or open source) software is software that comes with a license that gives users certain rights. to thrive. Qt Free edition is available for Windows. In particular the right to use the software. Macintosh and Linux/embedded. The Qt interface follows the design of the SAX2 Java implementation. Its naming scheme was adapted to fit the Qt naming conventions. OpenGL OpenGL is a standard API for rendering 3D graphics. software that is licensed under the GNU GPL or a similarly recognized open source license. with thousands of developers around the world using the Qt Free Edition at no cost to themselves. OpenGL only deals with 3D rendering and provides little or no support for GUI programming issues.'The KBasic Book' of 1st quarter 2006 XML The XML module provides a well-formed XML parser using the SAX2 (Simple API for XML) interface plus an implementation of the DOM Level 2 (Document Object Model). except that it opens an OpenGL display buffer where you can use the OpenGL API to render the contents.org. You can use this edition of Qt to create free software. If you buy a commercial edition of Qt you can sell your software for any price and with any license you like. Details and the specification of DOM Level 2 can be found at http://www.

Qtopia provides a window system and application suite for handheld devices. On top of that. Qt enables you to build professional. Qt/Embedded. Australia. Their flagship product is Qt. is designed to power todays new generation of embedded computers and electronic consumer devices. the multi-platform C++ GUI toolkit. the embedded version of Qt. the capital of Norway. California. and Palo Alto. portable and maintainable GUI applications quickly and easily.'The KBasic Book' of 1st quarter 2006 About Trolltech Trolltech is an international software company with headquarters in Oslo. efficient. Page 132 of 143 . and with offices in Brisbane.

$Dynamic #Else $End #ExternalSource #If #Region $Static Absolute Abstract AddressOf Alias Ansi As Assembly Auto Base ByRef ByVal Call CallByName Case Catch Chain Choose Class Class_Initialize Class_Terminate COM Common Compare Const Constructor Data Database Decimal Declare Def Default DefBool DefByte DefCur DefDate DefDbl DefInt DefLng DefObj DefSng DefStr DefVar Delegate Destructor Dim DirectCast Do Each Else ElseIf Empty End EndIf Enum Erase Event Exit Explicit Finally For Friend Function Global GoSub GoTo Handles If IIf Implements Imports In Inherits Interface Is Iterate KBasic Key LBound Let Lib Like Loop LSet Me Mid Module MustInherit MustOverride MyBase MyClass NameSpace New Next Nothing NotInheritable NotOverridable Null Off OldBasic On Option Optional Overloads Overriddable Overrides ParamArray Parent Pen Play Preserve Private Property Protected Public Range Read ReadOnly ReDim Rem /** /* */ ' Repeat Restore Resume Return RSet Run Select Set Shadows Shared Signal SizeOf Slot Static Step Stop STRIG Structure Sub Swap Switch SynClock System Text Then Throw Throws Timer To TROFF TRON Try Type TypeDef UBound UniCode Until VARPTR VARPTR$ VARSEG VeryOldBasic Wait Wend While With WithEvents WriteOnly Builtin Functions __Class__ __File__ __IsClass__ __IsLinux__ __IsMacOS__ __IsModule__ __IsSub__ __IsWindows__ __Line__ __Module__ __Scope__ __Sub__ Abs Access Acs AddHandler AppActiviate Append Array Asc Asn Atn Beep Bin Bin$ Binary BLOAD BSAVE CBCD CBool CByte CChar CCur CDate CDbl CDec CEXT CFIX ChDir ChDrive Chr Chr$ CInt Circle Clear CLng Close CLS CObj Color Command Command$ Cos CQUD CreateObject CShort CSng CsrLin CType CurDir CurDir$ CVD CVDMBF CVERR CVI CVL CVS CVSMBF Date Date$ DateAdd DateDiff DatePart DateSerial DateValue Day DDB Deg DeleteSetting Dir Dir$ DoEvents DOF Draw Environ Environ$ EOF ErDev ErDev$ Erl Err Error Error$ Exp Fact Field FileAttr FileCopy FileDateTime FileLen Files Filter Fix FN Format Format$ FormatCurrency FormatDateTime FormatNumber FormatPercent Frac FRE FreeFile FV Get GetAllSettings GetAttr GetAutoServerSettings GetObject GetSetting GetType Hex Hex$ Hour Hypot IMEStatus Inkey Inkey$ Inp Input Input$ InputBox InStr InStRev Int IOCtl IOCtl$ IPMT IRR IsArray IsBoolean IsByte IsCharacter IsCollection IsCString IsCurrency IsDate IsDouble IsEmpty IsError IsInt16 IsInt32 IsInt64 IsInteger IsMissing IsNull IsNumeric IsObject IsShort IsSingle IsUInt16 IsUInt32 IsUInt64 IsLong IsString IsVariant Join Kill LCase LCase$ Left Left$ Len Line Ln Load LoadPicture LoadResData LoadResPicture LoadResString Loc Locate Lock LOF Log Logb LPos LPrint LTrim LTrim$ Max Mid$ Min Minute MIRR MKD$ MkDir MKDMBF$ MKI$ MKL$ MKS MKS$ MKSMBF$ Month MonthName MsgBox MTIMER Name Now NPER Page 133 of 143 . Some of them are reserved for the future. Keywords A keyword is a predefined identifier. which has a special meaning for KBasic and which meaning cannot be changed.'The KBasic Book' of 1st quarter 2006 Lexical Unit The following information descibes predefined identifiers and keywords of KBasic. The following list contains all KBasic keywords.

* / Mod = <> >= <= > < And AndAlso Or OrElse Not ^ & Xor \ Eqv Imp Types Boolean Byte Character Collection CString Currency Date Double Int16 Int32 Int64 Integer Long Object Short Single String UInt16 UInt32 UInt64 Variant Page 134 of 143 .'The KBasic Book' of 1st quarter 2006 NPV Nz Oct Oct$ Open Out Output Paint Palette Partition PCopy Peek PMAP PMT Point Poke Pos PPMT Preset Print PSet Put PV QBCOLOR Rad Raise RaiseEvent RaiseSignal Random Randomize Rate RemoveHandler Replace Reset RGB Right Right$ RmDir RND Round RTrim RTrim$ SavePicture SaveSetting Screen Sec Second Seek Seg SendKeys SetAttr Sgn Shell Sin Sleep Sln Sound Space Space$ Spc Split Sqr Stick Str Str$ StrComp StrConv String String$ StrReverse SYD Tab Tan Time Time$ TimeSerial TimeValue Trim Trim$ TypeName TypeOf UCase UCase$ UnLoad UnLock Using Val VarType View Weekday WeekdayName Width Window Write Year Operators << >> Inc Dec += -= /= *= BitAnd BitOr BitXor BitNot + .

/ 048 049 050 051 052 053 054 055 056 057 058 059 060 061 062 063 0 1 2 3 4 5 6 7 8 9 : .'The KBasic Book' of 1st quarter 2006 ASCII-Codes (codes 0 . < = > ? 064 065 066 067 068 069 070 071 072 073 074 075 076 077 078 079 @ A B C D E F G H I J K L M N O 080 081 082 083 084 085 086 087 088 089 090 091 092 093 094 095 P Q R S T U V W X Y Z [ \ ] ^ _ 096 097 098 099 100 101 102 103 104 105 106 107 108 109 110 111 ` a b c d e f g h i j k l m n o 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 p q r s t u v w x y z { | } ~ ¦ Page 135 of 143 .127) 000 001 002 003 004 005 006 007 008 009 010 011 012 013 014 015 ? ? ? ? ? ? • ? ? ? ? ¤ (nul) (soh) (stx) (etx) (eot) (enq) (ack) (bel) (bs) (tab) (lf) (vt) (np) (cr) (so) (si) 016 017 018 019 020 021 022 023 024 025 026 027 028 029 030 031 ? ? ? ? ¶ § ? ? ? ? ? ? ? ? ? (dle) (dc1) (dc2) (dc3) (dc4) (nak) (syn) (etb) (can) (em) (eof) (esc) (fs) (gs) (rs) (us) 032 033 034 035 036 037 038 039 040 041 042 043 044 045 046 047 sp ! " # $ % & ' ( ) * + . .

'The KBasic Book' of 1st quarter 2006 Command arguments for KBasic TODO2 Page 136 of 143 .

Also see Debugging.'The KBasic Book' of 1st quarter 2006 Appendix Argument A value that is passed to a procedure or function. Boolean Expression A combination of terms that evaluates to a value of true or false. you can more easily find errors in your programs. Also see Parameter. Arithmetic Operations Mathematical operations such as addition. Also see Bit. Boolean A data type that represents a value of true or false. rather than continuing to execute instructions in strict order. and division that produce numerical results. A bit can be only one of two values. (x = 5) And (y = 6). multiplication. Breakpoint A point in a program at which program execution should be suspended in order to enable the programmer to examine the results up to that point. BASIC Beginner’s All-Purpose Symbolic Instruction Code. For example. Bit The smallest piece of information a computer can hold. KBasic automatically employs a compiler when you run a program or select the File menu’s Make command to convert the program to an executable file (only Professional Version). Compiler A programming tool that converts a program’s source code into an executable file. Also see Interpreter. Branching When program execution jumps from one point in a program to another. Byte A piece of data made up of eight bits. Array A variable that stores a series of values that can be accessed using a subscript. subtraction. the computer language upon which kBasic is based. By setting breakpoints in a program. 0 or 1. Also see Conditional Branch and Unconditional Branch. Concatenate Page 137 of 143 .

For example. denoted in a program by two double quotes.75 and 235. For example. the following example sets a variable called str1 to an empty string: str1 = “”. String. Also see Increment. which causes the program to branch to a program line based on a condition such as If (x=5). usually an application. Also see Double and Single. Decrement Decreasing the value of a variable. File A named set of data on a disk.7584 are floating-point values. Empty String A string that has a length of 0. Most executable files end with the file extension . 12.EXE on Windows. two text strings into one text string. For example. Constant A predefined value that never changes. end to end.'The KBasic Book' of 1st quarter 2006 To join. Long. An example of a conditional branch is an If/Then statement. the string “OneTwo” is a concatenation of the two strings “One” and “Two”. and Boolean. Event A message that is sent to a program as a result of some interaction between the user and the program. Single. that the computer can load and run. Conditional Branch When program execution branches to another location in the program based on some sort of condition. also known as a double-precision floating-point value. Executable File A file. Double The data type that represents the most accurate floating-point value. usually by 1. Double. Form Page 138 of 143 . Debugging The act of finding and eliminating errors in a program. These values include Integer. Data Type The various kinds of values that a program can store. Also see Floating Point and Single. Floating Point A numerical value that has a decimal portion.

Also see Compiler. The form is the container on which you place the controls that make up your program’s user interface. the program line If X = 5 Then Y = 6 is a logical error if the variable X can never equal 5. Initialize Setting the initial value of a variable. –128. Increment Increasing the value of a variable. That is. which converts an entire program to an executable file before executing any of the program’s commands. the value is not stored in a variable. Also see Loop and Loop Control Variable.483. Local Variable A variable that can be accessed only from within the subprogram in which it is declared.147. and 2 are examples of integers.147. Literal A value in a program that is stated literally. Also see Long. Integer A data type that represents whole numbers between –2.648 to 2.483. For example. Also see Runtime Error. Also see Global Variable and Variable Scope. Also see Relational Operator. Global Variable A named value that can be accessed from anywhere within a program module. For example.647. An infinite loop ends only when the user terminates the program. Infinite Loop A loop that can’t end because its conditional expression can never evaluate to true. usually by 1. Also see Decrement. Interpreter A programming tool that executes source code one line at a time. unlike a compiler.'The KBasic Book' of 1st quarter 2006 The KBasic object that represents an application’s window. Logical Operator A symbol that compares two expressions and results in a Boolean value (a value of true or false). in the line If X = 5 And Y = 10 Then Z = 1. Page 139 of 143 . The values 240. Function A subprogram that processes data in some way and returns a single value that represents the result of the processing. Logic Error A programming error that results when a program performs a different task than the programmer thought he programmed it to perform. And is the logical operator.

Parameter Often means the same thing as “argument. For example. such as 125 or 34. or the result of an arithmetic operation. any piece of data in a program. Also see Arithmetic Operations. Order of Operations The order in which KBasic resolves arithmetic operations. All program source code must be converted to machine language before the computer can run the program. Numerical Literal A literal value that represents a number. Machine Language The only language a computer truly understands. If the parentheses had been left off. KBasic would first divide 5 by Y and then perform the remaining addition operations. For example. KBasic will perform the two additions before the division. Loop A block of source code that executes repeatedly until a certain condition is met.1 to +2³². Numerical Value A value that represents a number. Mathematical Expressions A set of terms that use arithmetic operators to produce a numerical value. a Command Button’s Move method repositions the button on the form. such as in the expression X + 5 / Y + 2.” although some people differentiate argument and parameter. where an argument is the value Page 140 of 143 . Object Generally. a variable. a set of properties and methods that represent some sort of real-world object or abstract idea.'The KBasic Book' of 1st quarter 2006 Long A data type that represents integer values from –2³² . Also see Integer. in the mathematical expression (X + 5) / (Y + 2). Method A procedure associated with an object or control that represents an ability of the object or control. Specifically in kBasic. This value can be a literal. Also see Literal and String Literal.87. For example. the terms (X + 17) / (Y + 22) make up a mathematical expression. Loop Control Variable A variable that holds the value that determines whether a loop will continue to execute.

Read-Only Property A property whose value cannot be changed from within a program.” Also see Logical Operator. Also see Argument. Also see Double and Floating Point. Also see Function. in the expression X > 10. Relational Operator A symbol that determines the relationship between two expressions. Also see Function. a program can retrieve (read) a property’s value. Runtime Error An system error that occurs while a program is running. Programming Language A set of English-like keywords and symbols that enable a programmer to write a program without using machine language. However. Without some sort of error handling.'The KBasic Book' of 1st quarter 2006 sent to a procedure or function and a parameter is the variable in the function or procedure that receives the argument. Return Value The value that a function sends back to the statement that called the function. also known as a single-precision floating-point value. Program A list of instructions for a computer. For example. such as that provided by the Try/Catch statement. Scope See Variable Scope. An example is a divide-by-zero error or a type-mismatch error. Page 141 of 143 . but does not return a value. Property A value that represents an attribute of an object or control. Single The data type that represents the least accurate floating-point value. runtime errors often result in a program crash. Program Flow The order in which a computer executes program statements. which means “greater than. Procedure A subprogram that performs a task in a program. Source Code The lines of commands that make up a program. the relational operator is >.

KBasic manages the data type of a Variant value for you. Variable A named value in a program. Page 142 of 143 . String Literal One or more text characters enclosed in double quotes. This value can be assigned and reassigned a value of the appropriate data type. An example of an unconditional branch is the GoTo statement. the scope of a global variable is anywhere within the program. that enables the user to interact with the application. whereas the scope of a local variable is limited to the procedure or function that declares the variable. Unconditional Branch When program execution branches to another location regardless of any conditions. the variable str1 must be of the String (or Variant) data type. This data type is very inefficient and should be avoided when possible. In KBasic. in the assignment statement str1 = “I’m a string.'The KBasic Book' of 1st quarter 2006 String A data type that represents one or more text characters. Also see Global Variable and Local Variable. Subprogram A block of source code that performs a specific part of a larger task. usually made up of various types of controls. For example. Also see Function and Procedure. a subprogram can be either a procedure or a function. User Interface The visible representation of an application. Variable Scope The area of a program in which a variable can be accessed. For example. More accurately. Variant A special data type that can represent any type of data.”.

com QUALITY BY BERND NOETSCHER MADE IN GERMANY (EUROPEAN UNION) Trademarks TROLLTECH®.2006 ALL RIGHTS RESERVED. ALL OTHER PRODUCTS NAMED IN THE DOCUMENTATION ARE TRADEMARKS OF THEIR RESPECTIVE OWNERS. www. QT® AND THE TROLLTECH LOGO ARE REGISTERED TRADEMARKS OF TROLLTECH. LINUX® IS A TRADEMARK OF LINUS TORVALDS.'The KBasic Book' of 1st quarter 2006 Impressum (C)OPYRIGHT KBASIC SOFTWARE 2000 . Page 143 of 143 .com EMAIL: info@kbasic.kbasic.

Sign up to vote on this title
UsefulNot useful