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