Callback problem in Skill

Discussion in 'Cadence' started by camelot, Jun 28, 2005.

  1. camelot

    camelot Guest

    Hello,
    When I call this procedure

    procedure(MigEditRuleFile()
    prog(()
    edit "test.txt"
    ))

    from a form button callback nothing append but when I type the command
    edit "test.txt" in CIW the command is executed. Is there a solution to
    this question?

    Camelot
     
    camelot, Jun 28, 2005
    #1
  2. Can you give the details how you implemt it
    in your callback button and what kind of form it is?

    Bernd
     
    Bernd Fischer, Jun 28, 2005
    #2
  3. camelot

    S. Badel Guest

    please try it with
    edit("test.txt")
    or
    (edit "test.txt")

    edit "test.txt" is not proper skill code.
    it works within the CIW, and it happens to work in your prog()
    by the result of a side effect: edit is taken to be a label,
    (prog allows to label statements and to jump around with go())
    and "test.txt" is a string constant. Thus, it does nothing.

    cheers,
    stéphane
     
    S. Badel, Jun 28, 2005
    #3
  4. camelot

    Tom_Ding Guest

    edit is a command. It can not be used in SKILL code directly.

    Tom
     
    Tom_Ding, Jun 28, 2005
    #4
  5. Surly it can, be used in SKILL code directly,
    because it is a SKILL function!

    I don't know what you mean with a command?

    Bernd

    edit(
    S_object
    [ g_loadFlag ]
    )
    => x_childId

    Description

    Edits a file, function, or variable. This function only works if you are in
    graphical mode. This is an nlambda function.

    edit brings up an editor window in a separate process and thus doesn't lock up
    the CIW. If the object being edited is a function that was loaded after debug
    mode was turned on, then edit opens up the file that contains the function. If
    the editor is vi or emacs it jumps to the start of the function. If g_loadFlag
    is t the file is loaded into SKILL when the editor is exited. Be sure the editor
    variable is set up properly if you are using an editor other than vi or emacs.
    Arguments

    S_object
    If you are editing a file, the object you are editing must be a string. If
    you are editing a function or variable, it must be an unquoted symbol.

    g_loadFlag
    Determines whether to load the file after the editor window is exited.
    Valid values: t or nil
    Default: nil.

    Value Returned

    x_childId
    Integer identifying the process spawned for the editor.
     
    Bernd Fischer, Jun 28, 2005
    #5
  6. Stephane is quite right. Omitting the parentheses when you have a
    sub-expression leads to incorrect behaviour.

    In this case it is referencing the value of a variable called "edit", and then
    the return value of the function will be the literal string "test.txt". You
    need to put in the parentheses.

    I always describe missing out the parentheses as "lazy" mode (to
    distinguish it from "C" mode - edit("test.txt") or "LISP" mode -
    (edit "test.txt") . You should only ever use lazy mode when typing functions
    in the CIW, and even then only when you don't want to do something with the
    return value of the function.

    Regards,

    Andrew.
     
    Andrew Beckett, Jun 29, 2005
    #6
  7. camelot

    camelot Guest

    Thank you. Now it works.

    Camelot
     
    camelot, Jun 29, 2005
    #7
  8. camelot

    S. Badel Guest

    Andrew,

    this is detail, but
    then it should complain that edit variable doesn't exists. It does it in fact if
    you replace the prog with a let, but with the prog it doesn't.
    I think what happens is, as i said, the symbol 'edit' is taken for a label.
    According to SKILL reference, prog always return nil, unless you specify a return
    value with a call to return().
    again, it would work with a let, since let returns the value of the last statement,
    but not with a prog.

    stéphane


    procedure( test() let( () edit "test.txt" ) )
    => test
    test()
    => *Error* eval: unbound variable - edit

    procedure( test() prog( () edit "test.txt" ) )
    => test
    test()
    => nil

    procedure( test(n) prog( ( x ) edit unless(x x=1) x++ when(x<n go(edit)) return(x) ) )
    => test
    test(5)
    => 5
     
    S. Badel, Jun 29, 2005
    #8
  9. Stephane,

    For some reason I had a temporary mind glitch and didn't read your previous
    reply properly, nor indeed the original question. You are quite right.

    I have a pathological hatred of the go() function, so that's probably what
    threw me ;-)

    Andrew.
     
    Andrew Beckett, Jun 29, 2005
    #9
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.