• 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. Custom IC SKILL
  3. How can a concatenated string be transformed into a variable...

Stats

  • Replies 4
  • Subscribers 151
  • Views 67
  • Members are here 0

How can a concatenated string be transformed into a variable name?

SZ20260803361
SZ20260803361 22 hours ago

I want to set a variable name that can change over time. For example:
item=""
lists=setof(i parseString(getCurrentTime() "") i!) =" "&&i! =":")
foreach(elem lists

item=strcat(item elem)
)
I received the item with the code "Aug201706212026".
I want to replace the "item" in the variable name "a_item" with "Aug201706212026", so that the final variable name becomes "a_Aug201706212026". How can I do this? I tried using `setq(stringToSymbol(strcat("a_" item)) 5)`, but this caused an error. How should I proceed?

  • Sign in to reply
  • Cancel

Top Replies

  • Andrew Beckett
    Andrew Beckett 19 hours ago +1
    This is almost certainly not what you want to do, because creating different variable names on the fly usually means you should be creating a different data structure - e.g. a hash table indexed by the…
  • Andrew Beckett
    Andrew Beckett 19 hours ago

    This is almost certainly not what you want to do, because creating different variable names on the fly usually means you should be creating a different data structure - e.g. a hash table indexed by the date rather than a unique variable name. However, if you really want to do this (the wrong way in my opinion), then taking your code:

    item=""
    lists=setof(i parseString(getCurrentTime() "") i!=" " && i!=":")
    foreach(elem lists
        item=strcat(item elem)
    )

    (I assume you used some kind of optical character recognition because it had some spurious parentheses) then you could do:

    set(concat("a_" item) 5)

    you can retrieve it with:

    symeval(concat("a_" item))

    A cleaner (more efficient in terms of creating garbage that needs collecting) way of building the variable name would be to do:

    cleanup=pcreCompile("[ :]")
    varName=concat("a_" pcreReplace(cleanup getCurrentTime() "" 0))

    However, if you creating a number of these, I'd use a hash table (using makeTable) as I mentioned before.

    Regards,

    Andrew

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Cancel
  • SZ20260803361
    SZ20260803361 4 hours ago in reply to Andrew Beckett

    Dear Mr. Beckett,

    Thank you very much for your prompt, professional and informative replies. I have tried both of your proposed methods, and both work as I expected. I will test the hash‑table approach you suggested later. I will elaborate on why I require dynamic variable names based on a small ongoing project I am developing, and seek your advice on the issues I have encountered during development.

    Best regards,
    Steve

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • SZ20260803361
    SZ20260803361 3 hours ago in reply to Andrew Beckett

    This project is developed to meet requirements from the layout team. They need a persistently‑pinned UI panel that can be activated by clicks at any time. For this purpose, I planned to use dockWindow so that the panel can be docked inside the PTE frame. However, I have run into multiple issues during development, as listed below:

    1. With my current implementation, the dock window is only created for a single session window. My expectation is to make this dock window available for multiple session windows simultaneously.
    2. How can I completely delete an appForm from memory? I create an appForm via hiCreateLayoutForm, then construct the dock window with:

    dock_W = hiCreateDockWindow(
                           ?appType "layout"
                           ?widgetType "form"
                           ?form appForm )

    Afterwards I render the dock window with:

    foreach( n ns hiDockWindow( ?window dock_W ?session n ) )

    My intention is to automatically unset the global variable appForm after the dock window is generated. When creating the dock window for another session window, I would recreate the global appForm variable.

    1. If fully destroying appForm is not feasible, I considered generating time‑dependent unique variable names. Each time a new session window opens, a brand‑new global variable such as appForm_currentTime would be generated to avoid naming conflicts caused by re‑using the same variable appForm.

    This is the motivation behind my post.

    There are three global variables in my codebase: appForm, layoutForm_pte and dock_W.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • SZ20260803361
    SZ20260803361 2 hours ago in reply to Andrew Beckett

    Source code is shown below

    load_form.il:

    (let (load_en reload_en)

    procedure(load_form()
    cond(
    (dock_W
    load_en = nil
    reload_en = t
    )
    (t
    load_en = t
    reload_en = nil
    )
    )

    layoutForm_pte~>loadpte_button~>enabled = load_en
    layoutForm_pte~>reloadpte_button~>enabled = reload_en

    hiDisplayForm('layoutForm_pte)
    )

    )




    load_procedure.il:

    (let (a b ns)

    procedure(loadpte(a)
    load("test_layout_demand.il")
    hiFormClose(a)
    layoutForm_pte~>loadpte_button~>enabled = nil
    layoutForm_pte~>reloadpte_button~>enabled = t
    )

    procedure(reloadpte(a)
    b=hiDockWindow(
    ?window dock_W
    )

    if(b==t then
    hiFormClose(a)
    else
    dock_W=hiCreateDockWindow(
    ?appType "layout"
    ?widgetType "form"
    ?form appForm
    )

    ns=hiGetWindowList('session)

    foreach( n ns
    hiDockWindow(
    ?window dock_W
    ?session n
    )
    )
    )
    )
    )





    gui_contain.il:

    (let (load_en reload_en loadpte_button reloadpte_button loadpte reloadpte boxLayout_ver )

    dock_W = nil
    load_en = t
    reload_en = nil


    loadpte_button = hiCreateButton(
    ?name 'loadpte_button
    ?buttonText "Press this button for initial loading:"
    ?callback "loadpte(layoutForm_pte)"
    ?enabled load_en
    )


    reloadpte_button = hiCreateButton(
    ?name 'reloadpte_button
    ?buttonText "Click to Reload: "
    ?callback "reloadpte(layoutForm_pte)"
    ?enabled reload_en
    )

    boxLayout_ver = hiCreateVerticalBoxLayout(
    'boxLayout_ver
    ?items list(loadpte_button reloadpte_button)
    )

    layoutForm_pte = hiCreateLayoutForm(
    'layoutForm_pte "LOAD PTE" boxLayout_ver
    )

    )

    test_layout_demand.il:

    (let (addMosW_string addMosW_button gridLayout boxLayout loadpte_button reloadpte_button boxLayout_ver ns)


    addMosW_string = hiCreateStringField(
    ?name 'addMosW_string
    ?prompt "M1_width: "
    ?defValue "1.5"
    )


    addMosW_button = hiCreateButton(
    ?name 'addMosW_button
    ?buttonText "apply"
    ?callback "(AddMosM1)"
    )

    gridLayout = hiCreateGridLayout( 'gridLayout
    ?items (list
    list( addMosW_string 'row 0 'col 0 )
    list( addMosW_button 'row 0 'col 1 )
    list( 'col_stretch 0 1)
    list( 'col_stretch 1 0)
    )
    )

    boxLayout = hiCreateHorizontalBoxLayout(
    'boxLayout
    ?items list(gridLayout)
    )


    appForm = hiCreateLayoutForm(
    'appForm "LAYOUT_PTE" boxLayout
    )


    procedure(AddMosM1()
    let((cv objs metal1 temp temp1 shapes x y ux uy xy row column transform M1_width)
    M1_width = evalstring(appForm~>addMosW_string~>value)
    cv = geGetEditCellView()
    objs = geGetSelSet()
    foreach(obj objs
    transform = nil
    if(obj~>objType == "inst" then transform = list(obj~>transform));end if
    if(obj~>objType == "mosaic" then
    x = xCoord(obj~>xy)
    y = yCoord(obj~>xy)
    ux = obj~>uX
    uy = obj~>uY
    row = obj~>rows
    column = obj~>columns
    for(a 0 row-1
    for(b 0 column-1
    case(car(obj~>tileArray)
    ("R0" || "MXR90" xy = list(x+a*ux : y+b*uy))
    ("R90" || "MY" xy = list(x-a*ux : y+b*uy))
    ("R0" || "MXR90" xy = list(x+a*ux : y-b*uy))
    ("R0" || "MXR90" xy = list(x-a*ux : y-b*uy))
    );end case
    transform = append1(transform list(car(xy) car(obj~>tileArray) 1.0))
    );end for
    );enf for
    );end if
    shapes = obj~>master~>shapes
    foreach(shape shapes
    if(car(shape~>lpp) == "M1" && cadr(shape~>lpp) == "drawing"
    then
    foreach(trans transform
    metal1 = dbCopyFig(shape cv trans)
    temp = leConvertPolygonToPath(metal1)
    temp~>width = M1_width
    );foreach
    );if
    );foreach
    );foreach
    );let
    );proc


    dock_W=hiCreateDockWindow(
    ?appType "layout"
    ?widgetType "form"
    ?form appForm
    )

    ns=hiGetWindowList('session)

    foreach( n ns
    hiDockWindow(
    ?window dock_W
    ?session n
    )
    )
    )

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

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.

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

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