String manipulation

Discussion in 'Cadence' started by eric.d.fitzsimmons, May 19, 2009.

  1. Hi All,

    What is the best way to remove the quotes from a variable.

    For example
    "window:4"

    needs to be

    window:4

    So far I have been using car, cadr, etc but this won't get me there
    for this.

    Thank you in advance,
    Eric
     
    eric.d.fitzsimmons, May 19, 2009
    #1
  2. eric.d.fitzsimmons

    Riad KACED Guest

    Hi Eric,

    car and cadr functions operate on lists. "window:4" is a string.
    You may try stringToSymbol instead.

    Cheers,
    Riad.
     
    Riad KACED, May 19, 2009
    #2
  3. eric.d.fitzsimmons

    Guest Guest

    Are you sure the quotes are actually there? For example, if you do:

    X = "window:4"

    The X is a string and the value is "window:4", but the quotes just indicate
    that the value is a string and aren't actually part of the string.

    For example:
    window:4
    t

    If you set the value of X to a string that includes the quotes, then they'll
    show up as extra quotes in println, but just as you show in printf:
    "window:4"
    t

    If the quotes are truly there and you know they are the first and last
    character of the string you can remove them with substring():
    "window:4"

    -Pete Zakel
    ()

    "...computer hardware progress is so fast. No other technology since
    civilization began has seen six orders of magnitude in performance-price
    gain in 30 years."
    -Fred Brooks, Jr.
     
    Guest, May 19, 2009
    #3
  4. eric.d.fitzsimmons

    Guest Guest

    P.S. If you want a symbol, then use concat, but I don't think that's what you
    really want. I suspect you are asking the wrong question.

    I think you want the windowId (which is what window:4 represents). Converting
    "window:4" to a symbol won't get you that.

    If you want the window ID of window 4, then you do:
    window:4

    MyWinID will now contain a window ID for window 4, but the value is NOT
    "window:4" -- that's just the print representation of the windowId.

    -Pete Zakel
    ()

    "Anyone can hold the helm when the sea is calm."

    -Publilius Syrus
     
    Guest, May 19, 2009
    #4
  5. Hi all,

    Yes, I am confused I am new to skill ;)

    I am getting the window number on start up of a script with a form,
    but would like to give the ability to change the window number and I
    think I can do that with hiSetCurrentWindow. So, for the form I am
    trying to take the current window number and place it in the form, but
    when I do EFInstanceNetsForm->EFWindowid->value = EFwindow_number I
    get an error....

    *Error* ilGetString: arg must be symbol or string - window:85

    I think I just want the "85" since
    EFInstanceNetsForm->EFWindowid->value = "85"

    I noticed also hiSetCurrentWindow(EFWindowid) works and
    hiSetCurrentWindow(window(85)) works.

    I appreciate very much both posts.

    Thank you for any help in advance,
    Eric





    EFwindow_number=hiGetCurrentWindow()

    EFWindowid=hiCreateIntField(
    ?name 'EFWindowid
    ?prompt "Window Number"
    ?value ""
    )

    EFDualMode = hiCreateRadioField(
    ?name 'EFDualMode
    ?prompt "Sort data by?"
    ?value "None"
    ?defValue "None"
    ?choices list("None" "Instance" "Cellname" "InstTerm" "Net")
    ?callback
    list("case(EFInstanceNetsForm->EFDualMode->value
    (\"None\"
    EFInstanceNetsForm->EFSortBy->editable = nil
    )
    (\"Instance\"
    EFInstanceNetsForm->EFSortBy->editable = t
    )
    (\"Cellname\"
    EFInstanceNetsForm->EFSortBy->editable = t
    )
    (\"InstTerm\"
    EFInstanceNetsForm->EFSortBy->editable = t
    )
    (\"Net\"
    EFInstanceNetsForm->EFSortBy->editable = t
    )
    )");end case
    )

    EFSortBy = hiCreateStringField(
    ?name 'EFSortBy
    ?prompt "Instance, Net, Cellname or InstTerm"
    ?editable nil
    ?value ""
    )

    EFSelectOrProbe = hiCreateRadioField(
    ?name 'EFSelectOrProbe
    ?prompt "Probe or Schematic Select"
    ?value "Probe"
    ?defValue "Probe"
    ?choices list("Probe" "Select")
    )

    EFDataSingleClick = hiCreateRadioField(
    ?name 'EFDataSingleClick
    ?prompt "Data type to perform Probe or Select"
    ?value "Net"
    ?defValue "Net"
    ?choices list("Instance" "Cellname" "InstTerm" "Net")
    )

    EFDeselectCurr = hiCreateButtonBoxField(
    ?name 'EFDeselectCurr
    ?prompt " "
    ?choices '("Undo" "Clear" "Auto Sort" "Refresh" "Reverse")
    ?callback '("EFDeselectCurrentCB()" "EFDeselectAllCB()"
    "EFAutoSortCB()" "EFRefreshForm()" "EFReverseList()")
    )

    EFNetsBox = hiCreateListBoxField(
    ?name 'EFListBoxField
    ?prompt " "
    ?choices EFNet_list
    ?value nil
    ?multipleSelect nil
    ?changeCB "EFprobe()"
    ?doubleClickCB "EFprobeandzoom()"
    ?CBOnReselect t
    ?numRows length(EFNet_list)
    )

    ;;; defines the form

    hiCreateAppForm(
    ?name 'EFInstanceNetsForm
    ?formTitle "Instance Viewer. Data Format:Instance.Cellname.Term
    (Pin) - Net Name"
    ?callback "EFSortExecutionCB(hiGetCurrentForm())"
    ?fields
    list(
    EFWindowid
    EFDualMode
    EFSortBy
    EFSelectOrProbe
    EFDataSingleClick
    EFDeselectCurr
    EFNetsBox
    )
    ?help ""

    ) ; hiCreateAppForm

    hiDisplayForm(EFInstanceNetsForm)

    );procedure
     
    eric.d.fitzsimmons, May 21, 2009
    #5
  6. eric.d.fitzsimmons

    Guest Guest

    That gives you a window ID, not the window number.

    To get the window number, you can get the windowNum property from the windowID.

    To convert to a string, you can use sprintf:

    EFwindow_number = sprintf( nil "%d" get(hiGetCurrentWindow() 'windowNum))

    Now EFwindow_number will contain the window number as a string.

    To get the number as a number, just use the get function:

    get(hiGetCurrentWindow() 'windowNum)

    A shorter form of this is to use "->":

    hiGetCurrentWindow()->windowNum

    which is another way to specify get(). You can use the window number to in
    turn get the window ID:
    window:85

    -Pete Zakel
    ()

    "Vital papers will demonstrate their vitality by spontaneously moving
    from where you left them to where you can't find them."
     
    Guest, May 22, 2009
    #6
  7. Thank you both for your wonderful help, I was able to accomplish what
    I set out to do.
    Eric
     
    eric.d.fitzsimmons, May 27, 2009
    #7
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.