Search code examples
ampl

How to print in the same line in AMPL


Good evening everyone! I have this silly question but I cannot find the solution in the language manual. It starts to seem that it is not possible. Until now I have tried using:

print "Write something";
print "This is not in the same line";

I know I can concatenate strings with & but that does not solve my use case. Does anyone know how to print in the same line in AMPL?


Solution

  • printf "Write something";
    printf "This is in the same line";
    printf "\nThis is a new line";
    

    See AMPL printf documentation for more detail on options. print is good for simple output statements, printf gives you more power to micro-manage how the output prints.