Dear all,
I have a script which allows the user to select a cell view from the library manager, without opening prompting the user. The user selects, in first place, the cell view from the library manager and only then the user should press the button for the script to run. As this is counter-intuitive for some, I would like to have the opposite. When user clicks the "select" button it will open the lib manager, so the user can choose the cell view.
This is described in Cadence documentation, and an example is given for the "ddsUpdateSyncWithForm" command. However this method uses three text boxes (string fields) which get the values for lib, cell and view. But in my case, I would like to use a single text box instead of three, and I can't do it. I've tried to pass the values (lib,cell,view) with variables but it didn't work.
Second question. In the code, you can see that I have to identical "procedures". The only difference is that one is executed when button 1 is pressed and the second when button 2 is pressed. How can I detect which button has been pressed, so I can do a generic function for both.
Thanks in advance.
Best regards,
José
My code
;==============================================================================
;============================== main function ================================
;==============================================================================
procedure(main()
let((retValue)
; Create the form
retValue=CreateMainForm()
putprop( 'settingsForm 'myHelpCB 'hiHelpAction) ; Customize the information displayed by the Help button
declare(selectedViewArray[2])
selectedViewArray[0]=""
selectedViewArray[1]=""
);end let
) ; end procedure
;==============================================================================
;=============== Display main Form - Create Main form" =======================
;==============================================================================
procedure(CreateMainForm()
let((label1 doneButton settingsForm cellView1 cellView2 selectButton1 selectButton2 selectButton3 sep1)
; template loading and saving
label1=hiCreateLabel(
?name 'label1
?labelText "SUMMARY FILE'S COMPARISON"
?justification 'center
)
sep1=hiCreateSeparatorField(?name 'sep1)
cellView1 = hiCreateStringField(
?name 'cellView1
?prompt "Summary file 1 :"
?value "Please select a summary file"
?editable nil
)
cellView2 = hiCreateStringField(
?name 'cellView2
?prompt "Summary file 2 :"
?value "Please select a summary file"
?editable nil
)
selectButton1=hiCreateButton(
?name 'selectButton1
?buttonText "Select"
?callback "cb_button1_pressed()"
)
selectButton2=hiCreateButton(
?name 'selectButton2
?buttonText "Select"
?callback "cb_button2_pressed()"
)
selectButton3=hiCreateButton(
?name 'selectButton3
?buttonText "Compare !"
?callback "cb_button3_pressed()"
)
hiCreateAppForm(
?name 'settingsForm
?formTitle "Compare summary files"
;?callback list("testOK()" "testCancel()")
?buttonLayout 'Close
?fields list(
list(label1 10:10 600:0 40)
list(sep1 0:35 600:0)
list(cellView1 15:50 500:30 100)
list(cellView2 15:85 500:30 100)
;list(cellView2 300:8 55:30)
;list(selectLabel 15:70 45:20 200)
list(selectButton1 520:50 50:30)
list(selectButton2 520:85 50:30)
list(selectButton3 120:120 90:30)
) ; end list
) ; create form
hiDisplayForm(settingsForm) ; Display form
); end let
); end procedure
;==============================================================================
;=============== Select button1 pressed "cb_button1_pressed" ====================
;==============================================================================
procedure(cb_button1_pressed()
let((selectedView libName cellName viewName pathToSelectedView)
;printf("Test!")
selectedView=ddsGetLibManLCV() ; list containing the the "lib", "cell" and "view", when clicked in lib manager
; separate the list into different variables
libName=nth(0 selectedView)
cellName=nth(1 selectedView)
viewName=nth(2 selectedView)
if(rexMatchp("small_sum" viewName)==t then ; checks if "small_sum" exist in the name of the cell view
; outputs the path to the cell view in the list
pathToSelectedView=ddGetObjReadPath(ddGetObj(libName cellName viewName "*"))
; creates a string in the format "cellname -> viewName" and copies it to the textbox
sprintf(cellViewStr "\n%s -> %s" cellName viewName)
get(settingsForm settingsForm->cellView1->value=cellViewStr)
;printf("Button 1 pressed\n")
;printf(pathToSelectedView)
selectedViewArray[0]=pathToSelectedView
else
dispMessage("Cellview must be text !")
) ;end if
) ;end let
) ;end procedure
;==============================================================================
;=============== Select button2 pressed "cb_button2_pressed" ====================
;==============================================================================
procedure(cb_button2_pressed()
let((selectedView libName cellName viewName pathToSelectedView)
;printf("Test!")
selectedView=ddsGetLibManLCV() ; list containing the the "lib", "cell" and "view", when clicked in lib manager
; separate the list into different variables
libName=nth(0 selectedView)
cellName=nth(1 selectedView)
viewName=nth(2 selectedView)
if(rexMatchp("small_sum" viewName)==t then
; outputs the path to the cell view in the list
pathToSelectedView=ddGetObjReadPath(ddGetObj(libName cellName viewName "*"))
; creates a string in the format "cellname -> viewName" and copies it to the textbox
sprintf(cellViewStr "\n%s -> %s" cellName viewName)
get(settingsForm settingsForm->cellView2->value=cellViewStr)
;printf("Button 2 pressed\n")
;printf(pathToSelectedView)
selectedViewArray[1]=pathToSelectedView
else
dispMessage("Cellview must be text !")
) ;end if
) ;end let
) ;end procedure
;==============================================================================
;=============== Compare Button "cb_button3_pressed" ====================
;==============================================================================
procedure(cb_button3_pressed()
let((str)
; checks if both textboxes aren't empty
if(cellView1->value!="Please select a summary file" && cellView2->value!="Please select a summary file" then
str=sprintf(test "tkdiff %s %s" selectedViewArray[0] selectedViewArray[1]) ; string having the full command to be executed in the shell
csh(str) ; executes the command on linux shell
; Re-initialise text boxes after closing tkdiff editor
get(settingsForm settingsForm->cellView1->value="Please select a summary file")
get(settingsForm settingsForm->cellView2->value="Please select a summary file")
else
dispMessage("Please select two views to be compared !!" )
) ;end if
) ;end let
) ;end procedure
;==============================================================================
;===================== Display Message "dispMessage" =========================
;==============================================================================
procedure(dispMessage( message )
hiDisplayAppDBox(
?name gensym('mybox)
?dboxBanner "Message"
?dboxText message
?dialogStyle 'modeless
?dialogType hicMessageDialog
?buttonLayout 'Close
) ; hiDisplayAppDBox
); End procedure
;==============================================================================
;===================== Building myHelpCB funtion =============================
;==============================================================================
procedure(myHelpCB(arg1 arg2 arg3 arg4)
let((helpStrMsg)
; Help Message
helpStrMsg="\n\
DESCRIPTION\n\
\tSummary file 1 - first summary view selected from the lib manager\n\
\tSummary file 2 - second summary view selected from the lib manager\n\
\t\"Select\" buttons- retrieve the name of the selected views from the lib manager\n\
\t\"Compare\" button - triggers \"tkdiff\" from linux in order to compare both views\n\n\
SUMMARY: \n\
\t1 - Click on the desired cell view from the \"Library manager\"\n\
\t2 - Click the correspondent \"Select\" button.\n\
\t3 - Hit the \"Compare\" button.\n"
hiDisplayAppDBox(
?name gensym("dbox")
?dboxBanner "compViews script HELP"
?dboxText helpStrMsg
?dialogType hicInformationDialog
?dialogStyle 'modeless
?buttonLayout 'Close
)
)
)