• 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. Allegro X PCB Editor
  3. Calling an user defined function

Stats

  • Replies 2
  • Subscribers 158
  • Views 13089
  • Members are here 0
More Content

Calling an user defined function

kumarsanj
kumarsanj over 8 years ago

Hi,

I am trying to create an user define function to return MM DD YYYY from getCurrentTime(). Below is the program for the same.

procedure( DATE()

DATE_LIST = parseString( getCurrentTime())
MM = nthelem( 1 DATE_LIST )
DD = nthelem( 2 DATE_LIST )
YYYY = nthelem( 4 DATE_LIST )
return_list = printf("%s/%s/%s" MM DD YYYY)

)

With the above function, I want to display the date when ever the DATE() function is called. However t is being return once I call the DATE() Function. for the below code

File=outfile("readme.txt" "w")

fprintf(File "DATE       :   %s\n\n" DATE())

close(File)

Any Idea how the date in the above prescribed format can be returned?

Thanks,

Sanjeev

  • Sign in to reply
  • Cancel
  • B Bruekers
    B Bruekers over 8 years ago
    Use sprintf() to 'print' a formatted string to a variable.
    You don't need to assign the sprintf() to a variable, the returned value is the string, and since it is the last statement this value is returned to the procedure.
    Further you can use car, cadr etc to get list elements. It is much faster than nth() if it is called a lot of times.

    procedure( DATE()
    let( (DATE_LIST)
    DATE_LIST = parseString( getCurrentTime())
    sprintf(nil "%s/%s/%s" car(DATE_LIST) cadr(DATE_LIST) cadddr(DATE_LIST))
    )
    )
    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • kumarsanj
    kumarsanj over 8 years ago
    Thank you Bruekers. It works fine.
    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
Cadence Guidelines

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