• 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 to perform callback from browse button

Stats

  • Locked Locked
  • Replies 9
  • Subscribers 143
  • Views 11078
  • Members are here 0
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

how to perform callback from browse button

saurabh96
saurabh96 over 3 years ago

Hi there,

i have made a string box and browse button

path_enter=hiCreateStringField(
?name 'path_enter
?defValue "/xyz/cadence/2022.12.22"

)

browse_Entry=hiCreateButton(
?name 'browse_Entry
?buttonText "Browse..."
?callback "ddsFileBrowseCB(hiGetCurrentForm() 'path_enter \"\" 'directoryOnly)"
?callback "PathCB(hiGetCurrentForm())")

procedure(PathCB(form)
case(form->Entry->value
("Test"
unless(boundp('MyInCallback) && MyInCallback
let((pat (MyInCallback t))
pat=pcreCompile("/[^/]*/[^/]*/[^/]*/[^/]*")
form->path_enter->value=strcat("/xyz/cadence" pcreReplace(pat form->path_enter->value "" 1))
)
)
)
)
)

I want that above procedure (PathCB(form) only works when i press the browse button

so how can we use two callbacks one for directory surfing and other for procedure calling using browse button.

Please guide.
Thanks in advance.

  • Cancel
Parents
  • Andrew Beckett
    Andrew Beckett over 3 years ago

    You asked the same question a couple of months ago, and I gave a suggestion there (to use hiDisplayFileDialog).

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • saurabh96
    saurabh96 over 3 years ago in reply to Andrew Beckett

    Hello Andrew,
    Yes i remembered...but i didn't get it.
    Can you please help me with example or test-case

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Andrew Beckett
    Andrew Beckett over 3 years ago in reply to saurabh96

    Over many months you've had countless examples provided on how to write callback functions and create form and form fields. I would have expected it ought to be clear enough by now (and I've also suggested attending the free online training too). I'm not going to write a full example, but it would be this:

    create a "browse" button - button callback will call hiDisplayFileDialog() with appropriate arguments and a callback
    create string field that you can type in characters; this doesn't need a callback

    The callback for the hiDisplayFileDialog will do whatever processing you want on the selected file and then fill in the string field. This way the path processing only happens when you've used the browse button.

    Andrew

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
Reply
  • Andrew Beckett
    Andrew Beckett over 3 years ago in reply to saurabh96

    Over many months you've had countless examples provided on how to write callback functions and create form and form fields. I would have expected it ought to be clear enough by now (and I've also suggested attending the free online training too). I'm not going to write a full example, but it would be this:

    create a "browse" button - button callback will call hiDisplayFileDialog() with appropriate arguments and a callback
    create string field that you can type in characters; this doesn't need a callback

    The callback for the hiDisplayFileDialog will do whatever processing you want on the selected file and then fill in the string field. This way the path processing only happens when you've used the browse button.

    Andrew

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
Children
  • saurabh96
    saurabh96 over 3 years ago in reply to Andrew Beckett

    thanks for help!

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • saurabh96
    saurabh96 over 3 years ago in reply to saurabh96

    Hi Andrew/everyone.

    I tried a test-case below...its working correct but the file browser is coming as soon as load the file without pressing browse button...can you please guide what the glitch?

    path_enter = hiCreateStringField(
    ?name 'path_enter
    ?defValue "/xyz/cadence/2021.12.22"
    )

    Entry = hiCreateFormButton(
    ?name 'Entry
    ?buttonText "Browse..."
    ?callback hiDisplayFileDialog(
    ?dialogName 'myFileDialog
    ?callback "MyTrimPathCB"
    )
    )


    procedure(MyTrimPathCB(form)
    unless(boundp('MyInCallback) && MyInCallback
    let((pat (MyInCallback t))
    pat=pcreCompile("/[^/]*/[^/]*/[^/]*/[^/]*")
    form->path_enter->value=strcat("/xyz/cadence" pcreReplace(pat form->path_enter->value "" 1))
    )
    )
    )


    hiCreateAppForm(
    ;; the form variable is global, this is required
    ?name 'myTestForm
    ?formTitle "Browser test form"
    ?fields list(
    list(path_enter 0:0 420:30 50)
    list(Entry 430:0 70:30)
    )
    )
    hiDisplayForm(myTestForm)
    ); let

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • skillUser
    skillUser over 3 years ago in reply to saurabh96

    Hi Saurabh,

    Put the hiDisplayFileDialog callback in double quotes, then it will get activated when the button is pressed, rather than when the code is loaded/read.

    Best regards,

    Lawrence.

    • Cancel
    • Vote Up +1 Vote Down
    • Cancel
  • saurabh96
    saurabh96 over 3 years ago in reply to skillUser

    Thank you Lawrence!

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • saurabh96
    saurabh96 over 3 years ago in reply to skillUser

    Hello Lawrence,
    am getting error as Error* MyTrimPathCB: too many arguments
    for the below script-

    path_enter=hiCreateStringField(
    ?name 'path_enter
    ?defValue "/xyz/cadence/2021.12.22"
    )

    Entry=hiCreateButton(
    ?name 'Entry
    ?buttonText "Browse..."
    ?callback strcat("hiDisplayFileDialog(?dialogName 'Select"
    " ?mode 'directoryOnly"
    " ?callback \"MyTrimPathCB\")")
    )

    procedure(MyTrimPathCB(form)
    unless(boundp('MyInCallback) && MyInCallback
    let((pat (MyInCallback t))
    pat=pcreCompile("/[^/]*/[^/]*/[^/]*/[^/]*")
    form->path_enter->value=strcat("/xyz/cadence" pcreReplace(pat form->path_enter->value "" 1))
    )
    )
    )
    )
    )

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Andrew Beckett
    Andrew Beckett over 3 years ago in reply to saurabh96

    Seriously? You can't diagnose that after all these posts about callbacks? Please read the documentation on hiDisplayFileDialog - it shows that the callback function needs to be defined to take 2 arguments (or 3 if ?userData is passed to hiDisplayFileDialog). Your callback only has one argument which is the form (the arguments need to be the dialog itself and the event).

    Because I can't bear this going back and forth longer, here's a small example - showing a clean way of passing the form to the dialog box callback so that your code can update the main form. Call MyDisplayForm() to launch the example form.

    procedure(MyCreateForm()
      hiCreateLayoutForm(
        'MyDummyForm
        "Example Form for Forum"
        hiCreateFormLayout(
          'MyLayout
          ?items
            list(
              hiCreateStringField(
                ?name 'filePath
                ?prompt "Path"
              )
              hiCreateButton(
                ?name 'browse
                ?buttonText "Browse"
                ?callback "MyLaunchFileDialog(hiGetCurrentForm())"
              )
            )
        )
      )
    )
    
    procedure(MyDisplayForm()
      hiDisplayForm(MyCreateForm())
    )
    
    procedure(MyFileDialogCB(dialog event formName)
      ; the user data has to be passed as a symbol, so 
      ; use symeval to get the form itself
      let(((form symeval(formName)))
        printf("EVENT IS %L\n" event)
        when(event=='done
          form->filePath->value=car(hiFileDialogSelection(dialog))
          ; here is where you'd call your TrimCB function
        )
      )
    )
    
    procedure(MyLaunchFileDialog(form)
      hiDisplayFileDialog(
        ?dialogName 'MyFileSelect
        ?mode 'directoryOnly
        ?callback "MyFileDialogCB"
        ?userData form->hiFormSym
      )
    )
    • Cancel
    • Vote Up 0 Vote Down
    • 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.

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

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