Way of checking for end of data

Got an idea for enhancing SpiderBasic? New command(s) you'd like to see?
User avatar
MrTAToad
Posts: 291
Joined: Sun Apr 20, 2014 11:43 am
Location: Chichester, England
Contact:

Way of checking for end of data

Post by MrTAToad »

At the moment once all data has been read and reading continues, it will generate a browser error. It would be nice to be able to detect in SpiderBasic whether all data has read or not.
Fangles
Posts: 11
Joined: Sat Jan 28, 2017 4:25 am

Re: Way of checking for end of data

Post by Fangles »

What's wrong with doing this? It works with PureBasic and I've tested it on a SpiderBasic application

Code: Select all

Restore BeginDictionary
  While TempString.s <> "_EndDictionary_"
    Read.s TempString.s
     If TempString.s <> "_EndDictionary_"
       ; Do something here
     EndIf
   Wend
   
   TempString.s = "<>"
     
DataSection
  BeginDictionary:
  Data.s "-",               "/space"
  Data.s "_",               "/space"
  Data.s "#",               "/space"
  Data.s "@",               "/space"
  Data.s "!",               "/space"
  Data.s "_EndDictionary_", "_EndDictionary_"
EndDataSection
User avatar
MrTAToad
Posts: 291
Joined: Sun Apr 20, 2014 11:43 am
Location: Chichester, England
Contact:

Re: Way of checking for end of data

Post by MrTAToad »

The problem is if you for get any data terminator the program (or rather the browser) will hang...
Fangles
Posts: 11
Joined: Sat Jan 28, 2017 4:25 am

Re: Way of checking for end of data

Post by Fangles »

MrTAToad wrote:The problem is if you for get any data terminator the program (or rather the browser) will hang...
Weird, the above method works properly for me in PB AND SB without any issues.
User avatar
MrTAToad
Posts: 291
Joined: Sun Apr 20, 2014 11:43 am
Location: Chichester, England
Contact:

Re: Way of checking for end of data

Post by MrTAToad »

Are you omitting the last data line ?
Fangles
Posts: 11
Joined: Sat Jan 28, 2017 4:25 am

Re: Way of checking for end of data

Post by Fangles »

MrTAToad wrote:Are you omitting the last data line ?
No. I needed a recogniseable end of data marker so I didn't have those runaway problems:)
Fred
Site Admin
Posts: 1506
Joined: Mon Feb 24, 2014 10:51 am

Re: Way of checking for end of data

Post by Fred »

I don't see why a marker is a problem, as you define the data yourself
User avatar
MrTAToad
Posts: 291
Joined: Sun Apr 20, 2014 11:43 am
Location: Chichester, England
Contact:

Re: Way of checking for end of data

Post by MrTAToad »

Fred wrote:I don't see why a marker is a problem, as you define the data yourself
It's not - but if you try to read past the end of data, then its a problem.
Post Reply