-->
Page 1 of 7

New build. Added arrays and bug fixes thanks to cicciocb

PostPosted: Sun Apr 17, 2016 1:01 pm
by Mmiscool
ESP BASIC 2.0 alpha 13
fix parser single "
fix for textboxes and other gui eliments spaceces being convereted to + character.
fix snag into web_gui_stuff.ino
dynamic memory handling for variables : more free ram available
introduction of function dim(a$,5,1) = "J"
introduction of arrays
the arrays can be string or float.
dim a(100) => declare a float
dim a$(50) => declare a string
dim b(200) as string => declare a string
undim a => clear the content of the buffer a
memclear => clear all the variables including the arrays

fix spaces printed on the html: now print " AAAA " is displayed as it should

new commands for serial port
serialinput var => get into var the byte received from the serial port (port 1)
serialbranch label => jumps to the label as soon as serial data are received;

instr() with 3rd optional argument
instrrev() with 3rd optional argument
increased the nb of max led neopixel to 512



// some test code for the new functionalities


'''''''''''''''''''''''''''''''''''''''''''''
'This is to test the Arrays
'''''''''''''''''''''''''''''''''''''''''''''
memclear
print ramfree()
dim a(100)

a(0) = 10
a(1) = 20
a(2) = "pollo"

print a(0)
print a(1)
print a(2)
print a(100)

dim b$(10)

b$(1) = "ciao"
b$(2) = "bambina"
' a number into a string array will be converted to string 30 -> "30"
b$(3) = 30
print b$(1)
print b$(2)
print b$(3)

dim c(10)
c(1) = 1
c(2) = 654
' a string into a float array will be treated as 0
c(3) = "ciao"
print c(1)
print c(2)
print c(3)

undim a
undim b$
undim c

dim a$(100) as string
a$(0) = "This"
a$(1) = "Is"
a$(2) = "My"
a$(3) = "First"
a$(4) = "String"
a$(5) = "Array"
a$(6) = "Example"
a$(7) = "1234"
print ramfree()

n = 7
'print the content of the array
for i=0 to n
serialprintln left( a$(i) , 2)
next i

' this is a simple bubble sort algo
for i = 0 to n
for j = i+1 to n
if a$(i) < a$(j) then goto [prox]
t = a$(i)
a$(i) = a$(j)
a$(j) = t
[prox]
next j
next i

'print the content of the array sorted
for i=0 to n
serialprintln a$(i)
next i

'create a big float array
dim big(1000)
for i=0 to 1000
big(i) = i * 2
next i

for i=0 to 1000
serialprintln big(i)
next i

end

'''''''''''''''''''''''''''''''''''''''''''''
'This is to test the serial port interrupt
'
' to test it, simply type keys into the
' terminal emulator on the serial port
'''''''''''''''''''''''''''''''''''''''''''''

memclear
print ramfree()
serialbranch [serialin]
wait

[serialin]
serialinput zz$
Serialprint "received:"
serialprintln zz$
return

'''''''''''''''''''''''''''''''''''''''''''''
'Test for MID= and instr instrrev
' instrrev search string from the end (reverse)
'''''''''''''''''''''''''''''''''''''''''''''

a = "12345678901234567890"
mid( a , 10, 2 ) = "GIORGIO"
print a

print instr(a, "78")
print instrrev(a, "78")

print instr(a, "78", 10)
print instrrev(a, "78", 10)
end

Re: New build. Added arrays and bug fixes thanks to cicciocb

PostPosted: Sun Apr 17, 2016 1:51 pm
by forlotto
errr that is a crap ton of things to digest lmao

I would think you should have went version 3.0 beta on this one .... Just saying

Holy moly!

Keep up the good work guys before you know it someone is going to be flying to the moon with espbasic lol!

hrmmm... multiple staged helium balloons and a satellite link hrmmmm..... A few thousand lightbulbs solar panels on a servo controlled car all communicating through each other to spell out ESPBASIC on the moon In large letters we may be able to see it just looking up in the sky no telescope even errrr.... maybe not but you get the idea!

Re: New build. Added arrays and bug fixes thanks to cicciocb

PostPosted: Sun Apr 17, 2016 1:59 pm
by viscomjim
Hey Mike, congrats again for your hard work and win!!!!

Great new features in this release. I do have a question on this...

print instr(a, "78")
print instrrev(a, "78")

These two I understand, but what does the 3rd option inside the () do on the following?

print instr(a, "78", 10)
print instrrev(a, "78", 10)

Re: New build. Added arrays and bug fixes thanks to cicciocb

PostPosted: Sun Apr 17, 2016 2:35 pm
by Mmiscool
Code: Select allbla = "The quick brown fox jumped over the lazy dog"
print instr(bla,"fox",20)
print instr(bla,"fox",5)
print instr(bla,"fox")


This is where it starts to look for the search string. See the example above.