String manipulation

Guest
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
 
Hi Eric,

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

Cheers,
Riad.
 
In article <c4ca500b-e500-408a-817e-6d7b56d76718@x1g2000prh.googlegroups.com> eric.d.fitzsimmons@gmail.com writes:
Hi All,

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

For example
"window:4"

needs to be

window:4
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:

X = "window:4"
"window:4"
println(X)
"window:4"
nil
printf("%s\n" X)
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:

X = "\"window:4\""
"\"window:4\""
println(X)
"\"window:4\""
nil
printf("%s\n" X)
"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():

X
"\"window:4\""
Y = substring( X 2 strlen(X) - 2 )
"window:4"

-Pete Zakel
(phz@seeheader.nospam)

"...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.
 
In article <4a12f5b5$1@news.cadence.com> pxhxz@cadence.com (Pete nospam Zakel) writes:
In article <c4ca500b-e500-408a-817e-6d7b56d76718@x1g2000prh.googlegroups.com> eric.d.fitzsimmons@gmail.com writes:
Hi All,

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

For example
"window:4"

needs to be

window:4

Are you sure the quotes are actually there? For example, if you do:
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:

MyWinID = window(4)
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
(phz@seeheader.nospam)

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

-Publilius Syrus
 
On May 19, 2:17 pm, px...@cadence.com (Pete nospam Zakel) wrote:
In article <4a12f5b...@news.cadence.com> px...@cadence.com (Pete nospam Zakel) writes:

In article <c4ca500b-e500-408a-817e-6d7b56d76...@x1g2000prh.googlegroups..com> eric.d.fitzsimm...@gmail.com writes:
Hi All,

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

For example
"window:4"

needs to be

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

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:

MyWinID = window(4)

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
 (p...@seeheader.nospam)

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

                        -Publilius Syrus
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
 
In article <a6af4de9-ac41-493d-a748-6382d8edf049@y10g2000prc.googlegroups.com> eric.d.fitzsimmons@gmail.com writes:

EFwindow_number = hiGetCurrentWindow()
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:

EFwindow_number = hiGetCurrentWindow()->windowNum
85
EFwindow_ID = window(EFwindow_number)
window:85

-Pete Zakel
(phz@seeheader.nospam)

"Vital papers will demonstrate their vitality by spontaneously moving
from where you left them to where you can't find them."
 
On May 21, 8:15 pm, px...@cadence.com (Pete nospam Zakel) wrote:
In article <a6af4de9-ac41-493d-a748-6382d8edf...@y10g2000prc.googlegroups..com> eric.d.fitzsimm...@gmail.com writes:

EFwindow_number = hiGetCurrentWindow()

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:

EFwindow_number = hiGetCurrentWindow()->windowNum
85
EFwindow_ID = window(EFwindow_number)

window:85

-Pete Zakel
 (p...@seeheader.nospam)

"Vital papers will demonstrate their vitality by spontaneously moving
 from where you left them to where you can't find them."
Thank you both for your wonderful help, I was able to accomplish what
I set out to do.
Eric
 

Welcome to EDABoard.com

Sponsor

Back
Top