screen on and screen off

Hi, can you please illustrate maybe with a numerical example when to use screen on and screen off? And describe what is the benefit of using them? Thank you!

1 Answer



Screen on and screen off are used to toggle the printing to the Program Input/Output window on and off. This can be useful in cases when printing to the screen is distracting from what you actually want to view or when screen printing might slow a program down.

For me, this often comes up when running simulations or looping through something. For example, suppose we want to simulate linear data and estimate the coefficients. We will run the simulation 1000 times. I don't want to see the printout from the olsmt procedure, so I turn the screen off just before calling olsmt and turn the screen on again after calling olsmt.

Note that I could have chosen many places to put the screen off and screen on to have the same effects. The key points are that:

  1. I turn the screen off in the code before any procedures which produce printout that I don't want printed to screen.
  2. I turn the screen on before anything that I do want printed to the screen.
iters = 1000;

//  Generate x data
x = 3*rndn(150,1) ~ 2.5*rndn(150,1) ~ 0.63*rndn(150,1);
x = ones(rows(x),1)~x;

// Coefficients
b = { 3.2 0.5 3.2 1.2};
b_mat = zeros(iters, cols(b));

// Loop through iterations
for i(1, iters, 1);

    // Set y matrix
    y = x*b' + rndn(rows(x), 1);

    // Declare 'ols_out' to be an olsmtOut structure
    // to hold the results of the computations
    struct olsmtOut ols_out;

    // Call the olsmt procedure
    screen off;
    ols_out = olsmt("", y, x);
    screen on;

    b_mat[i, .] = ols_out.b';


print "Mean coefficient estimate: ";



Your Answer

You must login to post answers.

Have a Specific Question?

Get a real answer from a real person

Need Support?

Get help from our friendly experts.

Try GAUSS for 30 days for FREE

See what GAUSS can do for your data

© Aptech Systems, Inc. All rights reserved.

Privacy Policy