GMBR
Gostaria de reagir a esta mensagem? Crie uma conta em poucos cliques ou inicie sessão para continuar.
Entrar

Esqueci-me da senha

Últimos assuntos
» Servidor de Discord do fórum?
por Super Games Ontem à(s) 01:27

» Problemas com a caixa de diálogo, ela é pequena e as letras não cabem dentro
por Rukasu777 Qui 16 maio 2024, 18:10

» Problemas com particulas
por RastaMaan Dom 12 maio 2024, 17:03

» Problema ao entrar por uma porta e voltar por ela
por aminaro Seg 06 maio 2024, 10:08

» Alguém aqui já ganha dinheiro com seus games?
por theguitarmester Ter 30 Abr 2024, 11:43

» Colisões não funcionando
por theguitarmester Ter 30 Abr 2024, 10:16

» Como ajustar velocidade de cada frame da animação no game maker
por pequetux Sex 26 Abr 2024, 16:45

» Preciso de ajuda
por AftonDuGrau Dom 21 Abr 2024, 20:18

» Como faz o evento drawn GUI, não se repetir?
por aminaro Sex 19 Abr 2024, 20:30

» PROBLEMAS COM FÍSICAS DE ÁGUA
por aminaro Ter 16 Abr 2024, 10:07

» Retorno da GMBR!!!
por Ralphed Sex 12 Abr 2024, 22:45

» JOGADOR PARANDO NO AR QUANDO ATACA
por aminaro Qua 10 Abr 2024, 13:51

» Problemas com texto interativo
por Kaaru72 Dom 07 Abr 2024, 11:31

» Erro escondido e indecifrável
por dev_gabize.azv Qui 04 Abr 2024, 10:11

» Mudar cor de apenas uma palavra
por Ralphed Sáb 30 Mar 2024, 00:39

» Procuro Programador de game maker
por Wou Sex 15 Mar 2024, 10:27

» Mod APK
por gamerainha Qua 13 Mar 2024, 06:30

» Aceito pedidos de sprites (Com exemplos meus)
por Sevilha Qua 28 Fev 2024, 12:17

» Inventário simples
por Isquilo_Roedor Qui 22 Fev 2024, 15:18

» Problemas na programaçnao de inimigo [jogo DOOM LIKE]
por Black Mirror Dom 11 Fev 2024, 13:34

» ANDROID MULTI TOUCH
por DiegoBr Dom 04 Fev 2024, 12:13

» Save e Load Json
por Klinton Rodrigues Qui 25 Jan 2024, 11:12

» Colisão com mais de um objeto
por aminaro Seg 22 Jan 2024, 15:02

» Oi sou novo aqui
por Thiago Silveira Alexandre Sáb 20 Jan 2024, 20:55

» Como acessar conteudo comprado no marketplace
por macmilam Sex 19 Jan 2024, 07:42


[Resolvido]Dúvida com ficheiros de texto

+2
Super Games
afonso_silva
6 participantes

Ir para baixo

[Resolvido]Dúvida com ficheiros de texto Empty [Resolvido]Dúvida com ficheiros de texto

Mensagem por afonso_silva Sex 22 Out 2010, 20:18

Oi pessoal. Sei que ultimamente tenho colocado muitas questões, mas estou a criar um programa e preciso realmente da vossa ajuda. Então é o seguinte:
Como é que eu faço para que quando carrego num botão, abra-se uma janela para escolher um ficheiro de texto(com aquela função get_open_filename), e depois esse texto seja mostrado na tela, mas com a variavel keyboard_string, para que o texto surja na minha caixa de texto?
afonso_silva
afonso_silva

Data de inscrição : 29/05/2010
Reputação : 0
Número de Mensagens : 147
Prêmios : [Resolvido]Dúvida com ficheiros de texto Empty

Medalhas x 0 Tutoriais x 0 Moedas x 0

Ouro x 0 Prata x 0 Bronze x 0

Insignia 1 x 0 Insignia 2 x 0 Insignia 3 x 0

Ir para o topo Ir para baixo

[Resolvido]Dúvida com ficheiros de texto Empty Re: [Resolvido]Dúvida com ficheiros de texto

Mensagem por Super Games Sex 22 Out 2010, 22:15

Tente colocar algo como draw_text.

Espero ter ajudado...
Super Games
Super Games

Games Ranking : Nota C

Notas recebidas : C
Data de inscrição : 10/06/2010
Reputação : 36
Número de Mensagens : 2800
Prêmios : [Resolvido]Dúvida com ficheiros de texto Empty

Medalhas x 0 Tutoriais x 0 Moedas x 0

Ouro x 0 Prata x 1 Bronze x 0

Insignia 1 x 0 Insignia 2 x 0 Insignia 3 x 0
Plataformas :
  • Game Maker 8.0 ou 8.1
  • Game Maker Studio 1.4
  • Game Maker Studio 2.0
  • Java
  • Godot
  • Javascript
  • C ou C++


Ir para o topo Ir para baixo

[Resolvido]Dúvida com ficheiros de texto Empty Re: [Resolvido]Dúvida com ficheiros de texto

Mensagem por Janx Sex 22 Out 2010, 22:27

Super Games escreveu:Tente colocar algo como draw_text.

Espero ter ajudado...

Nesse caso seria melhor nem postar ¬¬"
Só poste se você realmente souber como resolver o problema, não fique supondo soluções! Isso só atrapalha. Na próxima vou considerar um FLOOD.
Avisado por MP.


A função get_open_filename retorna o diretorio+nome do arquivo escolhido. Então basta salvar isso numa variavel dessa forma:
arquivo = get_open_filename(....);

Depois você pode manipular como quiser, se quer mudar a variavel keyboard_string para esse valor, você pode simplesmente fazer:
keyboard_string = get_open_filename(....);

OBS: A função retorna uma string vazia caso a pessoa aperte o botão "Cancelar".
Janx
Janx

Data de inscrição : 24/05/2008
Reputação : 14
Número de Mensagens : 2417
Prêmios : [Resolvido]Dúvida com ficheiros de texto Empty

Medalhas x 0 Tutoriais x 0 Moedas x 0

Ouro x 0 Prata x 2 Bronze x 0

Insignia 1 x 0 Insignia 2 x 0 Insignia 3 x 0

Ir para o topo Ir para baixo

[Resolvido]Dúvida com ficheiros de texto Empty Re: [Resolvido]Dúvida com ficheiros de texto

Mensagem por Gabreel Sáb 23 Out 2010, 00:41

Janx, creio que ele queira pegar o texto do arquivo, e não o título.. Mad

Se for isso, no Help do GM:
file_text_open_read(fname) Opens the file with the indicated name for reading. The function returns the id of the file that must be used in the other functions. You can open multiple files at the same time (32 max). Don't forget to close them once you are finished with them.
file_text_open_write(fname) Opens the indicated file for writing, creating it if it does not exist. The function returns the id of the file that must be used in the other functions.
file_text_open_append(fname) Opens the indicated file for appending data at the end, creating it if it does not exist. The function returns the id of the file that must be used in the other functions.
file_text_close(fileid) Closes the file with the given file id.
file_text_write_string(fileid,str) Writes the string to the file with the given file id.
file_text_write_real(fileid,x) Write the real value to the file with the given file id. (As separator between the integer and decimal part always a dot is used.
file_text_writeln(fileid) Write a newline character to the file.
file_text_read_string(fileid) Reads a string from the file with the given file id and returns this string. A string ends at the end of line.
file_text_read_real(fileid) Reads a real value from the file and returns this value.
file_text_readln(fileid) Skips the rest of the line in the file and starts at the start of the next line.
file_text_eof(fileid) Returns whether we reached the end of the file.
file_text_eoln(fileid) Returns whether we reached the end of a line in the file.

Meu inglês e meu tempo estão ruins, espero ter ajudado! Flw
Gabreel
Gabreel

Data de inscrição : 02/10/2009
Reputação : 52
Número de Mensagens : 2232
Prêmios : [Resolvido]Dúvida com ficheiros de texto Empty

Medalhas x 0 Tutoriais x 0 Moedas x 0

Ouro x 0 Prata x 0 Bronze x 0

Insignia 1 x 0 Insignia 2 x 0 Insignia 3 x 0
Plataformas :
  • Game Maker 8.0 ou 8.1
  • Game Maker Studio 1.4
  • Game Maker Studio 2.0
  • Javascript
  • Outros


Ir para o topo Ir para baixo

[Resolvido]Dúvida com ficheiros de texto Empty Re: [Resolvido]Dúvida com ficheiros de texto

Mensagem por afonso_silva Sáb 23 Out 2010, 08:19

·ßieL escreveu:Janx, creio que ele queira pegar o texto do arquivo, e não o título.. Mad

Se for isso, no Help do GM:
file_text_open_read(fname) Opens the file with the indicated name for reading. The function returns the id of the file that must be used in the other functions. You can open multiple files at the same time (32 max). Don't forget to close them once you are finished with them.
file_text_open_write(fname) Opens the indicated file for writing, creating it if it does not exist. The function returns the id of the file that must be used in the other functions.
file_text_open_append(fname) Opens the indicated file for appending data at the end, creating it if it does not exist. The function returns the id of the file that must be used in the other functions.
file_text_close(fileid) Closes the file with the given file id.
file_text_write_string(fileid,str) Writes the string to the file with the given file id.
file_text_write_real(fileid,x) Write the real value to the file with the given file id. (As separator between the integer and decimal part always a dot is used.
file_text_writeln(fileid) Write a newline character to the file.
file_text_read_string(fileid) Reads a string from the file with the given file id and returns this string. A string ends at the end of line.
file_text_read_real(fileid) Reads a real value from the file and returns this value.
file_text_readln(fileid) Skips the rest of the line in the file and starts at the start of the next line.
file_text_eof(fileid) Returns whether we reached the end of the file.
file_text_eoln(fileid) Returns whether we reached the end of a line in the file.

Meu inglês e meu tempo estão ruins, espero ter ajudado! Flw

Sim, é isso que eu quero fazer. Eu tenho o seguinte código:
Código:
txt = get_open_filename('Arquivos de texto|*.txt','')
file_text_open_read(txt)
keyboard_string = txt

No entanto dá sempre erro, e não acontece nada. Se me puder ajudar...
afonso_silva
afonso_silva

Data de inscrição : 29/05/2010
Reputação : 0
Número de Mensagens : 147
Prêmios : [Resolvido]Dúvida com ficheiros de texto Empty

Medalhas x 0 Tutoriais x 0 Moedas x 0

Ouro x 0 Prata x 0 Bronze x 0

Insignia 1 x 0 Insignia 2 x 0 Insignia 3 x 0

Ir para o topo Ir para baixo

[Resolvido]Dúvida com ficheiros de texto Empty Re: [Resolvido]Dúvida com ficheiros de texto

Mensagem por Kabeção Sáb 23 Out 2010, 10:43

afonso_silva escreveu:Sim, é isso que eu quero fazer. Eu tenho o seguinte código:
Código:
txt = get_open_filename('Arquivos de texto|*.txt','')
file_text_open_read(txt)
keyboard_string = txt

No entanto dá sempre erro, e não acontece nada. Se me puder ajudar...
file_text_open retorna um número para identificar qual arquivo você abriu.
Assim como fez em "txt = get_open_filename('Arquivos de texto|*.txt','')" você tem que usar uma variável para guardar o indice do arquivo carregado.
Código:
f = file_text_open_read(txt);
Você precisa ler o que esta escrito no arquivo e para isso se usa file_text_write_string(indice) e file_text_readln(f) para ir para a próxima linha, por exemplo:
Código:
texto = file_text_write_string(f);  // lé primeira linha do arquivo
file_text_readln(f) // pula para a próxima linha
texto += file_text_write_string(f); // adiciona a segunda linha do arquivo
// ...
Para ler todas as linhas do arquivo você pode usar um loop:
Código:
txt = '';
do
{
    txt += file_text_read_string(f);  // adicionar linha
    file_text_readln(f); // passar a próxima
}
until file_text_eof(f); // parar se esta na ultima linha
file_text_eof(indice) checa se as linhas do texto acabaram.

No final o script ficaria assim:
Código:
caminho = get_open_filename('Arquivos de texto|*.txt',''); // caminho do arquivo
f = file_text_open_read(caminho); // carregar

txt = '';
do
{
    txt += file_text_read_string(f);  // adicionar linha
    file_text_readln(f); // passar a próxima
}
until file_text_eof(f); // parar se esta na ultima linha
Kabeção
Kabeção

Games Ranking : Sem avaliações

Data de inscrição : 08/06/2008
Reputação : 100
Número de Mensagens : 2314
Prêmios : [Resolvido]Dúvida com ficheiros de texto Empty

Medalhas x 0 Tutoriais x 7 Moedas x 0

Ouro x 3 Prata x 0 Bronze x 1

Insignia 1 x 0 Insignia 2 x 0 Insignia 3 x 0

http://blackcapapps.blogspot.com.br/

Ir para o topo Ir para baixo

[Resolvido]Dúvida com ficheiros de texto Empty Re: [Resolvido]Dúvida com ficheiros de texto

Mensagem por Jiraya Dom 24 Out 2010, 15:26

sei que n precisa mais de ajuda sobre isso, mas vou dar minha "contribuição".
crie um script e de o seguinte nome a ele
//===OpenFile====//
var _file,_open,_stream;
_file=argument0;
if (file_exists(_file))
{
_open=file_text_open_read(_file);
_stream='';
for (i=0;!file_text_eof(_open);i+=1;)
{
_stream+=file_text_read_string(_open)+' ';
file_text_readln(_open);
}
file_text_close(_open);
return _stream;
}else
{
return 0;
}
//como usar
para usar esse script
basta criar um script colocar esse código la
e dar o nomeOpenFile();
esse script abriar e ira ler todo o conteudo do arquivo
com o simples comando
var str;
str=OpenFile("arquivo.txt");
//isso fará com que a variavel str armazene todo o conteudo do arquivo!
:­D
Jiraya
Jiraya

Games Ranking : Nota A

Notas recebidas : A+A
Data de inscrição : 20/03/2010
Reputação : 108
Número de Mensagens : 1134
Prêmios : [Resolvido]Dúvida com ficheiros de texto Empty

Medalhas x 0 Tutoriais x 1 Moedas x 0

Ouro x 1 Prata x 0 Bronze x 1

Insignia 1 x 0 Insignia 2 x 0 Insignia 3 x 0

https://www.facebook.com/seito.washiro.7

Ir para o topo Ir para baixo

[Resolvido]Dúvida com ficheiros de texto Empty Re: [Resolvido]Dúvida com ficheiros de texto

Mensagem por afonso_silva Dom 24 Out 2010, 17:46

Obrigadão Jiraya e Kabeção. Era mesmo isso que eu queria saber. Alguém que tranque o tópico please
afonso_silva
afonso_silva

Data de inscrição : 29/05/2010
Reputação : 0
Número de Mensagens : 147
Prêmios : [Resolvido]Dúvida com ficheiros de texto Empty

Medalhas x 0 Tutoriais x 0 Moedas x 0

Ouro x 0 Prata x 0 Bronze x 0

Insignia 1 x 0 Insignia 2 x 0 Insignia 3 x 0

Ir para o topo Ir para baixo

[Resolvido]Dúvida com ficheiros de texto Empty Re: [Resolvido]Dúvida com ficheiros de texto

Mensagem por Conteúdo patrocinado


Conteúdo patrocinado


Ir para o topo Ir para baixo

Ir para o topo

- Tópicos semelhantes

 
Permissões neste sub-fórum
Não podes responder a tópicos