Beijer Electronics (formerly QSI Corporation)

Manufacturer of Mobile Data and Human Machine Interface Terminals.
It is currently Sun Nov 19, 2017 6:51 am

All times are UTC - 7 hours




Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Tue Aug 04, 2009 9:30 am 
Offline

Joined: Mon Apr 17, 2006 11:02 am
Posts: 10
Location: Detroit, MI
Hello,

I have large byte array's that I want to save. When I use the PersistenceVariablesV2 it triples the size used on the Flash File System.

Does the PersistenceVariablesV2 save the byte array as a string.

Example

dim data[100] as byte
' if saved as a string it would look like "data[0,0,0,0,0,0,0,...till ,0]"
' or does it save as binary data.

What I need is to save it as binary data so it does not consume all the Flash File System.

I am using a G55

Thanks,

Scott Gilbert


Top
 Profile  
 
PostPosted: Tue Aug 04, 2009 9:44 am 
Offline
QSI Support
QSI Support
User avatar

Joined: Wed Mar 08, 2006 12:25 pm
Posts: 881
Location: Salt Lake City, Utah
Due to the very limited amount of reflection that Qlarity supports, the PersistentVariables object must save variable values in string form (as you correctly observed).

This is documented in the object, albeit in a somewhat obscure spot. From the documentation:
Quote:
Each saved numeric type property requres about 40 bytes, each saved string/array type requires about 30 bytes plus 4 * the length of the array.


In practice, I have never seen anyone use the PV object for more than a dozen or so variables in a single workspace, so unless your arrays are huge you should not risk running out of file space.

If you have need to save a large amount of data and do need the space efficiency, I would strongly recommend you directly read and write your own files with OpenFile, WriteFile, ReadFile and CloseFile. Not only will these allow you to write the data in binary form, but will be much more efficient in terms of speed and allow you to control exactly when the values are saved and restored.

If you still have more data than may fit in the file system (a typical G55 program has about 3+ MB available flash storage for files, although this will vary based on font and graphics usage), you can use zlibcompress to compress the binary data prior to saving.

-----------------------------------

For reference, if Object_1 had an 10 element array of bytes called data, the following would be saved:
Quote:
object_1.data=[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n
(\n is the newline character). The object name and property name are saved as well so that if the persistence list is changed between compiles the values will correctly restore.

_________________
Jeremy
http://www.beijerinc.com


Top
 Profile  
 
PostPosted: Tue Aug 04, 2009 9:50 am 
Offline

Joined: Mon Apr 17, 2006 11:02 am
Posts: 10
Location: Detroit, MI
Thanks,

I will be looking at using the FileObjectV2 instead.

Scott


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 7 hours


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group