• 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 PCB Editor
  3. how to retain variable during skill session

Stats

  • Replies 6
  • Subscribers 160
  • Views 13753
  • Members are here 0
More Content

how to retain variable during skill session

Ejlersen
Ejlersen over 13 years ago

Hi

I've got a skill program that parses data to a new .dra file.

So the program actually saves the current session then start a new dra file and after it is finished with the dra file it reloads the original session.

I'm however experiencing that variables get lost so when I return to the original session. Is there any way to prevent this from happening.

At the same time I would like to clear the memory for all variables when the program terminates.

Best regards

Ole

  • Sign in to reply
  • Cancel
  • eDave
    eDave over 13 years ago
    Hi Ole, How are you closing and opening each session? I jump between designs in several utilities and don't lose the variables. Of course you will lose the dbid values. Cheers, Dave
    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • Ejlersen
    Ejlersen over 13 years ago

    Hi Dave

    Somone (maybe you) once posted the defun AFn_OpenDesign (code further down) which I use together with the following code

    currentDesign = axlCurrentDesign()
    state = axlSaveEnable()
    if(upperCase(axlDesignType(nil)) == "LAYOUT" then
      tempDesignName = "ns_temp.brd"
      if(isFile("ns_temp.brd") then deleteFile("ns_temp.brd"))
    else
      tempDesignName = "ns_temp.dra"
      if(isFile("ns_temp.dra") then deleteFile("ns_temp.dra"))
    )
    axlSaveDesign(?design tempDesignName, ?mode "nocheck", ?noMru t)
    AFn_OpenDesign(?design strcat(draName, ".dra"), ?mode "wf", ?noMru t, ?noConfirm t, ?forceNew t)
    axlSetSymbolType("shape")
    axlDBChangeDesignUnits("millimeters" 3) 

    Some code to generate .dra file

    axlDBChangeDesignExtents(extents)
    axlSaveDesign(?noMru t)
    AFn_OpenDesign(?design tempDesignName, ?mode "wf", ?noMru t, ?noConfirm t)
    axlRenameDesign(currentDesign)
    deleteFile(tempDesignName)
    axlSaveEnable(state)

    ----

    defun( AFn_OpenDesign (@key design, (mode "w"), noMru, noConfirm, forceNew)
     let((noconfirmStatus, result)
      when(noConfirm, noconfirmStatus = axlGetVariable("NOCONFIRM"), axlSetVariable("NOCONFIRM", t))
      when(forceNew && isFile(design), deleteFile(design))
      result = if(noMru && axlVersion('version) >= 16.0
       then axlOpenDesign(?design design, ?mode mode, ?noMru t)
       else axlOpenDesign(?design design, ?mode mode)
      )
      when(noConfirm, if(noconfirmStatus then axlSetVariable("NOCONFIRM", t) else axlUnsetVariable("NOCONFIRM")))
      result
    ))

    Best regards

    Ole

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • Ejlersen
    Ejlersen over 13 years ago

    Hi Dave

    Debugging actually shows when it happens.

    Variable is fine before calling AFn_OpenDesign defun in previous message.

    I can actually pin point it down to the command

      axlOpenDesign(?design design, ?mode mode, ?noMru t)

    After the defun call the variable is nil, so it happens during the call of that defun.

    Best regards

    Ole

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • Ejlersen
    Ejlersen over 13 years ago

    Hi

    I keep getting wiser. saving the variable into another temp_var = nextline and then reassigning after this line works.

    So it does not clear all variables, but apparently the variable named nextline.

    Does it matter whether a variable is put into a let statement or not? Currently my variables are not for test purposes.

    Best regards

    Ole

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • eDave
    eDave over 13 years ago
    Hi Ole, Yes, it very much matters whether a variable is inside a let statement. Variables inside a let statement will be undefined outside it. I prefer not to let any of my variables "leak" outside a function. If I want a variable to be global I use the defvar statement and identify the variable with a prefix that highlights it. I use the sklint utility to verify my code. Regards, Dave
    • 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