Skip to content

Commit abc2049

Browse files
committed
apt files are deleted
EngineApi renamed to ScriptBasic AuxTest now runs documentation
1 parent f1fbb69 commit abc2049

37 files changed

Lines changed: 156 additions & 1986 deletions

site/advanced/extend.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
some methods that will be available to the BASIC program without `use` or `method` declarations.
77

88
To register a method into the BASIC runtime and thus make it available for the BASIC program to call,
9-
ScriptBasic for Java provides a method `registerExtension(Class<?> klass)` in the `EngineApi` interface. Using
9+
ScriptBasic for Java provides a method `registerExtension(Class<?> klass)` in the `ScriptBasic` interface. Using
1010
this method the embedding application can register static methods from a class. The embedding application has to
1111
issue a single call and it will register all the methods that are appropriately annotated.
1212

@@ -34,7 +34,7 @@
3434
The declared function can be called after that from BASIC the following way:
3535

3636
```
37-
EngineApi engine = EngineApi.getEngine();
37+
ScriptBasic engine = ScriptBasic.getEngine();
3838
engine.registerExtension(TestExtensionClass.class);
3939
engine.load("Sub aPie\nreturn javaFunction()\nEndSub\n");
4040
engine.execute();

site/advanced/nativeapi.md

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -81,18 +81,18 @@ arguments and getting return values.
8181
The simplest ever use of the ScriptBasic for Java native API is to execute a script that is available in a string:
8282

8383
```
84-
EngineApi engine = EngineApi.getEngine();
84+
ScriptBasic engine = ScriptBasic.getEngine();
8585
engine.eval("print \"hello world\"");
8686
```
8787

8888

8989
This code creates a new `Engine` object, then calls the method `eval` with the string that contains the
90-
program code. Note that `EngineApi` is an interface and `Engine` is the implementation.
90+
program code. Note that `ScriptBasic` is an interface and `Engine` is the implementation.
9191
If you want to have the output of the program in a `String` you can create a `StringWriter`
9292
and redirect the standard output of the program to there:
9393

9494
```
95-
EngineApi engine = EngineApi.getEngine();
95+
ScriptBasic engine = ScriptBasic.getEngine();
9696
StringWriter sw = new StringWriter(10);
9797
engine.setOutput(sw);
9898
engine.eval("print \"hello world\"");
@@ -105,7 +105,7 @@ arguments and getting return values.
105105
program from a `java.io.Reader`:
106106

107107
```
108-
EngineApi engine = EngineApi.getEngine();
108+
ScriptBasic engine = ScriptBasic.getEngine();
109109
StringWriter sw = new StringWriter(10);
110110
engine.setOutput(sw);
111111
StringReader sr = new StringReader("print \"hello world\"");
@@ -117,7 +117,7 @@ arguments and getting return values.
117117
or from a `java.io.File`:
118118

119119
```
120-
EngineApi engine = EngineApi.getEngine();
120+
ScriptBasic engine = ScriptBasic.getEngine();
121121
StringWriter sw = new StringWriter(10);
122122
engine.setOutput(sw);
123123
File file = new File(getClass().getResource("hello.bas").getFile());
@@ -155,7 +155,7 @@ arguments and getting return values.
155155
To specify the directories where the files are use the following piece of code:
156156

157157
```
158-
EngineApi engine = EngineApi.getEngine();
158+
ScriptBasic engine = ScriptBasic.getEngine();
159159
StringWriter sw = new StringWriter(10);
160160
engine.setOutput(sw);
161161
String path = new File(getClass().getResource("hello.bas").getFile())
@@ -169,15 +169,15 @@ arguments and getting return values.
169169
as many `String` parameters as you like:
170170

171171
```
172-
EngineApi engine = EngineApi.getEngine();
172+
ScriptBasic engine = ScriptBasic.getEngine();
173173
engine.eval("include.bas", ".", "..", "/usr/include/scriptbasic");
174174
```
175175

176176
The second possibility is to provide a `SourcePath` object. The following sample
177177
shows you a very simple use of this approach:
178178

179179
```
180-
EngineApi engine = EngineApi.getEngine();
180+
ScriptBasic engine = ScriptBasic.getEngine();
181181
StringWriter sw = new StringWriter(10);
182182
engine.setOutput(sw);
183183
String path = new File(getClass().getResource("hello.bas").getFile())
@@ -201,7 +201,7 @@ arguments and getting return values.
201201
this is the following:
202202

203203
```
204-
EngineApi engine = EngineApi.getEngine();
204+
ScriptBasic engine = ScriptBasic.getEngine();
205205
StringWriter sw = new StringWriter(10);
206206
engine.setOutput(sw);
207207
SourceProvider provider = new SourceProvider() {
@@ -252,7 +252,7 @@ arguments and getting return values.
252252
for the script exactly as it was set by some BASIC code. To do so the following sample can be used:
253253

254254
```
255-
EngineApi engine = EngineApi.getEngine();
255+
ScriptBasic engine = ScriptBasic.getEngine();
256256
StringWriter sw = new StringWriter(10);
257257
engine.setOutput(sw);
258258
engine.setVariable("a", 13);
@@ -272,7 +272,7 @@ arguments and getting return values.
272272
After the code was executed you are able to query the values of the global variables:
273273

274274
```
275-
EngineApi engine = EngineApi.getEngine();
275+
ScriptBasic engine = ScriptBasic.getEngine();
276276
engine.eval("a = \"hello world\"");
277277
String a = (String) engine.getVariable("a");
278278
assertEquals("hello world", a);
@@ -294,7 +294,7 @@ arguments and getting return values.
294294
the execution of the code programmatically:
295295

296296
```
297-
EngineApi engine = EngineApi.getEngine();
297+
ScriptBasic engine = ScriptBasic.getEngine();
298298
engine.eval("a = \"hello world\"\nb=13");
299299
String varnames = "";
300300
for (String varname : engine.getVariablesIterator()) {
@@ -327,7 +327,7 @@ arguments and getting return values.
327327
To call a subroutine you have to know the name of the subroutine and you should call the method `call()`:
328328

329329
```
330-
EngineApi engine = EngineApi.getEngine();
330+
ScriptBasic engine = ScriptBasic.getEngine();
331331
engine.eval("sub applePie\nglobal a\na = \"hello world\"\nEndSub");
332332
String a = (String) engine.getVariable("a");
333333
assertNull(a);
@@ -340,7 +340,7 @@ arguments and getting return values.
340340
The next example shows how to pass arguments and how to get the return value:
341341

342342
```
343-
EngineApi engine = EngineApi.getEngine();
343+
ScriptBasic engine = ScriptBasic.getEngine();
344344
engine.eval("sub applePie(b)\nglobal a\na = b\nreturn 6\nEndSub");
345345
String a = (String) engine.getVariable("a");
346346
assertNull(a);
@@ -357,7 +357,7 @@ arguments and getting return values.
357357
To get all the subroutines the BASIC program defines you should call the method `getSubroutineNames()`:
358358

359359
```
360-
EngineApi engine = EngineApi.getEngine();
360+
ScriptBasic engine = ScriptBasic.getEngine();
361361
engine.eval("sub applePie(b)\nEndSub\nsub anotherSubroutine\nEndSub\n");
362362
int i = 0;
363363
for (@SuppressWarnings("unused")
@@ -378,7 +378,7 @@ arguments and getting return values.
378378
instance you can call `call(Object ... args)`, `getName()` and `getNumberOfArguments()` methods.
379379

380380
```
381-
EngineApi engine = EngineApi.getEngine();
381+
ScriptBasic engine = ScriptBasic.getEngine();
382382
engine.eval("sub applePie\nglobal a\na = \"hello world\"\nEndSub");
383383
String a = (String) engine.getVariable("a");
384384
assertNull(a);
@@ -392,7 +392,7 @@ arguments and getting return values.
392392
sample how to call a subroutine in OO way that returns some value:
393393

394394
```
395-
EngineApi engine = EngineApi.getEngine();
395+
ScriptBasic engine = ScriptBasic.getEngine();
396396
engine.eval("sub applePie(b)\nglobal a\na = b\nreturn 6\nEndSub");
397397
String a = (String) engine.getVariable("a");
398398
assertNull(a);

site/advanced/requiredVersion.md

Lines changed: 43 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,51 @@
1-
```
2-
jScriptBasic Project Documentation
3-
```
4-
Peter Verhas
5-
```
6-
2012-12-05
7-
```
8-
9-
ScriptBasic for Java Interface Versions
1+
# ScriptBasic for Java Interface Versions
102

11-
ScriptBasic provides an interface for functions implemented in Java and callable from BASIC. The functions
12-
implemented in Java need not implement any Java interface. The "interface" ScriptBasic provides is not a Java
13-
interface. This term refers to the way ScriptBasic calls these methods.
14-
15-
As ScriptBasic develops the way ScriptBasic handles these extension functions also develop and some new
16-
features become available. If an extension relies such an advanced feature it will not work with earlier
17-
version of ScriptBasic that implements an earlier version of the interface. Therefore ScriptBasic introduces
18-
a simple `long` number that specifies the version of the interface.
19-
20-
This document describes the differences between the different interface versions.
3+
ScriptBasic provides an interface for functions implemented in Java and callable
4+
from BASIC. The functions
5+
implemented in Java need not implement any Java interface. In this terminology the
6+
"interface" ScriptBasic provides is not a Java
7+
interface. This term refers to the way ScriptBasic calls these methods.
8+
9+
As ScriptBasic develops the way ScriptBasic handles these extension functions also develop and some new
10+
features become available. If an extension relies on such an advanced feature
11+
it will not work with earlier
12+
versions of ScriptBasic that implements an earlier version of the interface.
13+
Therefore ScriptBasic introduces
14+
a simple `long` number that specifies the version of the interface.
15+
16+
This document describes the differences between the different interface versions.
2117

2218
* 1L
2319

2420
This is the initial version.
2521

2622
* 2L
2723

28-
ScriptBasic 1.0.4 introduced the possibility for an extension to accept BASIC array as argument and also to
29-
return an array as value. If you need that feature you have to specify `requiredVersion=2L` in the
30-
annotation of the static method implementing the extension function.
24+
ScriptBasic 1.0.4 introduced the possibility for an extension to accept BASIC
25+
array as argument and also to
26+
return an array as value. If you need that feature you have to
27+
specify `requiredVersion=2L` in the
28+
annotation of the static method implementing the extension function.
29+
30+
For example the method `length()` implemented in the class `UtilityFunctions` as
31+
32+
```
33+
@BasicFunction(classification = Utility.class, requiredVersion = 2L)
34+
public static Long length(Object arg) {
35+
if (arg == null) {
36+
return null;
37+
} else if (arg instanceof BasicArrayValue) {
38+
BasicArrayValue array = (BasicArrayValue) arg;
39+
return array.getLength();
40+
} else if (arg instanceof String) {
41+
String string = (String) arg;
42+
return (long) string.length();
43+
} else if (arg.getClass().isArray()) {
44+
return (long) Array.getLength(arg);
45+
}
46+
return null;
47+
}
48+
```
49+
50+
This is because this basic function would not work with versions of ScriptBasic prior to
51+
1.0.4

site/design.md

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
# Design Considerations
2-
3-
This document summarizes some of the design considerations that we followed developing ScriptBasic for Java.
42

53
The main design goals of ScriptBasic for Java were to create an interpreted language that is
64

@@ -16,11 +14,9 @@
1614

1715
* 4E: easy to embed, easy to extend
1816

19-
* compile
20-
2117
* multi-thread
2218

23-
ScriptBasic for Java was developed with similar design goals in mind. We wanted a BASIC interpreter in Java so that
24-
Java application can access a BASIC interpreter as a scripting extension to their application to be used by the
25-
business experts.
19+
We wanted a BASIC interpreter in Java so that
20+
Java application can access a BASIC interpreter as a scripting extension
21+
to their application to be used by the business experts.
2622

site/index.md

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,37 @@
11
# ScriptBasic for Java Documentation
22

3+
## introduction
4+
5+
These documents will help you to get acquainted with the application and how to use it.
6+
7+
* [Introduction to the application](intro.md)
8+
39
* [The BASIC language implemented](basic.md) a simple and short language definition and not a BASIC
410
programming tutorial
511

6-
* [How to install SB4J](install.md)... just put it on the classpath
12+
* [How to install SB4J](install.md) ... just put it on the classpath
13+
14+
* [How to configure](configure.md) ... no need to
15+
16+
* [Design considerations](design.md) ... there were none (just kidding)
17+
18+
* [Name of the game](name.md)
19+
20+
* [Releases](releases.md)
21+
22+
## advanced
23+
24+
These documents will give you more detail into the topics, like embedding the interpreter
25+
into a host application, writing hook classes that use the service programming interface
26+
of the interpreter and so on.
27+
28+
* [Index of the advanced topics](advanced/index.md)
29+
30+
* [How to extend ScriptBasic for Java with external Java Methods](advanced/extend.md)
31+
32+
* [How to embed the interpreter as s standard scripting engine](advanced/jsr223tutorial.md)
33+
This should quite standard as defined by the standard JSR223, but here it is. The extra
34+
information, which is a bit more than a standard JSR223 tutorial is how the interpreter
35+
binds the global variables to the JSR defined contexts.
36+
37+
* [How to embed the interpreter using the native ScriptBasic API](advanced/nativeapi.md)

site/install.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ use the ScriptBasic for Java native interface.
6363
Place the JAR file on the classpath and use the native interface
6464

6565
```
66-
EngineApi engine = EngineApi.getEngine();
66+
ScriptBasic engine = ScriptBasic.getEngine();
6767
engine.eval("print \"hello world\"");
6868
```
6969

site/intro.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
For the same reason the language implemented is very simple. It implements only a very limited set
2020
of commands and operators. Each command is implemented that is needed to create embedded scripts but nothing more.
21-
You can assign values to variables, loop, execute conditional code (IF statement), print to the standard output
21+
You can assign values to variables, loop, execute conditional code (`IF` statement), print to the standard output
2222
and call subroutines. You can handle arrays. Anything else you need in a BASIC script? To communicate with the embedding application
2323
more than just printing to the output the program can call Java static methods or instance methods in case an
2424
object is stored in a BASIC variable. To do that the usual `object.method(params)` format can be used, or just

site/name.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ For example the default file name for the configuration file that ScriptBasic us
88
ScriptBasic for Java does not need configuration generally though.)
99

1010
"ScriptBasic" without the starting `j` or without saying that this is for java denotes the
11-
classic version of ScriptBasic. The classic version was developed by the same authors from 1997 till 2006 and was and is still used
11+
classic version of ScriptBasic. The classic version was developed from 1997 till 2006 and was and is still used
1212
by many application as an embedded language. To name two: Sarian routers can be programmed using ScriptBasic and the company
1313
EZ-R Stats uses ScriptBasic to develop audit routines into their application.
1414

@@ -24,4 +24,6 @@ language and interpreter in an article, blog or other human readable text.
2424

2525
Use jScriptBasic only if the repetitive use of the long name would distract the reader.
2626

27-
Use `sb4j` when the notation is used in software.
27+
Use `sb4j` when the notation is used in software.
28+
29+
Anyway: you are free to use any name so long as long others understand what you mean.

site/releases.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,11 @@ of a release is `M.m.b` where `M` is the major version, `m` is the minor version
1616
* `b` is increased if there is some bugfix but the features of the language and the interpreter did not change.
1717

1818

19-
## 1.0.0-SNAPSHOT
20-
The current development version. This is not a release version.
19+
## 1.0.0
20+
The first release in 2012
21+
22+
## 1.0.4
23+
2124

2225
## 1.0.5-SNAPSHOT
2326
Version that supports Java 9.

src/main/java/com/scriptbasic/Engine.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package com.scriptbasic;
22

3-
import com.scriptbasic.api.EngineApi;
3+
import com.scriptbasic.api.ScriptBasic;
44
import com.scriptbasic.api.ScriptBasicException;
55
import com.scriptbasic.api.Subroutine;
66
import com.scriptbasic.errors.BasicInterpreterInternalError;
@@ -16,7 +16,7 @@
1616
import java.util.HashMap;
1717
import java.util.Map;
1818

19-
public class Engine implements EngineApi {
19+
public class Engine implements ScriptBasic {
2020

2121
private final Map<String, Subroutine> subroutines = new HashMap<>();
2222
private Reader input;

0 commit comments

Comments
 (0)