Author Topic: Write a list to Xrecord  (Read 2506 times)

0 Members and 1 Guest are viewing this topic.

Tharwat

  • Swamp Rat
  • Posts: 710
  • Hypersensitive
Write a list to Xrecord
« on: June 25, 2013, 04:05:35 AM »
Hello .

I am working on a project that needs to have a dictionary as a very good place to store the needed data to , but due to the plenty of real and strings to be stored I faced one problem of storing them .

I am looking for a way to store this list of data as an example '("Vertical" 20. 25. 50. 175. 7. "Horizontal" 10. 5 7 46) as a variable in Xrecord to be easily retrieved once it needed .

Thanks in advanced .

kruuger

  • Swamp Rat
  • Posts: 637
Re: Write a list to Xrecord
« Reply #1 on: June 25, 2013, 06:47:45 AM »
Hello .

I am working on a project that needs to have a dictionary as a very good place to store the needed data to , but due to the plenty of real and strings to be stored I faced one problem of storing them .

I am looking for a way to store this list of data as an example '("Vertical" 20. 25. 50. 175. 7. "Horizontal" 10. 5 7 46) as a variable in Xrecord to be easily retrieved once it needed .

Thanks in advanced .
Code: [Select]
(setq dic (cd:DCT_AddDict (namedobjdict) "MyTool"))
(cd:DCT_AddXrecord dic "Line1" '((1 . "Vertical1") (40 . 20.) (40 . 25.) (40 . 50.) ))
(cd:DCT_AddXrecord dic "Line2" '((1 . "Vertical2") (40 . 20.) (40 . 25.) (40 . 50.) ))
(cd:DCT_GetDictList dic T)

all DCT sub-routines are here:
http://cad.pl/ftp/Pack/v1/CADPL-Pack-v1.html
k.

Tharwat

  • Swamp Rat
  • Posts: 710
  • Hypersensitive
Re: Write a list to Xrecord
« Reply #2 on: June 25, 2013, 07:39:12 AM »
Code: [Select]
(setq dic (cd:DCT_AddDict (namedobjdict) "MyTool"))
(cd:DCT_AddXrecord dic "Line1" '((1 . "Vertical1") (40 . 20.) (40 . 25.) (40 . 50.) ))
(cd:DCT_AddXrecord dic "Line2" '((1 . "Vertical2") (40 . 20.) (40 . 25.) (40 . 50.) ))
(cd:DCT_GetDictList dic T)

all DCT sub-routines are here:
http://cad.pl/ftp/Pack/v1/CADPL-Pack-v1.html
k.

Thanks kruuger , it is a very idea to start with , I mean to append the list to the Xrecord as you have did in your functions .

I will be more than happy to see more example on the same issue  :-)

Much appreciated .

dgorsman

  • Water Moccasin
  • Posts: 2437
Re: Write a list to Xrecord
« Reply #3 on: June 25, 2013, 10:28:00 AM »
DXF codes have ranges, why not use sequential values (e.g. 400, 401, 402) so the values can be easily de-indexed later with (assoc...)?
If you are going to fly by the seat of your pants, expect friction burns.

try {GreatPower;}
   catch (notResponsible)
      {NextTime(PlanAhead);}
   finally
      {MasterBasics;}

Tharwat

  • Swamp Rat
  • Posts: 710
  • Hypersensitive
Re: Write a list to Xrecord
« Reply #4 on: June 25, 2013, 11:37:34 AM »
DXF codes have ranges, why not use sequential values (e.g. 400, 401, 402) so the values can be easily de-indexed later with (assoc...)?

That seems interesting , could you please give an example ?  :-)

dgorsman

  • Water Moccasin
  • Posts: 2437
Re: Write a list to Xrecord
« Reply #5 on: June 25, 2013, 12:38:44 PM »
If I was storing three string which describe an object (e.g. Long description, short description, ID), I would find that DXF codes 300 through 309 are for "Arbitrary strings".  I could always store them in the same order, and read them back in the same order, but what happens later if I add another piece of data?  Instead, I choose to use the range of codes when creating the XRecord:

Code: [Select]
(300 . "Long description")
(301 . "Short desc")
(302 . "ID-0001")

When I read the data back, if I want just the ID code the order doesn't matter - I can just (assoc 302 ...) to pull that data out of the list returned from the XRecord.

Many of the DXF codes are provided in ranges so this can be done with pointers, integers, secondary points, and so on.
If you are going to fly by the seat of your pants, expect friction burns.

try {GreatPower;}
   catch (notResponsible)
      {NextTime(PlanAhead);}
   finally
      {MasterBasics;}