User Tools

Site Tools


detokeniser

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

detokeniser [2018/03/31 13:19]
127.0.0.1 external edit
detokeniser [2018/04/17 15:47] (current)
tbest3112 Added syntax highlighting
Line 2: Line 2:
  
 //by Jon Ripley, January 2008, May 2011//\\ \\  The //​FNdetokenise//​ function listed below accepts a string containing either a tokenised program line or tokenised code and returns a string containing detokenised code:​\\ ​ //by Jon Ripley, January 2008, May 2011//\\ \\  The //​FNdetokenise//​ function listed below accepts a string containing either a tokenised program line or tokenised code and returns a string containing detokenised code:​\\ ​
 +<code bb4w>
         DEF FNdetokenise(S$)         DEF FNdetokenise(S$)
         IF S$ = ""​ OR S$ = CHR$0+CHR$255+CHR$255 THEN =""​         IF S$ = ""​ OR S$ = CHR$0+CHR$255+CHR$255 THEN =""​
Line 52: Line 53:
         NEXT i%         NEXT i%
         =O$         =O$
 +</​code>​
 \\  \\ 
 ==== Using FNdetokenise to list the error line ==== ==== Using FNdetokenise to list the error line ====
Line 57: Line 59:
 ==== Using FNdetokeniser to write a Quine ==== ==== Using FNdetokeniser to write a Quine ====
 \\  Using //​FNdetokenise//​ it is possible to write a [[http://​en.wikipedia.org/​wiki/​Quine_%28computing%29|Quine]],​ that is, a program which when run outputs its own listing:​\\ ​ \\  Using //​FNdetokenise//​ it is possible to write a [[http://​en.wikipedia.org/​wiki/​Quine_%28computing%29|Quine]],​ that is, a program which when run outputs its own listing:​\\ ​
 +<code bb4w>
         P% = PAGE         P% = PAGE
         WHILE (!P% AND &​FFFFFF) <> &FFFF00         WHILE (!P% AND &​FFFFFF) <> &FFFF00
Line 67: Line 70:
         ENDWHILE         ENDWHILE
         END         END
 +</​code>​
 In the author'​s opinion using this method or ***LIST** to write a Quine is cheating.\\ \\  In the author'​s opinion using this method or ***LIST** to write a Quine is cheating.\\ \\ 
 ==== Using the built-in detokeniser ==== ==== Using the built-in detokeniser ====
 \\  The BBC BASIC for Windows interpreter has a built-in detokeniser accessed using the ***LIST** command that detokenises a specified file and outputs the listing on the current output device. Whilst it is possible to write a simpler looking detokeniser utilising ***LIST** the resulting routine is significantly slower due to the number of file operations required.\\ \\  \\  The BBC BASIC for Windows interpreter has a built-in detokeniser accessed using the ***LIST** command that detokenises a specified file and outputs the listing on the current output device. Whilst it is possible to write a simpler looking detokeniser utilising ***LIST** the resulting routine is significantly slower due to the number of file operations required.\\ \\ 
 +<code bb4w>
         DEF FNdetokenise(S$)         DEF FNdetokenise(S$)
         IF S$=""​ OR S$=CHR$0+CHR$255+CHR$255 THEN =""​         IF S$=""​ OR S$=CHR$0+CHR$255+CHR$255 THEN =""​
Line 96: Line 101:
         SYS "​DeleteFile",​ $$T%         SYS "​DeleteFile",​ $$T%
         =S$         =S$
 +</​code>​
 \\ \\ **Do not use** this version in production code. \\ \\ **Do not use** this version in production code.
detokeniser.txt ยท Last modified: 2018/04/17 15:47 by tbest3112