Skip to content

Commit a4a7718

Browse files
committed
COMMON: map,ref,try/catch,ismap,isref,array,str,array unary operators
1 parent 97f2e2b commit a4a7718

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+3406
-2687
lines changed

ChangeLog

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,21 @@
1+
2014-09-28
2+
Refactor image handling to use system object
3+
4+
2014-09-22
5+
Implemented ARRAY command to read JSON into a map variable
6+
7+
2014-09-19
8+
Fix STR(v) support for map variables
9+
10+
2014-09-12
11+
Add support for unary operators on array elements
12+
Fix printing UDS vars
13+
14+
2014-09-08
15+
Fix call FUNC with (arg1), (arg2)
16+
Fix INKEY Backspace in FLTK
17+
Fix FOR/NEXT using float increments
18+
119
2014-09-06
220
RTE command renamed THROW
321

configure.ac

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ dnl This program is distributed under the terms of the GPL v2.0
77
dnl Download the GNU Public License (GPL) from www.gnu.org
88
dnl
99

10-
AC_INIT([smallbasic], [0.11.15])
10+
AC_INIT([smallbasic], [0.11.16])
1111
AC_CONFIG_SRCDIR([configure.ac])
1212

1313
AC_CANONICAL_TARGET
@@ -226,6 +226,7 @@ function buildSDL() {
226226
AC_DEFINE(IMPL_DEV_READ, 1, [Implement dev_read()])
227227
AC_DEFINE(IMPL_OSD_SOUND, 1, [Driver implements osd_sound()])
228228
AC_DEFINE(IMPL_LOG_WRITE, 1, [Driver implements lwrite()])
229+
AC_DEFINE(IMPL_IMAGE, 1, [Driver implements image commands])
229230
AC_DEFINE(OS_PREC64, 1, [64 bit variables])
230231
AC_DEFINE(DRV_BEEP, 1, [Use the driver based beep function])
231232

debian/changelog

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
smallbasic (0.11.16) unstable; urgency=low
2+
* Add support for unary operators on array elements
3+
* Fix call FUNC with (arg1), (arg2)
4+
* Fix INKEY Backspace in FLTK
5+
* Fix FOR/NEXT using float increments
6+
7+
-- Chris Warren-Smith <cwarrensmith@gmail.com> Sat, 13 Sept 2014 09:45:25 +1000
8+
19
smallbasic (0.11.15) unstable; urgency=low
210
* RTE renamed THROW
311

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
url = "http://ajax.googleapis.com/ajax/services/search/web?rsz=large&q=" + trim(command) + "&v=1.0"
2+
open url as #1
3+
if (eof(1)) then
4+
throw "Connection failed: " + url
5+
fi
6+
7+
dim results
8+
tload #1, results
9+
json = array(results)
10+
num_results = len(json.responseData.results)
11+
for i = 0 to num_results - 1
12+
print json.responseData.results(i).titleNoFormatting
13+
print " "; json.responseData.results(i).unescapedUrl
14+
next i

samples/distro-examples/tests/array.bas

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,44 @@ if ubound(m)<>3 then ?"UBOUND() ERROR"
2929
if lbound(m,2)<>-1 then ?"LBOUND() ERROR"
3030
if ubound(m,2)<>1 then ?"UBOUND() ERROR"
3131

32+
if (isarray(m) == false) then
33+
throw "m is not an array"
34+
end if
35+
36+
m2 = array("[1,2,3,\"other\"]")
37+
if (isarray(m2) == false) then
38+
throw "m2 is not an array"
39+
end if
40+
41+
if (isnumber(m2(0)) == false) then
42+
throw "m2(0) is not an number"
43+
end if
44+
45+
if (isstring(m2(3)) == false) then
46+
throw "m2(3) is not an string"
47+
end if
48+
49+
m3 = array("{\"cat\":{\"name\":\"lots\"},\"other\":\"thing\",\"zz\":\"thing\"}")
50+
if (ismap(m3) == false) then
51+
throw "m3 is not an map"
52+
end if
53+
54+
m4 = byref m3
55+
if (isref(m4) == false) then
56+
throw "m3 is not an ref"
57+
end if
58+
59+
if m4.cat.name <> "lots" then
60+
throw "ref/map error"
61+
end if
62+
63+
dim sim
64+
sim << 100
65+
sim(0) --
66+
sim(0) ++
67+
sim(0) /= 2
68+
if (sim(0) <> 50) then
69+
throw "dim sim not tasty"
70+
fi
71+
72+

samples/distro-examples/tests/iifs.bas

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,15 @@
11
'
2+
' Test for refactoring regression
3+
'
4+
blue=1
5+
red=2
6+
green=3
7+
8+
if false then blue=4:red=5:green=6
9+
10+
if (1 <> blue OR red <> 2 OR green <> 3) then
11+
throw "Inline IF error: blue=" + blue + " red=" + red + " green=" + green
12+
endif
213

314
' normal if
415
if 1 then:? "Normal IF - Ok":else:? "ERROR":fi
@@ -25,4 +36,3 @@ goto 200
2536
? "label 600 - Ok"
2637
goto 210
2738

28-
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
something
22
123
3-
[blah=something,other=123,100=cats]
3+
{"100":"cats","blah":"something","other":123}

samples/distro-examples/tests/output/ref.out

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@ dog= dog
44
1= 1
55
a=b a=b
66
a<>b a<>b
7-
[NAME=kitchen]
8-
[NAME=hall]
9-
[NAME=Kitchen,FRIDGE=empty]
10-
[NAME=toilet,OCCUPIED=-1]
11-
[NAME=Kitchen,FRIDGE=empty]
12-
[NAME=hall]
7+
{"NAME":"kitchen"}
8+
{"NAME":"hall"}
9+
{"FRIDGE":"empty","NAME":"Kitchen"}
10+
{"NAME":"toilet","OCCUPIED":-1}
11+
{"FRIDGE":"empty","NAME":"Kitchen"}
12+
{"NAME":"hall"}
13+
toilet
Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,12 @@
11
start of test
2-
end of test
2+
a:
3+
{"XCAT":"cat","XDOG":"dog","XFISH":{"BIG":"big","SMALL":"small"}}
4+
In a:
5+
a.XCAT=cat
6+
a.XDOG=dog
7+
a.XFISH={"BIG":"big","SMALL":"small"}
8+
In a.xfish:
9+
a.xfish.BIG=big
10+
a.xfish.SMALL=small
11+
3
12+
2

samples/distro-examples/tests/ref.bas

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ print "a<>b", iFF(a==b, "a=b", "a<>b")
1515

1616
dim rooms
1717
sub addRoom(byref room)
18-
rooms << @room
18+
rooms << byref room
1919
end
2020

2121
dim kitchen,hall,toilet
@@ -40,3 +40,5 @@ print rooms(0)
4040
print rooms(1)
4141
print rooms(2)
4242

43+
roomref = byref rooms(0)
44+
print roomref.name

0 commit comments

Comments
 (0)