User Tools

Site Tools


detokeniser

Differences

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

Link to this comparison view

Next revision
Previous revision
detokeniser [2018/03/31 13:19] – external edit 127.0.0.1detokeniser [2024/01/05 00:22] (current) – external edit 127.0.0.1
Line 1: Line 1:
 =====Detokeniser===== =====Detokeniser=====
  
-//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 56:
         NEXT i%         NEXT i%
         =O$         =O$
-\\ +</code> 
 ==== Using FNdetokenise to list the error line ==== ==== Using FNdetokenise to list the error line ====
-\\ //FNdetokenise// is useful to [[/Listing%20the%20line%20an%20error%20occurs%20in%20ON%20ERROR|list the source code of a line when one occurs]].\\ \\ + 
 +//FNdetokenise// is useful to [[/Listing%20the%20line%20an%20error%20occurs%20in%20ON%20ERROR|list the source code of a line when one occurs]]. 
 + 
 ==== 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 77:
         ENDWHILE         ENDWHILE
         END         END
-In the author's opinion using this method or ***LIST** to write a Quine is cheating.\\ \\ +</code> 
 +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// and //BBC BASIC for SDL 2.0// interpreters have 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 111:
         SYS "DeleteFile", $$T%         SYS "DeleteFile", $$T%
         =S$         =S$
-\\ \\ **Do not use** this version in production code.+</code> 
 + 
 +**Do not use** this version in production code.
detokeniser.1522502355.txt.gz · Last modified: 2024/01/05 00:18 (external edit)