Last update July 28, 2009

Coming From /
BASICVariants

(redirection from Notes For Programmers Used To / BASICVariants)


Comparisons for programmers familiar with variants of BASIC

BASICD 
PRINT "Hello World"printf("Hello World\n") 
CONST MYPI# = 3.14const double myPi = 3.14 
CONST T$ = "Some Constant"const char[] T = "Some Constant" 
DIM S$char[] S 
DIM I%int I 
I% = 5I = 5 
S$ = "Some String"S = "Some String" 
I% = 2 : J% = 3I = 2; J = 3; 
' Single line comment// Single line comment 
REM Single line comment// Single line comment 
IF I% = 0 THEN I% = 5if(I == 0) I = 5 
IF I% = 0 THEN S$ = "Yes" ELSE S$ = "No"if(I == 0) S = "Yes"; else S = "No"; 
IF I% = 0 THEN
S$ = "Yes"
D$ = "Ja"
ELSE
S$ = "No"
D$ = "Nein"
END IF
if(I == 0) {
S = "Yes";
D = "Ja";
} else {
S = "No";
D = "Nein";
}
 

Some Major Differences From BASIC

  • Identifier names are case-sensitive. (MyVariable, MYVARIABLE, and myvariable are three different identifiers.)
  • Keywords such as "if" and "for" are also case-sensitive. (The symbol "if" is a keyword, "IF" isn't a keyword.)
  • All variables must be declared before use and assigned a specific type.
  • Printing to the console window: printf is much trickier than PRINT (see HowTo/printf).
  • All statements end with a semi-colon. Carriage returns and line feeds are ignored by the compiler (except within literal strings).

Guide for Finding the Right String Function

Add "import std.string;" to use these functions.

BASICD
InStrfind
InStrRevrfind
Val(i%)atoi(i)
Val(f#)atof(f)
LTrim$stripl
RTrim$stripr
Trim$strip
LCase$tolower
UCase$toupper

Related


FrontPage | News | TestPage | MessageBoard | Search | Contributors | Folders | Index | Help | Preferences | Edit

Edit text of this page (date of last change: July 28, 2009 1:29 (diff))