10000 Generate sbref.txt from markdown inputs · chrisws/smallbasic.github.io@27c0629 · GitHub
[go: up one dir, main page]

Skip to content

Commit 27c0629

Browse files
committed
Generate sbref.txt from markdown 8000 inputs
1 parent a73e030 commit 27c0629

File tree

9 files changed

+11244
-220
lines changed

9 files changed

+11244
-220
lines changed

_build/Makefile

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ pages = $(patsubst pages/%.markdown, $(out)/pages3/%.html, $(wildcard pages/*.ma
2424
posts = $(patsubst posts/%.markdown, $(out)/posts3/%.html, $(wildcard posts/*.markdown))
2525
scripts = $(patsubst scripts/%.html, $(out)/scripts2/%.html, $(wildcard scripts/*.html))
2626
reference = $(patsubst reference/%.markdown, $(out)/reference3/%.html, $(wildcard reference/*.markdown))
27+
reference_txt = $(patsubst reference/%.markdown, $(out)/reference_txt/%.txt, $(wildcard reference/*.markdown))
2728

2829
# rules
2930
.data: reference.json page.bas site.bas mkdata.bas includes/header.html
@@ -82,11 +83,16 @@ $(out)/scripts2/%.html: $(out)/scripts/%.html
8283
$(mkdir)
8384
$(sbasic) $(out)/sitepage.bas $< > $@
8485

85-
all: $(reference) $(pages) $(posts) $(scripts)
86+
$(out)/reference_txt/%.txt: reference/%.markdown
87+
$(mkdir)
88+
$(pandoc) --from markdown-tex_math_dollars --to plain -o $@ $<
89+
90+
all: $(reference) $(out)/reference.txt $(pages) $(posts) $(scripts)
8691
@mkdir -p ../reference/ide
8792
@mkdir -p ../pages
8893
@mkdir -p ../posts
8994
@$(sbasic) deploy.bas
95+
@cp $(out)/reference.txt ../reference
9096
@cp $(out)/pages3/*.html ../pages
9197
@cp $(out)/posts3/*.html ../posts
9298
@cp $(out)/scripts2/*.html ../pages
@@ -97,6 +103,9 @@ all: $(reference) $(pages) $(posts) $(scripts)
97103
@cp layouts/index.html ../reference
98104
@cp layouts/index.html ../reference/ide
99105

106+
$(out)/reference.txt : $(reference_txt) mkref.bas
107+
@$(sbasic) mkref.bas > $(out)/reference.txt
108+
100109
clean:
101110
rm -rf $(out) *.sbu
102111

_build/mkref.bas

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
rem
2+
rem generate single text file reference
3+
rem
4+
5+
tload "reference.json", s, 1
6+
ref = array(s)
7+
counter = 0
8+
9+
out "SmallBASIC Language reference"
10+
out ""
11+
out " _____ _ _ ____ _____ _____ _____"
12+
out " / ____| | | | _ \ /\ / ____|_ _/ ____|"
13+
out " | (___ _ __ ___ __ _| | | |_) | / \ | (___ | || |"
14+
out " \___ \| '_ ` _ \ / _` | | | _ < / /\ \ \___ \ | || |"
15+
out " ____) | | | | | | (_| | | | |_) / ____ \ ____) |_| || |____"
16+
out " |_____/|_| |_| |_|\__,_|_|_|____/_/ \_\_____/|_____\_____|"
17+
out ""
18+
out ""
19+
20+
mk_ref("Console")
21+
mk_ref("Data")
22+
mk_ref("Date")
23+
mk_ref("File")
24+
mk_ref("Graphics")
25+
mk_ref("Language")
26+
mk_ref("Math")
27+
mk_ref("String")
28+
mk_ref("System")
29+
30+
func cmpfunc(a, b)
31+
return iff(a.keyword == b.keyword, 0, iff(a.keyword < b.keyword, -1, 1))
32+
end
33+
34+
sub out(s)
35+
print s
36+
end
37+
38+
sub box(s)
39+
local l = len(s)
40+
local span = "+========================================================================================+"
41+
if (l % 2 == 1) then
42+
s += " "
43+
endif
44+
local g = (len(span) - l) / 2
45+
out span
46+
out "|" + space(g) + s + space(g - 2) + "|"
47+
out span
48+
end
49+
50+
sub mk_ref(package)
51+
local i, fileName, buffer
52+
local num_items = len(ref[package]) - 1
53+
54+
sort ref[package] use cmpfunc(x,y)
55+
for i = 0 to num_items
56+
item = ref[package][i]
57+
counter++
58+
box counter + ". (" + package + ") " + item.keyword
59+
60+
fileName = "_out/reference_txt/" + item.nodeID + "-" + lower(package) + "-" + lower(translate(item.keyword, " ", "")) + ".txt"
61+
try
62+
tload fileName, buffer, 1
63+
out buffer
64+
catch e
65+
print fileName
66+
throw e
67+
end try
68+
next i
69+
end

_build/pages/android_changelog.markdown

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,17 @@ Android Changelog
55
[Home](/) > [Articles](/pages/articles.html)
66
:::
77

8+
**12.22 (? June April 2021)**
9+
10+
- Fixed 'Socket Client doesn't receive byte with value 13' #112
11+
- Fixed RGB handling with IMAGEs
12+
- Fixed TSAVE of arrays includes extra null character. #119
13+
- Fixed array access regression
14+
- Implemented image.draw(), fix image.save in andoid #115
15+
- Removed "requestLegacyExternalStorage" for AppStore compliance
16+
- Removed path navigation to show unified view of available folders
17+
- Removed samsung keypad warning
18+
819
**12.21 (14 April 2021)**
920

1021
- Added range checking for the web services port

_build/pages/download.markdown

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,5 @@
3636

3737
## Language Reference
3838

39-
[Offline help text](http://sourceforge.net/projects/smallbasic/files/Language%20Reference/sbref_v2.txt/download){target="_blank"}
39+
[Offline help text](../reference/sbref.txt){target="_blank"}
4040

_build/reference/1432-data-array.markdown

Lines changed: 39 additions & 107 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,47 @@
22

33
> ARRAY [var | expr]
44
5-
Creates a ARRAY or MAP variable from the given string or expression
5+
Creates a ARRAY or MAP variable from the given string or expression.
66

7+
The ARRAY command supports JSON (Javascript object notation) syntax. The MAP provides value-key pair access along with array or dotted notation.
8+
The MAP can be converted back into a JSON string using the STR command. You can test whether a variable is a MAP using the ISMAP command.
9+
10+
The following example shows a possible JSON representation describing a person:
711

812
~~~
13+
{
14+
"firstName": "John",
15+
"lastName": "Smith",
16+
"isAlive": true,
17+
"age": 25,
18+
"address": {
19+
"streetAddress": "21 2nd Street",
20+
"city": "New York",
21+
"state": "NY",
22+
"postalCode": "10021-3100"
23+
},
24+
"phoneNumbers": [
25+
{
26+
"type": "home",
27+
"number": "212 555-1234"
28+
},
29+
{
30+
"type": "office",
31+
"number": "646 555-4567"
32+
},
33+
{
34+
"type": "mobile",
35+
"number": "123 456-7890"
36+
}
37+
],
38+
"children": [],
39+
"spouse": null
40+
}
41+
~~~
42+
43+
Example 1:
944

10-
' See also Article "New features" -> "User defined structures".
45+
~~~
1146
Def uline(text) = Cat(2) + text + Cat(-2) ' Underline text
1247
Cls
1348
? uline("1-Dimension Map Array:")
@@ -78,109 +113,11 @@ b.title = "Top-Left"
78113
?
79114
?:?:? " Press any key..."
80115
Pause
81-
82-
~~~
83-
84-
Thank you.
85-
Ah, new stuff!
86-
I see the string wrapped in curlie brackets, is that required? not [] brackets? or () brackets?
87-
I see the "properties"(?) separated by colon with it's value, is that also required? (well , separates pairs and ; separates rows)
88-
Append: ? "properties", better name is "field"
89-
Associative array is different from common array because of the fields?
90-
ARRAY syntax is like this (I don't see other option):
91-
ARRAY("{varName1:value1, varName2:value2, ...}")
92-
You can use expression or variable instead of string:
93-
Def s = "{varName1:value1, varName2:value2}"
94-
s = "{varName1:value1, varName2:value2}"
95-
...
96-
a = ARRAY(s)
97-
Associative array is not different then common array.
98-
ARRAY() simply creates an array which some programmers like its syntax.
99-
common array is more powerful because instead of fixed names it uses indexes, which you can use inside loops.
100-
To sum up: you don't have to use a.x; a.y - you can simply use a(X), a(Y).
101-
the term "Field" is mainly used for databases;
102-
the term "Property" is mainly used in object oriented programming syntax.
103-
But in the real life, both "field" and "property" are usually element of an array.
104-
To sum up: you don't need to use any term - you can simply say "variable".
105-
106-
107-
JSON is an open-standard format that uses human-readable text to transmit data objects consisting of attribute–value pairs. JSON is a language-independent data format.
108-
Here I quote Chris from Home -- Forums -- Project help -- Tile Map Editor:
109-
>
110-
...
111-
If you click File / Export and save the output in JSON format, you can then use the output in a SmallBASIC program like this:
112-
113116
~~~
114117

115-
tload "map.json" , buffer, 1
116-
tiles= array(buffer)
117-
? tiles.layers(0).data(0)
118+
Example 2:
118119

119120
~~~
120-
121-
...
122-
123-
These are good news, because it actually allows us to save and load arrays as regular text files in JSON format (which shares its vision with XML format).
124-
That's useful but can it be applied to other ARRAY types? For example I can make TLOAD and TSAVE work for a one dimensional array but I cannot see how to save or load an ordinary (non MAP) ARRAY with more than one dimension. Have you achieved this? Is it possible? Just wondering. Thanks.
125-
I've copy this code from JSON Wikipedia, it seems like JSON supports more then one
126-
dimension according to the example...
127-
The following example shows a possible JSON representation describing a person:
128-
129-
~~~
130-
131-
{
132-
"firstName": "John",
133-
"lastName": "Smith",
134-
"isAlive": true,
135-
"age": 25,
136-
"address": {
137-
"streetAddress": "21 2nd Street",
138-
"city": "New York",
139-
"state": "NY",
140-
"postalCode": "10021-3100"
141-
},
142-
"phoneNumbers": [
143-
{
144-
"type": "home",
145-
"number": "212 555-1234"
146-
},
147-
{
148-
"type": "office",
149-
"number": "646 555-4567"
150-
},
151-
{
152-
"type": "mobile",
153-
"number": "123 456-7890"
154-
}
155-
],
156-
"children": [],
157-
"spouse": null
158-
}
159-
160-
~~~
161-
162-
This what Chris wrote at Home -- Forums -- Announcements (10/02/2014):
163-
>
164-
...
165-
SmallBASIC implementations: Any
166-
SmallBASIC version 0.11.16 for Ubuntu is now available.
167-
...
168-
Variables:
169-
The MAP variable type combines the features of previously separate "User Defined Structures" and "Associated Array" variables. The MAP provides value-key pair access along with array or dotted notation. The MAP can be initialized from a String variable using the ARRAY command. The ARRAY command supports JSON (Javascript object notation) syntax.
170-
The MAP can be converted back into a JSON string using the STR command. You can test whether a variable is a MAP using the ISMAP command.
171-
The ARRAY command can be used to process web services results. For example: https:raw.githubusercontent.com*smallbasic*SmallBASIC*master*samples*distro-examples*devio*google.bas
172-
173-
I didn't have time to try anything, and I don't know if there is a function to convert between regular array and map array (is there?);
174-
If there isn't any function, you can create one, JSON format looks a bit more friendly then XML format, so it must be easy.
175-
Sorry I didn't understand...
176-
See my comment on:
177-
Home -- Forums -- Project help -- Tile Map Editor -- coffee first...
178-
It shows how easy is to save and load ordinary array with more than one dimension, by using the WRITE and READ keywords to save and load array variables in binary format.
179-
I am trying to make a dictionary with two columns as part of writing an assembler. I can SEARCH the first column and use (0,1) then (1,1) to look up the second column if I REDIM the array loaded from a file.
180-
But I cannot see a way to load the file with two dimensions.
181-
182-
~~~
183-
184121
REM SmallBASIC
185122
REM created: 03/04/2016
186123
? "Let's test reading files"
@@ -228,11 +165,9 @@ SEARCH i, "JEQ", r
228165
229166
~~~
230167

231-
See: Home -- Language reference -- File -- TLOAD -- How to convert TLOAD's array into nested array
232-
Thanks for your help but REDIM works for me.
168+
Example 3:
233169

234170
~~~
235-
236171
? "OPEN \\"dest\\" FOR INPUT AS #1"
237172
OPEN "dest" FOR INPUT AS #1
238173
? "TLOAD #1, i,0"
@@ -275,7 +210,4 @@ SEARCH i, "AM", r
275210
? "r = ", r
276211
? "destination = ",i(0,r)
277212
? "binary = ",i(1,r)
278-
279213
~~~
280-
281-

pages/download.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ <h2 id="source-code">Source code</h2>
8383
<h2 id="other-releases">Other releases</h2>
8484
<p><a href="http://sourceforge.net/project/showfiles.php?group_id=22348" target="_blank">SourceForge Project page</a></p>
8585
<h2 id="language-reference">Language Reference</h2>
86-
<p><a href="http://sourceforge.net/projects/smallbasic/files/Language%20Reference/sbref_v2.txt/download" target="_blank">Offline help text</a></p>
86+
<p><a href="../reference/sbref.txt" target="_blank">Offline help text</a></p>
8787
</div>
8888
<div class="pagefooter">
8989
This page was last edited on Sun, 24 Jan 2021 09:04:48 +1000

0 commit comments

Comments
 (0)
0