BBC BASIC
« Re: FNnxtwrd() TOOL (fixed) »

Welcome Guest. Please Login or Register.
Mar 31st, 2018, 10:44pm



ATTENTION MEMBERS: Conforums will be closing it doors and discontinuing its service on April 15, 2018.
We apologize Conforums does not have any export functions to migrate data.
Ad-Free has been deactivated. Outstanding Ad-Free credits will be reimbursed to respective payment methods.

Thank you Conforums members.
Cross-platform BBC BASIC (Windows, Linux x86, Mac OS-X, Android, iOS, Raspberry Pi)
BBC BASIC Resources
BBC BASIC Help Documentation
BBC BASIC for Windows Home Page
BBC BASIC Programmers' Reference
BBC BASIC Beginners' Tutorial
BBC BASIC for SDL 2.0 Home Page
BBC BASIC Discussion Group

« Previous Topic | Next Topic »
Pages: 1  Notify Send Topic Print
 thread  Author  Topic: Re: FNnxtwrd() TOOL (fixed)  (Read 435 times)
Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 803
xx Re: FNnxtwrd() TOOL (fixed)
« Thread started on: Nov 1st, 2016, 3:59pm »

on Nov 1st, 2016, 01:33am, michael wrote:
I REALLY need a proper tool to interpret my future works

You might be interested in the 'next word' routine that I use in LB Booster:

Code:
      Alphabet$ = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"      testString$ = "Happy Halloween my fellow programmers!!!"      REPEAT        word$ = FNword(testString$)        PRINT word$      UNTIL word$ = ""      END      DEF FNword(RETURN A$)      LOCAL space$      space$ = FNtoken(A$, " ")      = FNtoken(A$,Alphabet$)      DEF FNtoken(RETURN A$, list$)      LOCAL T$      WHILE INSTR(list$, LEFT$(A$,1))        T$ += LEFT$(A$,1)        A$ = MID$(A$,2)      ENDWHILE      = T$ 

The FNtoken routine returns as much of the supplied string as matches the supplied list of acceptable characters. It is called twice, once to discard leading spaces and then to return the next 'word'. This is quite flexible, for example if you wanted to skip leading tabs as well as spaces ('whitespace') you could do:

Code:
      whitespace$ = FNtoken(A$, " "+CHR$(9)) 

and if you want to return a 'variable name' (any letter followed by any combination of letters and numbers) you could do:

Code:
      variable$ = FNtoken(A$, Alphabet$) + FNtoken(A$, Alphabet$+"0123456789") 

Richard.
« Last Edit: Nov 1st, 2016, 6:44pm by Richard Russell » User IP Logged

Pages: 1  Notify Send Topic Print
« Previous Topic | Next Topic »

| |

This forum powered for FREE by Conforums ©
Terms of Service | Privacy Policy | Conforums Support | Parental Controls