Real Software Forums

The forum for Real Studio and other Real Software products.
[ REAL Software Website | Board Index ]
It is currently Sat Jun 23, 2018 8:52 pm
xojo

All times are UTC - 5 hours




Post new topic Reply to topic  [ 21 posts ]  Go to page Previous  1, 2
Author Message
 Post subject: Re: Include files in build
PostPosted: Fri Apr 05, 2013 1:30 pm 
Offline

Joined: Fri Jan 06, 2006 3:21 pm
Posts: 12388
Location: Portland, OR USA
Pass the string to a memoryblock and open a binarystream on the memoryblock. Example code in my previous post, above. Once you have done

bstream = new binarystream(mb)

use the bstream binarystream just like it was a file on disk.


Top
 Profile  
Reply with quote  
 Post subject: Re: Include files in build
PostPosted: Fri Apr 05, 2013 1:39 pm 
Offline

Joined: Fri Mar 22, 2013 11:33 am
Posts: 14
timhare, thanks so much for help. I think this approach will solve these issues for me.


Top
 Profile  
Reply with quote  
 Post subject: Re: Include files in build
PostPosted: Sat Apr 06, 2013 11:30 am 
Offline

Joined: Fri Mar 22, 2013 11:33 am
Posts: 14
I have succeeded in adding text files to a project and accessing them in code and this works fine. However, I have not been able to do the same for binary files. I used the following code to access a binary file added to the project but it does not work. Can you offer any suggestions? I am completely stumped by this problem. Thanks for any help.

dim s as string
dim mb as memoryblock
dim bstream as BinaryStream

s = Data1
mb = s
bstream = new BinaryStream(mb)

Data.StringValue(bstream.LittleEndian) = bstream.Read(Data.Size)

bstream.Close

'Data1 is the binary file added to the project and represents a structure
'Data is the structure I would like to read the data into.


Top
 Profile  
Reply with quote  
 Post subject: Re: Include files in build
PostPosted: Sat Apr 06, 2013 2:32 pm 
Offline

Joined: Fri Mar 22, 2013 11:33 am
Posts: 14
I have solved the problem of reading the included binary file. this code line:

Data.StringValue(bstream.LittleEndian) = bstream.Read(Data.Size)

should have been:

Data.StringValue(false) = bstream.Read(Data.Size)

with this change, the read is successful!

Thanks to all who helped solve this issue.


Top
 Profile  
Reply with quote  
 Post subject: Re: Include files in build
PostPosted: Sat Apr 06, 2013 3:33 pm 
Offline

Joined: Fri Jan 06, 2006 3:21 pm
Posts: 12388
Location: Portland, OR USA
If you're using structures, you should be able to use a Ptr and skip the binarystream.

s = Data1 // not necessary to copy it twice
mb = Data1 // set the mem block directly
dim p as Ptr = mb
Data= p.theStructure(0)

'or

for i = 0 to lenb(data1)/theStructure.Size
Data = p.theStructure(i)
next


Top
 Profile  
Reply with quote  
 Post subject: Re: Include files in build
PostPosted: Sun Apr 07, 2013 7:51 pm 
Offline

Joined: Fri Mar 22, 2013 11:33 am
Posts: 14
Thanks, timhare. All of this is great info and a big boost to my coding efforts. Thanks so much for your help.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 21 posts ]  Go to page Previous  1, 2

All times are UTC - 5 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

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group