There is the possibility to save data to a file in . txt in Visualg!
Visualg allows data to be stored in a text file, obtaining data from it when executing the commands leia
.
This feature works as follows:
(According to this source)
- If there is no file with specified name, Visualg will make a
reading data through typing, storing the data read in this
file, in the order in which they are provided.
- If the file exists, Visualg will get the data from this file until it arrives
to its end. From then on, it will read data through typing.
- Only one file command can be employed in each pseudocode, and it
should be in the declarations section (depending on the "success" of this
feature, in future versions it can be improved...).
- If a path is not provided, Visualg will search for this file
in the current workbook (usually, it is the folder where the program
VISUALG.EXE is). This command does not provide a standard extension; therefore, the
file name specification must be complete, including with your
extension
(e.g. txt, . dat, etc.).
The syntax of the command is:
arquivo < nome-de-arquivo >
<nome-de-arquivo>
is a constant character (double quotes). See the following example:
algoritmo "lendo do arquivo"
arquivo "teste.txt"
var x,y: inteiro
inicio
para x de 1 ate 5 faca
leia (y)
fimpara
fimalgoritmo
EXTRA
Your variables can also be stored in a character type matrix and test it in the query and implement the code with a menu. (With register and consultation)
algoritmo "lendo do arquivo"
arquivo "teste.txt"
var x,y,i,j: inteiro
char opcao
vetor mat[5][5]
inicio
repita
escreval("MENU")
escreval("A- GRAVAR ARQUIVOS")
escreval("B- PROCURAR ARQUIVOS")
escreval("s-Sair")
escolha(opcao)
caso 'A'
escreval("Leia matriz:")
para i de 1 ate 5 faca
para j de 1 ate 5 faca
leia(m[i][j])
fimpara
fimpara
caso 'B'
// compare com a variável que quiser
leia(x)
para i de 1 ate 5 faca
para j de 1 ate 5 faca
se(x=m[i][j]) entao
...
fimse
fimpara
fimpara
ate(opcao='s')
fimescolha
fimalgoritmo
You can use the file command, but maybe it is not the best option.
For with every command leia()
that Visualg finds, he will be reading this file and playing in the variable that is in leia()
. Translating... Until you reach the end of the file, all leia()
will is directed to the file... it will not be possible to read any user data via keyboard while the file is not finished.
If you are implementing with file, always remember the clean screen command may be useful.
try to post your code so I help you better.
– Maurício Z.B
I was able to help you?
– Maurício Z.B