A printf wrapper

Discussion in 'Cadence' started by marcoballins, Aug 11, 2008.

  1. marcoballins

    marcoballins Guest

    Dear skilled cadencers,

    I'd like to write a wrapper for the printf() function. The problem is
    that I do not know how to have a variable number argument. I tried
    with @rest:

    procedure( myPrint(port str @rest args)
    fprintf(port str args)
    newline(port)
    )

    however this won't work because args is a list and fprintf (or printf)
    complains about that.
    How can I achieve this task?

    Thanks,
    mb
     
    marcoballins, Aug 11, 2008
    #1
  2. marcoballins

    S. Badel Guest

    dear mb,

    you can use apply() to make up the list of arguments to pass to a function.

    in your example, apply('fprintf append(list(port str) args))

    would this do the trick ?

    cheers,
    Stéphane
     
    S. Badel, Aug 12, 2008
    #2
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.