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
Passing StringVectorData

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



Joined: 15 Oct 2006
Posts: 329
Location: Long Island, New York

Posted: 28 November 2006, 2:06 AM    Post subject: Passing StringVectorData Reply with quote

In an effort to be a bit more efficient in my coding, I'm using StringVectorData to store menu strings. Although the implimentation is fairly straightfoward, there's a few things I'd like to do that I can't seem to get a grasp on.

In total, I have 5 different menus, having varying numbers of entries. These menu strings are need to be sent via a serial (USB) connection to a terminal. In my previous version (without StringVectorData), each menu that was to be displayed had it's own sub which handled both the serial communications and the string data. Very simple.

In order to reduce so much redundant code, I would like to pass the vector data variable name to the sub, which in turn will parse the data and send it off to the serial port.

So how does one pass the data in an array where the array could be one of several, each with different upper bounds?

-Don
Back to top
dkinzer
Site Admin


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

Posted: 28 November 2006, 2:36 AM    Post subject: Reply with quote

I did something similar to this on my dividing head controller project. To address some of the issues that you are encountering, I ended up creating a "menu compiler" that takes textual descriptions of the menu structure and produces a file that can be used to initialize a ByteVectorData element. The data structure includes tables that can be indexed by a menu ID to locate the information for that menu, including the text for menu items and the actions associated with them.

To address your specific question, you'll need to pass the address of the data and its length. Then, in the service routine you'll have to use GetEEPROM() to read the data from Program Memory.

If you're interested in using the menu compiler, you can download it from the project page given above.
Back to top
Don_Kirby



Joined: 15 Oct 2006
Posts: 329
Location: Long Island, New York

Posted: 28 November 2006, 2:48 AM    Post subject: Reply with quote

I looked into using the DataAddress property, but was having difficulty implimenting it. After reading your post however, I think I have an idea how it should go together, using DataAddress and UBound to pass the data.

Thanks for the input Don.

-D
Back to top
Don_Kirby



Joined: 15 Oct 2006
Posts: 329
Location: Long Island, New York

Posted: 29 November 2006, 0:07 AM    Post subject: Reply with quote

So I have it working, but it's real clunky... Don, I looked around at your Dividing Head Controller project, but didn't find any links to the menu compiler. I'd like to see how someone who actually knows how to code does it...

-Don
Back to top
dkinzer
Site Admin


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

Posted: 29 November 2006, 0:29 AM    Post subject: Reply with quote

I was mistaken - there is no link on that page. On the parent page there is a short description and an invitation to email me for further information. I sent you (Don Kirby) a private email with the information.
Back to top
Don_Kirby



Joined: 15 Oct 2006
Posts: 329
Location: Long Island, New York

Posted: 29 November 2006, 1:18 AM    Post subject: Reply with quote

Thanks Don
Back to top
Don_Kirby



Joined: 15 Oct 2006
Posts: 329
Location: Long Island, New York

Posted: 03 December 2006, 2:50 AM    Post subject: Reply with quote

Another little detail...

In my experiences with StringVectorData, I have yet to find a way to embed characters that are not directly type-able (i.e. [ESC] or [CR]+[LF]). I have worked around this by parsing command strings via code, but I would rather store them in the vector data.

Is there a method provided for this?

-Don
Back to top
dkinzer
Site Admin


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

Posted: 03 December 2006, 3:55 AM    Post subject: Reply with quote

Don_Kirby wrote:
Is there a method provided for [embedding non-printing characters in StringVectorData initializers]?

There is currently no provision for doing so.

The best option, perhaps, is to use ByteVectorData. You can mix strings and byte values as shown in the example below. Of course, that makes using the strings a little harder but it might be simpler than what you're doing now.

Code:
Dim msg as ByteVectorData({ "Hello, world!", &H0d, &H0a})
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