USing a short string to store data

Please support our Pascal and Delphi advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Nov 2007
Posts: 68
Reputation: jsosnowski is an unknown quantity at this point 
Solved Threads: 11
jsosnowski's Avatar
jsosnowski jsosnowski is offline Offline
Junior Poster in Training

USing a short string to store data

 
0
  #1
Feb 10th, 2009
I am working on a project for a Cad program in which I must embed data in the Cad file. The tools for doing so in the cad program allow for embedding boolean, integer, double byte and string values, one at a time. There is a lot of data and the best way to store it would be in a single packet. The best option then appears to be using strings. The string data type in the Cad program is limited to 255 characters. I could enter the data in the string as comma delimited items, but wonder if it could be packed tighter by assembling the data as individual byte packets in a string and storing it that way. My instincts tell me that won't work in in pascal/delphi, because of carriage returns and linefeeds etc., but I am not sure. Can anyone shed some light on this or steer me to some resources / samples that could help?
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 1,735
Reputation: LizR has a spectacular aura about LizR has a spectacular aura about 
Solved Threads: 186
LizR LizR is offline Offline
Posting Virtuoso

Re: USing a short string to store data

 
0
  #2
Feb 11th, 2009
Strings can contain line feeds etc
Did I just hear "You gotta help us, Doc. We've tried nothin' and we're all out of ideas" ? Is this you? Dont let this be you! I will put in as much effort as you seem to.
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 68
Reputation: jsosnowski is an unknown quantity at this point 
Solved Threads: 11
jsosnowski's Avatar
jsosnowski jsosnowski is offline Offline
Junior Poster in Training

Re: USing a short string to store data

 
0
  #3
Feb 11th, 2009
Thanks, I realized my error, but on the way I also discovered the use of "absolute" to align the memory of two types. I am self educated which means there are often little holes in my bigger picture. I love these little surprises. Lots of possiblities for this one!
Reply With Quote Quick reply to this message  
Join Date: Feb 2009
Posts: 3,437
Reputation: sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of 
Solved Threads: 624
Sponsor
sknake's Avatar
sknake sknake is offline Offline
.NET Enthusiast

Re: USing a short string to store data

 
0
  #4
Feb 16th, 2009
I'm not sure if this will fit your needs exactly but you can read/write a struct in files (http://delphi.about.com/od/fileio/a/fileof_delphi.htm). If the data is embedded in a cad file then make the first part of your struct a 5 byte "Signature" and assign 5 unique values that make up the signature. You can then locate the signature in the CAD file and read SizeOf(struct) to get your data out.

It is binary so these files are not always portable across different platforms
Scott Knake
Custom Software Development
Apex Software, Inc.
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 68
Reputation: jsosnowski is an unknown quantity at this point 
Solved Threads: 11
jsosnowski's Avatar
jsosnowski jsosnowski is offline Offline
Junior Poster in Training

Re: USing a short string to store data

 
0
  #5
Feb 16th, 2009
Thanks sknake!

No it doesn't fit my needs, but it is another interesting idea. The problem with CAD files is that they are not standard databases. There are too many variable types to define different types of drawing "entities" many with attached attributes that are not necessarily in the same memory area. Everything is linked with page addresses. Direct read and write is a very risky propsect. Fortunately there are plenty of tools for interogating the data. In my case I was looking for a way of providing additional information in a consolidated packet. A string is an easy, compact means of doing so.

Thanks for the help.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:




Views: 1036 | Replies: 4
Thread Tools Search this Thread



Tag cloud for Pascal and Delphi
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC