Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Why can't Mata code output?

    I have a file called hellox.ado that contains the following code:

    Code:
    program hellox
    version 15
    mata: hello()
    end
    version 15
    mata:
    void hello()
    {
    printf("test output\n")
    }
    end
    Then I use the following code to call it in a do-file:

    Code:
    clear all
    do hellox.ado
    Why doesn't it output "test output"?

  • #2
    Code:
    do hellox.ado
    defines the program; it does not run it. To see output, run your program with

    Code:
    hellox
    Defining the program with a do command is legal but not needed. .ado means automatic do file and that means that do is not needed.

    Comment


    • #3
      I followed your advice, and the code is now running correctly. However, I have a doubt. Thank you very much. Let me express my understanding once again, and please help me correct any mistakes.
      In the ado file, the line "mata: hello()" does indeed call the function within the "hellox" command. However, running "do hellox.ado" only defines and loads the "hellox" command into memory, so it doesn't actually execute the "hellox" command. On the other hand, I can directly write the command as follows:
      Code:
      clear all
      hellox

      Comment


      • #4
        That's an accurate rewriting of #2.

        Comment

        Working...
        X