Compatibility with other versions of BASIC

From NSB App Studio
Revision as of 18:23, 9 November 2012 by Ghenne (talk | contribs)
Jump to navigation Jump to search

NSB/App Studio is a fully featured, easy to use implementation of BASIC. It is a modern version, allowing structured coding, visual controls, integrated SQL support and much more.

It is designed to have a gentle learning curve. Start with simple programs and build up to full applications: there is a lot of power under the surface. A full IDE allows the visual layout and editing of programs.

NSB/App Studio implements a version of BASIC based on VBScript, a widely used subset of Microsoft's Visual BASIC. The basic set of commands, operators and functions is identical. Differences arise from operating system dependant features. NSB/App Studio makes use of WebKit and JavaScript technology to be as cross platform compatible as possible.

NSB/App Studio has a number of extensions that give it power beyond what other implementions make available. This document necessarily focuses on incompatibilites and missing features - but there are a lot of nice additions to make up for them.

To see the list of all supported statements, functions and controls, see the Specifications.

As time goes on, we plan to improve compatibility. If there is a feature missing which you need, please let us know at support@nsbasic.com.

VBScript

VBScript is a subset of Microsoft's Visual BASIC, designed for use as a browser and desktop scripting language. NSB/App Studio is directly modeled after VBScript's specifications and features the identical statements, functions and data types. Most VBScript code will run without change in NSB/App Studio, so long as it does not use operating system functions. Differences:

  • Array elements are identified by square brackets "[]", while function arguments are identified by parentheses "()". If you use parentheses to access an array element, NSB/App Studio will do the correct thing unless it is ambiguous. It's safest to always use the proper usage.
  • Bitwise operations on logical functions: Functions such as AND, EQV, IMP, NOT, OR and XOR only work as logical functions. VBScript allows you to do (2 AND 7), whereas NSB/App Studio uses boolean arguments. There are bitwise operators you can use instead.
  • Date Arithmetic: VBScript allows you to add to a date using normal addition (X = Date + 7). In NSB/App Studio, use the DateAdd function.
  • ON ERROR is replaced by TRY...CATCH. The VBScript implementation of ON ERROR is pretty lame, so this is a real improvement.
  • CreateObject, GetRef, SetLocale and GetLocale are not supported.
  • Class...End Class is not supported. Objects, which are similar, can be created by a simple assignment statement.
  • Option Explicit is on by default.
  • Function and Subroutine arguments are always passed ByVal for simple variables and ByRef for objects.
  • Execute and Eval use JavaScript, not BASIC in their argument.
  • Colors are represented differently. If you use the built in color constants (vbWhite, vbRed, etc.) or the RGB functions to create colors, you won't notice any difference. Colors are represented by a hex string in the form "#XXYYZZ", where XX is red, YY is green and ZZ is blue.
  • The integer division operator (\) is not implemented.
  • The MsgBox function is different: it has less arguments, the title cannot be changed and the return value is slightly different. See the Language Reference for full info.
  • Localization: Whereas VBScript has localization built in for other data formats and commas vs. periods in numbers, NSB/App Studio does not. You will need to handle this in your code.

Microsoft Visual BASIC

Differences between NSB/App Studio and Visual Basic are the same as for VBScript, plus, of course, the differences between VBScript and VB. The differences between VBScript and Visual Basic are well documented elsewhere.

NS Basic/CE and NS Basic/Desktop

Both NS Basic/CE and NS Basic/Desktop use the VBScript runtime engine, so compatibility will be the same as for VBScript. NS Basic/CE and NS Basic/Desktop have extension to take advantage of features in Windows: most of these either do not work in a cross platform environment or are not needed. The following statements are not supported:

Bye, Break, Chain, ShowOKButton, NSExecute, AddObject, PlaySound, SysInfo(certain values), Declare, UpdateScreen, SpecialFolder, ShowFullScreen, SetParent, SetMenu, SendMessage, SendMessageString, SendKey, RunAppAtEvent, RunAppAtTime, KillFocus, KeyboardStatus, GetSerialNumber, GetResource, getLocale, GetCommandLine, CreateShortcut, doEvents

In most cases, the compiler will simply ignore these statements, with an optional warning.

Widgets (controls which are visual) cannot be created at runtime. They are created by the IDE as part of the development process. There is a new set of widgets, based on WebKit, which replace the old CommandButton, TextBox, PictureBox, etc. While they have different properties, they work more or less the same way as the old ones: they look and feel like the widgets you would have in a web browser.

If you use SQLite, good news: NSB/App Studio has full support for SQLite built in. The same SQL commands can still be used, though the actual calls are different. See the Tech Note on SQLite for more info.

File I/O (to flat files) does not exist. The security framework that NSB/App Studio runs within does not allow us to create and open anything but SQLite files (though there may be some clever workarounds).

The Output object is largely replaced by the Document object.

Third party controls, such as for serial devices, do not work. There is no support for dll files.

NS Basic/Palm

NS Basic/Palm is very closely tied to the capabilities of Palm OS. Code that does not depend on screen objects or file I/O will transfer with only minor changes. Screen and file IO related code will need to be reworked, but the same overall concepts and objects will still be there.