-->
Page 1 of 2

BUG ??

PostPosted: Fri Aug 05, 2016 2:13 am
by Atmega8
This litte program makes the device for approx 5 Minutes unavailable.
It runs in debug, but if you run it "normal" the device hangs, but it responds to ping, so no web browser connection possible.
After 5 Minutes normal Response.

Further question:
How to append data to a file?

do
zeit=time()
write("testfile",zeit)
text=read("testfile")
print text
delay (1000)
loop until 0
end

Re: BUG ??

PostPosted: Sat Aug 06, 2016 8:15 am
by Mmiscool
You are in a tight loop with out any waits. A wait is required for web pages to be returned to the browser.

The best method to do some thing at a regular intervals the timer.

I changed your code as seen in the snipet below. Also found a bug in the process. Download the latest and greatest for all to work properly.


Try the following. It should have the same result and will not be blocking like the loop.

Code: Select alltimer 1000, [yay]
wait

[yay]
zeit=time()
write("testfile",zeit)
text=read("testfile")
print text
wait

Re: BUG ??

PostPosted: Sat Aug 06, 2016 2:25 pm
by Atmega8
Hello mmiscool ( yes indeed it IS cool!!!!),


thank you for response.

"You are in a tight loop with out any waits. A wait is required for web pages to be returned to the browser."

Blut there is a Delay of 1000ms!?



What about my second question, how to apend data to a file?

THX

Re: BUG ??

PostPosted: Sat Aug 06, 2016 2:58 pm
by Mmiscool
Right now there is no file I/O in the classic sens of basic.

traditionally in basic you would "open" a file for "input" or "output" and then be able to print or input from that file line by line.

Some thing like.
open "MyFile.txt" for output as #mike
print #mike, "Some Text"
close #mike

Unfortunately in basic this is not currently possible in esp basic. I would like to add it but have not quit figured out how.

The way the current long term storage works with the read() and write() functions.

These functions allow you to store individual data elements to the flash memory. Because each one is a separate file in the system you can arbitrarily read and write data to elements. If an element dose not exist for a read it returns an empty string or value. So the elements don't necessarily need to be created first.

Remember a variable can be used for the name when calling these functions and these functions can be used in side if then statements for the logic or any other place that allows you to do instead of supplying a literal.