Search code examples
vdm++

Printing to console in VDM++?


How do I print text or values to the console to validate that my model is working correctly?

I would like to do something like this:

class Main
operations
    public Run: () ==> ()
    Run() ==
        print "Text"
        print mon.Func()
end Main

It seems to be possible, but I just cant figure out how to do it.


Solution

  • Nick Battle answered my question but for other beginners to VDM, there is missing a detail to his answer, how to include libraries.

    Before one can use the IO library, you first have to include it. I am using Overture and to include libraries into your project, you have to right-click on the project in the side menu and press New > Add VDM Library. You can then choose which libraries you want to include in a menu that pops up. Here you choose IO.

    After this you should be able to print out values using the IO`println(val) function.