Forum Index
HomeZBasic Home   Forum RulesForum Rules   Forum FAQForum FAQ   MemberlistMemberlist   UsergroupsUsergroups   RSS FeedRSS Feed
Site SearchSite Search   LinksLinks   DownloadDownload   Digests and SubscriptionsDigests and Subscriptions
ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in   RegisterRegister
Asc bug?

 
Post new topic   Reply to topic    Forum Index -> ZX-1281
Author Message
deadmm



Joined: 17 Mar 2006
Posts: 3
Location: Cambridge, UK

Posted: 05 January 2009, 17:38 PM    Post subject: Asc bug? Reply with quote

Hi Folks

While idling away the New Year I've come across this, distilled down from something a tad more complex:

Code:

sub main()

Dim s as String
Dim b as Byte
dim i as byte


s = "Howdy"
b = asc(s)
debug.print b
debug.print

b=asc(s,1)
debug.print b
b=asc(s,2)
debug.print b

debug.print


for i = 1 to 2
b=asc(s,i)
debug.print   b
next
end sub
.

On my Zx1280 this produces:

ZBasic v2.6.3
72

0
0

72
111


in other words a directly entered index in Asc(string, index) doesn't work but a variable does.

I presume (perhaps dangerously) it's not meant to work that way

Mal
Back to top
dkinzer
Site Admin


Joined: 03 Sep 2005
Posts: 2499
Location: Portland, OR

Posted: 05 January 2009, 18:42 PM    Post subject: Re: Asc bug? Reply with quote

deadmm wrote:
I presume (perhaps dangerously) it's not meant to work that way
Indeed not. The output is the result of a code generation optimization problem that has now been corrected.

When the compiler can determine both the string content and the specified index (if any) at compile time it may substitute the resultant value instead of generating the code to effect the function call. There was a coding error in the compile-time evaluation of the index value that caused the compiler to conclude that the result would be zero, hence the observed output.
Back to top
dkinzer
Site Admin


Joined: 03 Sep 2005
Posts: 2499
Location: Portland, OR

Posted: 06 January 2009, 19:52 PM    Post subject: Re: Asc bug? Reply with quote

dkinzer wrote:
The output is the result of a code generation optimization problem that has now been corrected.
The compiler version v2.6.9 contains a correction for this issue. You can download the full installer or just the compiler via the Downloads Page.
Back to top
Display posts from previous:   
Post new topic   Reply to topic    Forum Index -> ZX-1281 Time synchro. with the server - Timezone/DST with your computer
Page 1 of 1

 


All content Copyright © 2005-2012 Elba Corp. All Rights Reserved.
Opinions expressed in posts are those of the author and not necessarily those of Elba Corp.
Powered by phpBB © 2001, 2005 phpBB Group