JavaScript for BASIC Programmers: Difference between revisions

From NSB App Studio
Jump to navigation Jump to search
(Created page with "AppStudio's BASIC is modelled on Microsoft's Visual BASIC. It runs on other operating system by translating the BASIC to JavaScript, a language which is supported on all platf...")
 
No edit summary
Line 4: Line 4:


When we designed our Translator, we were pleased to discover that almost everything in BASIC had a direct equivalent in JavaScript. Each BASIC statement could be turned into a JavaScript statement which did the same thing. (The reverse is not true: there are many features in JavaScript which do not have an equivalent in BASIC.)
When we designed our Translator, we were pleased to discover that almost everything in BASIC had a direct equivalent in JavaScript. Each BASIC statement could be turned into a JavaScript statement which did the same thing. (The reverse is not true: there are many features in JavaScript which do not have an equivalent in BASIC.)
=== Variable Types ===
JavaScript variables are not explicitly typed: they get their types from whatever is assigned to them. It's very similar to BASIC's Variant type.
Variables are declared with the VAR statement:
{| class="wikitable"
|-
! BASIC !! JavaScript
|-
| Dim a || var a;<br>var b,c;<br>var d = 100;
|}
=== Assignment ===
=== IF statements ===
=== Operators ===
=== For loops ===
=== Statement Endings ===

Revision as of 12:58, 26 July 2017

AppStudio's BASIC is modelled on Microsoft's Visual BASIC. It runs on other operating system by translating the BASIC to JavaScript, a language which is supported on all platforms.

JavaScript is a powerful and flexible programming language. It's the standard programming language of the web. It's also the subject of Atwood's Law: "Any application that can be written in JavaScript, will eventually be written in JavaScript."

When we designed our Translator, we were pleased to discover that almost everything in BASIC had a direct equivalent in JavaScript. Each BASIC statement could be turned into a JavaScript statement which did the same thing. (The reverse is not true: there are many features in JavaScript which do not have an equivalent in BASIC.)

Variable Types

JavaScript variables are not explicitly typed: they get their types from whatever is assigned to them. It's very similar to BASIC's Variant type.

Variables are declared with the VAR statement:

BASIC JavaScript
Dim a var a;
var b,c;
var d = 100;

Assignment

IF statements

Operators

For loops

Statement Endings