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
Problem with program memory array indexing

 
Post new topic   Reply to topic    Forum Index -> ZBasic Language
Author Message
mikep



Joined: 24 Sep 2005
Posts: 771
Location: Austin, TX

Posted: 07 August 2010, 0:30 AM    Post subject: Problem with program memory array indexing Reply with quote

I had some problems with indexing into program memory string arrays. Initially I thought it was because I was using a Byte index instead of an Integer (which shouldn't make a difference). The result was garbage strings. The following reduced code shows the problem
Code:
Private stringData as StringVectorData ({ "test" })
Public Sub Main()
   Debug.print stringData(1 + 1 - 1) ' erroneous line
   Debug.print stringData(1)
End Sub

When compiled the following error message occurs
Code:
test.bas:3: Warning(9): first index of "stringData" is greater than the upper bound
What does "first index" mean in any case and the error shouldn't be occurring. The following snippet of generated native code indicates the problem
Code:
void
zf_Main(void)
{
   outStr(progMemReadStringTbl(PROG_MEM(&mzv_stringData.ptr[10637328UL - 1])));
   sendCRLF();
   outStr(progMemReadStringTbl(PROG_MEM(&mzv_stringData.ptr[1 - 1])));
   sendCRLF();
}
Back to top
dkinzer
Site Admin


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

Posted: 07 August 2010, 17:06 PM    Post subject: Re: Problem with program memory array indexing Reply with quote

mikep wrote:
What does "first index" mean in any case and the error shouldn't be occurring.
The use of "first index" is misleading, I suppose, since the the data item is a single dimension array. It would make more sense if the data item involved had multiple indices.

You are correct, of course, that the warning should not be issued. The correction in the compiler code was simple. An experimental version with the correction for this and a few other issues is available via the link below. The archive contains only the compiler executable and the changes.txt file. The executable can simply be extracted to the ZBasic installation directory. Copying or renaming the existing compiler executable before doing so is recommended.

http://www.zbasic.net/download/ZBasic/3.1/ZBasic_3-1-4.zip
Back to top
mikep



Joined: 24 Sep 2005
Posts: 771
Location: Austin, TX

Posted: 08 August 2010, 6:54 AM    Post subject: Reply with quote

Looks good now. Thank you for the fast fix.
Back to top
Display posts from previous:   
Post new topic   Reply to topic    Forum Index -> ZBasic Language 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