Visual G : What does the character ' mean and how does it influence the results?

Asked

Viewed 557 times

2

I’m learning to use the visual g through this stuff here: http://eletrica.ufpr.br/~Rogerio/visualg/Help/linguagem2.htm

In this particular code I have a very small question, which contains no answers neither in the material nor in google.

algoritmo "exemplo"
var x: real
y: inteiro
a: caractere
l: logico
inicio
x <- 2.5
y <- 6
a <- "teste"
l <- VERDADEIRO
escreval ("x", x:4:1, y+3:4) // Escreve: x 2.5    9
escreval (a, "ok")           // Escreve: testeok (e depois pula linha)
escreval (a, " ok")          // Escreve: teste ok (e depois pula linha)
escreval (a + " ok")         // Escreve: teste ok (e depois pula linha)
escreva (l)                  // Escreve: VERDADEIRO
fimalgoritmo

What I don’t understand is how x(2.5):4:1 equals 2.5 ? Type, the character ' : ' has no value and why the numbers 4 and 1?

I didn’t understand what this character ' means and how it influences or not the results.

  • I found the documentation confusing, I preferred to see which language was based on this behavior and look there.

1 answer

0


By the documentation, the is following the Pascal model of writing. Anything, see the documentation in Pascal

About the code: x:4:1 means four characters at the most on the output, one after the decimal place; if the number does not fill in the four characters, put blank spaces. In the linked Freepascal documentation, the output would be 2.5, with a space to the left of the printed number.

To see the effect, try printing 5.3:7:2, must print 5.30. Three spaces before the number, two boxes to decimals. Another interesting test is to print 5.29:3:1, where the outflow (if rounded) is 5.3; three characters, a single decimal place.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.