-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathREADME
401 lines (313 loc) · 15.7 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
-------------------------------------------------------------------------------
nuBASIC - http://www.nubasic.eu
(c) Antonino Calderone <[email protected]> - 2014 - 2022
-------------------------------------------------------------------------------
nuBASIC is an implementation of an interpreter of the BASIC programming
language distributed under MIT License.
It has been designed mainly for educational purposes both for C++ developers
that can deal with a non-trivial example of modern C++ programming and for nuBASIC's
users, that may get hooked on programming.
nuBASIC is suitable for simple games, educational or small business programs.
-------------------------------------------------------------------------------
Features
-------------------------------------------------------------------------------
- Free and Open Source (distributed under MIT License)
- Easy to use and simple enough for 8-year-old-child to understand
- Fully-developed procedural programming language
- Multiplatform. Runs on 32-bit and 64-bit Linux/Windows x86/amd64
- Built-in help
- Documented (English and Italian Guides)
- Syntax Highlighting Editor and Debugger (IDE) for Windows and Linux
- Examples include Tetris, Mine Hunter, Breakout, Calculator, TicTacToe
- Tiny version is suitable for embedded systems
-------------------------------------------------------------------------------
Released packages
-------------------------------------------------------------------------------
Linux Installers:
Debian / Ubuntu 64 bit Installer - nubasic_<ver>.deb
Windows Installers:
* Windows 64 bit Installer (VC++ build) - nubasic-ide-<ver>-setup_x64.zip
* Windows 32 bit Installer (VC++ build) - nubasic-ide-<ver>-setup.zip
Source code:
* Interpreter and IDE source code: nubasic-<ver>.tar.gz
Guides (PDF, ODT):
* nuBASIC Guide (ENG)
* nuBASIC Guide (ITA)
(See also http://www.nubasic.eu/download)
-------------------------------------------------------------------------------
How to download and install?
-------------------------------------------------------------------------------
You can download the latest released version from Source Forge.
The source code is managed using the git version control system provided by Github
nuBASIC source has been written in C++11 and compiles under several operating
systems including Windows and Linux.
-------------------------------------------------------------------------------
How to build nuBASIC on Ubuntu in 10 moves
-------------------------------------------------------------------------------
1) Install any build essential tools (c++ compiler, etc.):
# sudo apt install build-essential
2) Install cmake:
# sudo apt install cmake
3) Install X11 development libraries:
# sudo apt install libx11-dev
4) Install xterm:
# sudo apt install xterm
5) Install gtk+ 2.0:
# sudo apt install gtk2.0
6) Install git:
# sudo apt install git
7) Get nubasic source code from repository:
# git clone https://github.com/eantcal/nubasic.git
8) Enter nubasic directory:
# cd nubasic
9) Create build directory and run cmake:
# mkdir build && cd build && cmake ..
10) Make nubasic and nubasicide:
make && make install
-------------------------------------------------------------------------------
How to build nuBASIC on Visual Studio for Windows
-------------------------------------------------------------------------------
1) Install Visual Studio for Windows including C++ compiler
(any version is suitable since VS2015; see Microsoft website on Visual Studio
for more information about it).
2) Get the source code using git for Windows and cloning nuBASIC project
or in alternative download and extract the nuBASIC source code using the link
https://github.com/eantcal/nubasic/archive/master.zip
3) Build the Scilexer.dll
3.1) Go to ide/scintilla/win32 and open SciLexer.sln Visual Studio solution file
from Visual Studio.
3.2) Select the solution platform Release/x64 from the standard toolbar selectors
(see documentation on Visual Studio for more information)
3.3) Build the solution (Ctrl+Shift+B)
4) Build nuBASIC + nuBasicIDE
4.1) Open the solution file named nubasic.sln from source root directory.
4.2) Select the solution platform Release64/x64 from the standard toolbar selectors.
(see documentation on Visual Studio for more information)
4.3) Build the solution (Ctrl+Shift+B)
nuBasicIDE relies on Scilexer.dll to be executed, so copy
nubasic\ide\scintilla\win32\x64\Release\Scilexer.dll into nubasic\x64\Release64.
You can repeat the same operations for x86 platform and Debug target,
replacing x64 with x86 and Release with Debug in the precious steps.
-------------------------------------------------------------------------------
How to build nuBASIC on Visual Studio for Windows
-------------------------------------------------------------------------------
1) Install Visual Studio for Windows including C++ compiler
(any version is suitable since VS2015; see Microsoft website on Visual Studio
for more information about it).
2) Get the source code using git for Windows and cloning nuBASIC project
or in alternative download and extract the nuBASIC source code using the link
https://github.com/eantcal/nubasic/archive/master.zip
3) Build the Scilexer.dll
3.1) Go to ide/scintilla/win32 and open SciLexer.sln Visual Studio solution file
from Visual Studio.
3.2) Select the solution platform Release/x64 from the standard toolbar selectors
(see documentation on Visual Studio for more information)
3.3) Build the solution (Ctrl+Shift+B)
4) Build nuBASIC + nuBasicIDE
4.1) Open the solution file named nubasic.sln from source root directory.
4.2) Select the solution platform Release64/x64 from the standard toolbar selectors.
(see documentation on Visual Studio for more information)
4.3) Build the solution (Ctrl+Shift+B)
nuBasicIDE relies on Scilexer.dll to be executed, so copy
nubasic\ide\scintilla\win32\x64\Release\Scilexer.dll into nubasic\x64\Release64.
You can repeat the same operations for x86 platform and Debug target,
replacing x64 with x86 and Release with Debug in the precious steps.
-------------------------------------------------------------------------------
Windows Installer packages
-------------------------------------------------------------------------------
You can download setup*.zip packages, that are standalone binary installers,
following the link
https://sourceforge.net/projects/nubasic/files/binary/Windows/
* Installing nuBASIC for Windows
To install nuBASIC, double-click on the setup.exe contained in the zipped
file, and follow the instructions.
Different precompiled nuBASIC versions are provided:
- nubasic-and-editor-<ver>-setup_x64.zip (64 bit)
- nubasic-and-editor-<ver>-setup.zip (32 bit)
Those versions include IDE with an advanced editor based on Scintilla
(http://www.scintilla.org/).
-------------------------------------------------------------------------------
Windows Installation Prerequisites
-------------------------------------------------------------------------------
nuBASIC relies on "Visual C++ Redistributable Packages for Visual Studio" so
you may need to install them manually.
For more information search for "Visual C++ Redistributable Packages"
on Microsoft website.
-------------------------------------------------------------------------------
Linux Installation Prerequisites
-------------------------------------------------------------------------------
To install nuBASIC (full version) the following software components are
required on the installation system:
- X11 - X Windowing System (including xterm, xmessage)
- Gtk+ 2.0
- aplay (which is generally part of most basic Linux distributions).
-------------------------------------------------------------------------------
Introduction to nuBASIC
-------------------------------------------------------------------------------
nuBASIC program is an implementation of an interpreter of the programming
language nuBASIC.
As the name suggests, nuBASIC is a programming language from the BASIC family.
Anyone who has previously worked with other BASIC languages will quickly become
accustomed to nuBASIC.
Large sections of the basic constructs of nuBASIC are compatible with
other BASIC dialects.
The interpreter has been designed mainly for educational purposes both for C++
developers that can deal with a nontrivial example of C++11 programming and
for other users which may get hooked on programming.
nuBASIC is also very simple. It is an excellent tool for teaching programming
to a complete beginner, despite this, it has all the features of a modern
programming language.
nuBASIC allows you to write both classic BASIC programs (which use line
numbers and GoTo or GoSub control structures) and procedure oriented
programs, based on procedural programming paradigm.
The following two implementations of Rosetta Code example (the Rosetta
stone of Fractal geometry is the Mandelbrot set) run correctly on
nuBASIC interpreter:
---- Implementation 1 ----
5 Rem Rosetta.bas
10 For x0 = -2 To 2 Step .01
20 For y0 = -1.5 To 1.5 Step .01
30 x = 0
40 y = 0
50 iteration = 0
60 maxIteration = 223
70 xtemp = x*x-y*y+x0
80 y = 2*x*y+y0
90 x = xtemp
100 iteration = iteration + 1
110 If ((x*x+y*y<=4) And (iteration < maxIteration)) Then GoTo 70
120 If iteration <> maxIteration Then c = iteration Else c = 0
130 d%=150: dx%=300 : dy%=300
140 FillRect x0*d%+dx%,y0*d%+dy%,x0*d%+dx%+2,y0*d%+dy%+2,int(c)*16
150 Next y0
160 Next x0
---- Implementation 2 ----
' Rosetta.bas
For x0 = -2 To 2 Step .01
For y0 = -1.5 To 1.5 Step .01
x = 0
y = 0
iteration = 0
maxIteration = 223
While ((x*x+y*y<=4) And (iteration < maxIteration))
xtemp = x*x-y*y+x0
y = 2*x*y+y0
x = xtemp
iteration = iteration + 1
End While
If iteration <> maxIteration Then
c = iteration
Else
c = 0
End If
d%=150
dx%=300
dy%=300
FillRect x0*d%+dx%,y0*d%+dy%,x0*d%+dx%+2,y0*d%+dy%+2,int(c)*16
Next y0
Next x0
-------------------------------------------------------------------------------
Use of nuBASIC
-------------------------------------------------------------------------------
nuBASIC can be used by any user without any additional programs.
It has the components needed to create programs, including:
- The command line interpreter (CLI), which provides an inline-editor for
creating and testing programs.
- The language interpreter, which is needed to run nuBASIC programs.
- Integrated Development Environment for Windows.
-------------------------------------------------------------------------------
nuBASIC programming language
-------------------------------------------------------------------------------
The nuBASIC programming language can be divided into two components:
- The language of nuBASIC, which defines the elementary linguistic constructs,
for example, for variable declarations and loops.
- The built-in function library which provides standard functions for example,
functions for modifying numbers and strings, and files.
-------------------------------------------------------------------------------
Code samples
-------------------------------------------------------------------------------
Samples distributed with nuBASIC include:
* Breakout, Breakout2, Breakout3 (different implemntation os Breakout game)
* Calc (Interactive Calculator)
* Graph, Graph2
* Line
* Minehunter (clone of a popular game)
* nuTris, nuTris3D (clones of Tetris)
* Ray (a simple raycast 3D engine)
* Rosetta (Rosetta Code - Mandelbrot Set)
* TicTacToe
You can find nuBASIC samples by following this link :
https://sourceforge.net/projects/nubasic/files/examples
-------------------------------------------------------------------------------
Command Line Interface
-------------------------------------------------------------------------------
The user interface of the nuBASIC interpreter is a command-line environment
which, for example, has commands to Run, Load, Save, List the current program,
or quit to the shell, Exit.
These commands cannot be used as program statements.
In addition to the list of commands, the CLI interprets nuBASIC instructions
on-the-fly.
This characteristic is especially useful for debugging purposes.
For example, you may inspect content of a variable by printing out its value,
as follows:
Print variable
-------------------------------------------------------------------------------
Help
-------------------------------------------------------------------------------
The CLI also contains an online help system to provide descriptions and syntax
for each command via the Help and Apropos commands.
Giving no argument to Help, it lists all operators, keywords,
built-in functions, available in nuBASIC divided into four categories:
commands, instructions, functions and operators.
Giving as argument a keyword, Help displays the help text for that keyword.
For example, the command help open prints out a text describing the Print
statement, as follows:
help print
Print [list of expressions][;]
Prints list of expressions to standard output
If list of expressions is omitted, a blank line is displayed
If list of expressions is included, the values of the expressions are
displayed.
Expressions in the list may be numeric and/or string expressions,
separated by commas or semicolons.
A question mark (?) may be used in place of the word Print when it is the
first statement in the immediate-mode editing.
Literal strings in the list must be enclosed in double quotation marks.
Apropos is command to search help content. It is used to search all help
data for the string specified. This is often useful if one knows the
action that is desired, but does not remember the exact command.
The following example demonstrates the output of the Apropos command:
apropos file
exec Loads and runs a program file
load Loads a program file in memory
save Saves current program to file
close Terminates input/output to a file.
flush Shall cause any unwritten data for that file number to be ...
fopen Establishes input/output (I/O) to a file.
input# Inputs data from file that will be placed into a list of ...
open Establishes input/output (I/O) to a file.
plotimage Loads and draws a bitmap from file on the screen starting ...
print# Prints list of expressions to file (0-standard output)
read Reads data from file that will be placed into a variable.
seek Moves the file pointer to a specified location
write# Prints list of expressions to file (0-standard output)
eof Checks the end-of-file indicator.
erase Deletes file from disk
ferror Tests for an error on a file.
fsize Returns the current size in bytes of the file
ftell Returns the current value of the position indicator of the file
playsound Plays a sound (wav) specified by the given file name
-------------------------------------------------------------------------------
THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
-------------------------------------------------------------------------------
Please send your questions or comments to: [email protected]