• Skip to main content
  • Skip to search
  • Skip to footer
Cadence Home
  • This search text may be transcribed, used, stored, or accessed by our third-party service providers per our Cookie Policy and Privacy Policy.

  1. Community Forums
  2. Allegro X Scripting - Skill
  3. How to store association table in attachment

Stats

  • Replies 1
  • Subscribers 17
  • Views 8053
  • Members are here 0
More Content

How to store association table in attachment

mir0mik
mir0mik over 4 years ago

Hi,

I have some data in my code in form of an association table and I would like to store this table in the attachment section of the *.brd file...

;my table...
qqq_formFieldsDefaults = makeTable( "formFields" nil)
qqq_formFieldsDefaults[ 'qqq_formField_itemNumber] = '( nil value "fill IN" isEnabled t)
qqq_formFieldsDefaults[ 'qqq_formField_itemRevision] = '( nil value "1" isEnabled nil)
...

;my attachment data
qqq_attachmentData = ( nil 'formFields nil 'otherData nil ...)

;my attachment storing
qqq_attachmentData -> formFields = tableToList( qqq_formFieldsDefaults) ;need to convert the table to associated list for storing
axlCreateAttachment( "qqq_databaseAttachment" nil 0 'string sprintf( nil " '%L" qqq_attachmentData))

;my restoring attachment
qqq_databaseAttachmentID = axlGetAttachment( "qqq_databaseAttachment" 'string)
qqq_attachmentData = car( errsetstring( qqq_databaseAttachmentID -> data))

The issue is that storing the associated table without converting it to an associated list doesn't work... Now my question is there a reverse function to the tableToList() function? Or does anybody have some good code on how to convert the list back?

Thanks!
Miro

  • Cancel
  • Sign in to reply
  • mir0mik
    mir0mik over 4 years ago

    I did it this way but if someone can think of something nicer I will be glad...

    ;my table...
    qqq_formFieldsDefaults = makeTable( "formFields" nil)
    qqq_formFieldsDefaults[ 'qqq_formField_itemNumber] = '( nil value "fill IN" isEnabled t)
    qqq_formFieldsDefaults[ 'qqq_formField_itemRevision] = '( nil value "1" isEnabled nil)
    ...

    ;my attachment data
    qqq_attachmentData = ( nil 'formFields nil 'otherData nil ...)

    ;my attachment storing
    qqq_attachmentData -> formFields = tableToList( qqq_formFieldsDefaults) ;need to convert the table to associated list for storing
    axlCreateAttachment( "qqq_databaseAttachment" nil 0 'string sprintf( nil " '%L" qqq_attachmentData))

    ;my restoring attachment
    qqq_databaseAttachmentID = axlGetAttachment( "qqq_databaseAttachment" 'string)
    qqq_attachmentData = car( errsetstring( qqq_databaseAttachmentID -> data))
    qqq_attachmentData -> formFields = qqq_associatedListToAssociatedTable( qqq_attachmentData -> formFields "formFields" nil)

    ;function to convert assoc. list to assoc. table
    defun( qqq_associatedListToAssociatedTable ( qqq_associatedListToConvert qqq_associatedTablePrintName qqq_associatedTableDefaultValue)
    let( ( qqq_tmpTable)
    qqq_tmpTable = makeTable( qqq_associatedTablePrintName qqq_associatedTableDefaultValue)
    foreach( qqq_element qqq_associatedListToConvert
    qqq_tmpTable[ car( qqq_element)] = last( qqq_element)
    )))

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
Cadence Guidelines

Community Guidelines

The Cadence Design Communities support Cadence users and technologists interacting to exchange ideas, news, technical information, and best practices to solve problems and get the most from Cadence technology. The community is open to everyone, and to provide the most value, we require participants to follow our Community Guidelines that facilitate a quality exchange of ideas and information. By accessing, contributing, using or downloading any materials from the site, you agree to be bound by the full Community Guidelines.

© 2025 Cadence Design Systems, Inc. All Rights Reserved.

  • Terms of Use
  • Privacy
  • Cookie Policy
  • US Trademarks
  • Do Not Sell or Share My Personal Information