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?

Strings can contain line feeds etc

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!

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

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.