SmallBASIC version 0.12.7 has been released

Forums: 

The changes are:

Fixed editor cursor flicker issue
Fixed editor display issue with escaped quotes
Fixed editor find dialog paste support
Fixed editor scrolling after paste
Fixed editor stability issues with undo/redo
Fixed error with textScreen sub-command
Fixed infinite loop when printing FUNC with extra args
Fixed issue with INSTR (node/1600)
Fixed memory access issue with JOIN (node/1586)
Fixed memory access issue with SPRINT (node/1594)
Fixed memory issue with REPLACE
Fixed memory leak with LINPUT command
Fixed screen switching when program screen has different font size
Fixed memory access issues uncovered with new test all.bas
Fixed value of i when FOR loop body not executed (node/1611)
Implemented editor now allows run by selection
Implemented editor widget now remembers the undo buffer between program runs
Implemented editor F10 option to set the command$ variable
Implemented editor double click to select word
Implemented var pooling
Updated ARRAY command to handle 2d arrays
Updated MAP handling for performance
Updated error message formatting
Updated welcome screen

The windows update includes the command line version as well as the new web server version.

So this is what you've been up to lately! very good :)

Testing 12.7 on new code, I did run into a little problem using Pause, that normally stops going back to editor when code ends.

Tested in listSelect.bas code (see post), I had to stop return to editor with Input (or Delay) because Pause wasn't stopping the return to editor.

Also, I am noticing the mouse is sometimes arrow and sometimes I bar when testing listSelect.

PS pause working now and again, since I added k = inkey code to catch escape keypresses.
I had to comment out Pause for testing in Repeat Until loop.

Thanks for the report. Let me know if you have any other minor issues and I'll make another update soon-ish.

Btw, I've added a simple keyboard marco function you should try out. Press <control>-5 (number 5, not F5), then enter a few more keystrokes. Press <control>-6 to end remembering the keystrokes. Press <control>-7 to play back the keystrokes. It should be pretty handy for formatting multiple lines of text.

I have tried pause in other code and it is working as expected.

Nor, have I been able to replicate the conditions it wasn't working. (Except trying it with another newly downloaded version of SmallBASIC.)
So it is seems rare circumstances when it doesn't work. So yeah, this is a very minor issue.

I do like how Pause is ended not just by key press but also a mouse click!

;)) control 5,6,7 sounds like how I use copy and paste!

thanks for your efforts....

I may be a fanatic user of split-join combinations, but here I noticed a new(?) issue:

' tested on android 4.1.1
dim o()      ' ok
?o,len(o)    ' ok
join o,",",z ' ok
?z,len(z)    ' ok
x=""
join x,",",z ' not ok, as x is not an array - here it crashes
?z,len(z)    ' on android, goes to OS, w/o any error-msg
' should, imho, report an error, and go back to the editor
stop

the following issue, not fatal, but a bit annoying is still here

'as mentioned here
'http://smallbasic.sourceforge.net/?q=node/1587
a=[0,1,2,3,4,5,0,7,8,0]
?a,ubound(a)
for i=0 to ubound(a)
  if a(i)=0 then a(i)=""
next
?:?a,ubound(a),"replaced '0' by '' (empty)"
join a,",",s
?"'";s;"'",,"join-ed to a string"
split s,",",a
?a,ubound(a),"split-ted to an array":?
?"imho join-split sequence should give the same array"
?"as eg. in vb, vba, ..."
stop

and according to above, a small suggestion. IMHO, to keep some level of consistency:

a=[,1,2,3,4,5,,7,8,]
?a,len(a),"ignores all 'empty' entries"
a=["",1,2,3,4,5,"",7,8,""]
?a,len(a),"ok"
s=",1,2,3,4,5,,7,8,"
split s,",",a
?a,len(a),"ignores the last 'empty' entry"
?"should produce the same result, the 2nd one"
stop

should produce the same array, the second one...

regards and cheers!

For the first issue, the command just needs to validate the input and return and error (instead of crashing). Could you please have a look at my test programs below to see whether they cover your concerns?

Also, I made test program to cover all functions. If anyone is interested, please feel free to help put some more meat on the bones:
https://raw.githubusercontent.com/chrisws/SmallBASIC/0_12_8/samples/dist...

did_fail = false
try
x=""
z=""
join x,",", z
catch
did_fail = true
end try
if !did_fail then
throw "Join error"
endif

a1=[,1,2,3,4,5,,7,8,]
a2=["",1,2,3,4,5,"",7,8,""]
if (a1 != a2 or 9 != ubound(a1)) then
? a1
? a2
throw "Empty entries not included in array"
endif

s=",1,2,3,4,5,,7,8,"
split s,",",a
if (9 != ubound(a)) then
? a
throw "Final empty entry was ignored"
endif


For the first issue, the command just needs to validate the input and return and error (instead of crashing).

Exactly! Yes!

For the other two issues my humble oppinion is that the empty strings SHOULD be included in arrays.

This is based on how Visual Basic (for Applications) handles such problems; it includes both the 1st, middle and last empty strings into an array:
=== Example from Excel
Sub arr()
s = ",1,2,,4,5,,7,8,"
MsgBox (s)
w = Split(s, ",")
MsgBox (UBound(w)) ' prints 9 - i.e. 10 items
s = Join(w, ",")
MsgBox (s) ' prints ",1,2,,4,5,,7,8,"
w = Split(s, ",")
MsgBox (UBound(w)) ' prints 9
End Sub
=================

About your test blocks:

The first block crashes both in WinXP and Android on "join" instruction, with or without the try-catch block

did_fail = false
try
x=""
z=""
join x,",", z
catch
did_fail = true
end try
if !did_fail then
throw "Join error"
endif

in the other two the "throw" shows what i mean!

thanks!

PS. no need to bother much about that :)
I always find a workaround, I'd just like to have the even better, best BASIC in the world!

As for cover all functions, it'a a splendid idea.
If you meant something like this as 'meat on bones', probably I'll take freedom to occasionally contribute with simmilar snippets:

?"? is equvalent to PRINT":?
?"APPEND: {APPEND array,x[,...] | array << x[,...]}"
'simple APPEND
?:?,"c=[0,1,2]:?c,:APPEND c,3,4,5,6:?c,:c << 7,8,9:?c"
c=[0,1,2]:?,,c,:APPEND c,3,4,5,6:?c,:c << 7,8,9:?c
'mixed APPEND
?:?,"DIM c:c << \"cat\",\"dog\",7,8,9:?c"
dim c:c << "cat","dog",7,8,9:?,,c
'more mixed nested APPEND, with access to elements
?:?,"DIM e:a=[2,3]:b=[4,5,6]:c=[7,8]:b << c,b,\"cat\",5"
?,"e << a,b,c,9:?e:?e(1),e(1)(1),e(1)(3)(1)"
dim e:a=[2,3]:b=[4,5,6]:c=[7,8]:b << c,b,"cat",5
e << a,b,c,9:?,,e:?,,e(1),e(1)(1),e(1)(3)(1)

?:?"DELAY: DELAY ms"
?,"PRINT \"abc-wait 2s-\";:DELAY 2000:PRINT \"def\""
?,"abc-wait 2s-";:DELAY 2000:?"def"

?:?"DELETE: DELETE array,index"
'simple DELETE
?:?,"a=[1,2,3,4,5]:?a,:DELETE a,2:?a"
a=[1,2,3,4,5]:?,,a,:DELETE a,2:?a
'DELETE from more complicated arrays
?:?,"e=[[2,3],[4,5,6,[7,8],[4,5,6,[7,8]],\"cat\",5],[7,8],9]"
e=[[2,3],[4,5,6,[7,8],[4,5,6,[7,8]],"cat",5],[7,8],9]
?,,e
?,"DELETE e(1)(3),1:?e:DELETE e(1),3:?e:DELETE e,1:?e"
DELETE e(1)(3),1:?,,e:DELETE e(1),3:?,,e:DELETE e,1:?,,e

Cheers

PS. corrected escape codes!

Feedback: I am getting errors on lines where you are attempting to print a code line you are about to do eg 2nd lines in:

'mixed APPEND
?:?,"DIM c:c << "cat","dog",7,8,9:?c"

and

'more mixed nested APPEND, with access to elements
?:?,"DIM e:a=[2,3]:b=[4,5,6]:c=[7,8]:b << c,b,"cat",5"

I think you have to enclose( "double quoted text" ) or use escape option .

I do appreciate learning that one may append more than one item at a time to an array, thanks!

Hi,
of course, I HAVE INSERTED the escape chars in those positions :)
If you could look into the source of my message, you'd see them. Unfortunately, the Forum uses them also as escapes :(
I forgot to double them, just pasted the snippets from SB-editor...

In fact, these lines are only explanations for usage, and are for a future 'help-file' - at least, I understood Chris's idea that way....
So, they may be ignored/out-commented :)

Btw, a close look at this line, uncovers one more hidden quirk of redundancy in SB:
appending ITSELF, to an array, uses the CURRENT state of array 'b', so array 'c' is appended twice, first itself, then nested in 'b'!! Finally in 'e' it apears 3 times....

dim e:a=[2,3]:b=[4,5,6]:c=[7,8]:b << c,b,"cat",5

Just for fun, you may try this:

b=[6]:b << b,b,b,b,b,b:?b

Thanks for your feedback!
Cheers

Dang, I forgot about the forum's format editor. One or more format options do show double quotes without escape.

How come I got 16 copies of the last post in my email
print enclose("? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?")

jsalai, did you edit the your last two posts
? "16 times"

only 7-8 times.... :)

Cheers!

OK so I am only seeing double, ha, ha...

the system doubles (or even triples) some messages :(

the best is to turn off those emails :)

Cheers!

I tried that and that is when I started seeing double!

Auto-completion of incomplete arrays is a great option, but it hides some more inconsistencies/bugs

a=[;,,,]:?1,a,ubound(a,1)+1;"x";ubound(a,2)+1;" ok":?
a=[;;,;]:?2,a,ubound(a,1)+1;"x";ubound(a,2)+1;" ok":?
a=[;;5,;]:?3,a,ubound(a,1)+1;"x";ubound(a,2)+1;" ???"
?,"a number in 3rd row, moved to the 1st free":?
a=[0;;5,;]:?4,a,ubound(a,1)+1;"x";ubound(a,2)+1;" ???"
?,"a number in 3rd row, moved to the 1st free":?
a=[,2,5,4;;5;]:?5,a,ubound(a,1)+1;"x";ubound(a,2)+1
?,"1st row? If 1st item omitted, all items ignored":?
a=[,,5,;;;]:?6,a,ubound(a,1)+1;"x";ubound(a,2)+1
?,"1st row as above, but commas correctly counted":?
a=[;;"cat",;]:?7,a,ubound(a,1)+1;"x";ubound(a,2)+1
?,"a string in 3rd row moved to first free":?
a=[,,,]:?8,a,len(a),"why is 1dim array an exception?":?
?"============="
?"Here it works flawless"
a=[1,1;2,-1,-2;1,-2,2,1;1,-3,,1,3;3,-1,,,-2]:b=[44;;;;]
?a:?b:?:c=lineqn(a,b):?c:?:c=inverse(a)*b:?c
?"If 1st item in each row present, AND items in the"
?"vector 'b' are in top rows, the calculations are OK,"
?"else, avoid auto-completion :("
stop

Cheers

Hi,

Could you please update your code such that when the test fails, an error is printed otherwise there is no output.

This can then be added to my test suite and helps to avoid the chance I'll misinterpret your report :)

Thanks
Chris

Maybe this is more clear...

a=[;;,;]
b=[0,0;0,0;0,0;0,0]
if a!=b
  ?a
  ?b
  ?"array initialization failed":?
'  throw "array initialization failed"
  fi

a=[,,,;]
b=[0,0,0,0;0,0,0,0]
if a!=b
  ?a
  ?b
  ?"array initialization failed":?
'  throw "array initialization failed"
fi

a=[;;5,;]
b=[0,0;0,0;5,0;0,0]
if a!=b
  ?a
  ?b
  ?"3rd row moved to 1st (empty)":?
'  throw "3rd row moved to 1st (empty)"
fi

a=[0;;5,;]
b=[0,0;0,0;5,0;0,0]
if a!=b
  ?a
  ?b
  ?"3rd row moved to 2nd (1st empty)":?
'  throw "3rd row moved to 2nd (1st empty)"
fi

a=[,2,5,4;;;]
b=[0,2,5,4;0,0,0,0;0,0,0,0;0,0,0,0]
if a!=b
  ?a
  ?b
  ?"row ignored when 1st item omitted":?
'  throw "row ignored when 1st item omitted"
fi

a=[0,,,;0;0,,5;]
b=[0,0,0,0;0,0,0,0;0,0,5,0;0,0,0,0]
if a!=b
  ?a
  ?b
  ?"row ignored when 1st item omitted":?
'  throw "row ignored when 1st item omitted"
fi

a=[,,,]
b=[0,0,0,0]
if a!=b
  ?a
  ?b
  ?"empty items in 1-dim array ignored":?
'  throw "empty items in 1-dim array ignored":
fi

a=[0,,5,]
b=[0,0,5,0]
if a!=b
  ?a
  ?b
  ?"empty items in 1-dim array ignored":?
'  throw "empty items in 1-dim array ignored":
fi

stop

good job!

I'm more than satisfied!
thanks a lot!

In additional to the above fixes, the next update will have a few new interesting features:

1. The PLAY command is extended to allow playing an audio file. In the desktop version this will only be for mono 44100hz .WAV files (should still use useful for games).
2. The android version will support LOCATION and SENSOR details. The LOCATION handling returns latitude/longitude. The SENSOR handing can return accelerometer, magnetic field, gyroscope, light and proximity details (depending on whether supported in the device).