<< Previous Message Main Index Next Message >>
<< Previous Message in Thread This Month Next Message in Thread >>
Date   : Wed, 29 Jun 2005 09:31:31 +0100 (BST)
From   : Steve Fewell <kranser@...>
Subject: Re: BASIC IV: Coded Line Number

--0-1287722605-1120033891=:66144

Richard_Talbot-Watkins wrote:
> But the interpreter (Basic II at least) doesn't make special cases of
> *anything* when scanning the line as you can see by this example:
> 10 IF A%=0 PRINT"<139>Works" ELSE PRINT"Broken"
> (<139> is the ASCII character 139 inserted directly into the string)
> When run with A%=0, the message '<139>Works' is printed as expected.
> When run with A%=1, we get the less useful 'Mistake at line 10'.
> The interpreter is failing to notice that the ELSE token (139) is 
> within quotes and should therefore be scanned past.  This is a BUG!  
> (bit unfair
> admittedly)
> A truly evil way to obfuscate a Basic program would be to actually put 
> valid interpretable code inside that string after the <139>, ending it 
> with :<244> (the token for REM, to tell it to skip the rest of the 
> line, or that closing quote would be a syntax error).  I've just tried 
> this in Basic II and it works perfectly, much to my horror!

> I have a feeling this was corrected in Basic IV... anyone care to try it?

http://www.8bs.com/basic/basic4-9c08.htm shows that BASIC IV just keeps 
looking for the ELSE-token, just like BASIC II. So, from this page, it looks
like nothing has been fixed in this respect. It also mentions some examples
of valid code which doesn't work as might be expected due to the ELSE keyword.
This is rather worrying, as I think 139 is a valid MODE 7 function key colour
command (not sure what key it is, is it CTRL+F0?). Can't remember what it
does though, but it is directly enterable from the keyboard.
Of course poking characters into strings could be expected to cause problems,
especially it you try to poke <cr> [ASCII 13], as BASIC would assume it has
reached the end of the line!

Steve.
 

 

               
How much free photo storage do you get? Store your holiday snaps for FREE
with Yahoo! Photos. Get Yahoo! Photos
--0-1287722605-1120033891=:66144

<DIV>Richard_Talbot-Watkins wrote:</DIV>
<DIV>&gt; But the interpreter (Basic II@...) doesn't make special cases
of<BR>&gt; *anything* when scanning the line as you can see by this example:</DIV>
<DIV>&gt; 10 IF A%=0 PRINT"&lt;139&gt;Works" ELSE PRINT"Broken"<BR>&gt; (&lt;139&gt;
is the ASCII character 139 inserted directly into the string)</DIV>
<DIV>&gt; When run with A%=0, the message '&lt;139&gt;Works' is printed 
as expected.<BR>&gt; When run with A%=1, we get the less useful 'Mistake 
at line 10'.<BR>&gt; The interpreter is failing to notice that the ELSE token
(139) is <BR>&gt; within quotes and should therefore be scanned past.&nbsp;
This is a BUG!&nbsp; <BR>&gt; (bit unfair<BR>&gt; admittedly)</DIV>
<DIV>&gt; A truly evil way to obfuscate a Basic program would be to actually 
put <BR>&gt; valid interpretable code inside that string after the &lt;139&gt;, 
ending it <BR>&gt; with :&lt;244&gt; (the token for REM, to tell it to skip
the rest of the <BR>&gt; line, or that closing quote would be a syntax error).&nbsp;
I've just tried <BR>&gt; this in Basic II and it works perfectly, much to
my horror!</DIV>
<DIV><BR>&gt; I have a feeling this was corrected in Basic IV... anyone care
to try it?</DIV>
<DIV><BR><A href="http://www.8bs.com/basic/basic4-9c08.htmhttp://www.8bs.com/basic/basic4-9c08.htm">http://www.8bs.com/basic/basic4-9c08.htm> 
shows that BASIC IV just keeps looking for the ELSE-token, just like BASIC 
II. So, from this page, it looks like nothing has been fixed in this respect.
It also mentions some examples of valid code which doesn't work as might
be expected due to the ELSE keyword.</DIV>
<DIV>This is rather worrying, as I think 139 is a valid MODE 7 function key
colour command (not sure what key it is, is it CTRL+F0?). Can't remember
what it does though, but it is directly enterable from the keyboard.</DIV>
<DIV>Of course poking characters into strings could be expected to cause
problems, especially it you try to poke &lt;cr&gt; [ASCII 13], as BASIC would
assume it has reached the end of the line!</DIV>
<DIV><BR>Steve.</DIV>
<DIV>&nbsp;</DIV>
<DIV><BR>&nbsp;</DIV><p>
               <hr size=1><font face="Arial" size="2">How much free photo storage do you
get? Store your holiday snaps for FREE with Yahoo! Photos. <a href="Get">http://us.rd.yahoo.com/mail/uk/taglines/default/photos/*http://uk.photos.yahoo.com/">Get
Yahoo! 
Photos</b></a></font>
--0-1287722605-1120033891=:66144--
<< Previous Message Main Index Next Message >>
<< Previous Message in Thread This Month Next Message in Thread >>