Ayuda, archivos ... - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: Non-English (
https://sampforum.blast.hk/forumdisplay.php?fid=9)
+--- Forum: Languages (
https://sampforum.blast.hk/forumdisplay.php?fid=33)
+---- Forum: Español/Spanish (
https://sampforum.blast.hk/forumdisplay.php?fid=29)
+---- Thread: Ayuda, archivos ... (
/showthread.php?tid=468030)
Ayuda, archivos ... -
OTACON - 06.10.2013
Buenas a todos, me podrian ayudar con esto, como podria hacer lo siguiente: (es ke no utilizo mucho el include File y sus funciones y estoy medio dudoso) . ![Sad](images/smilies/sad.gif)
quiero crear una cantidad de archivos de textos y despues leerlos en un dialogo con listitem y ke cada item sea un archivo de texto (osea ke sea el nombre del archivo).
si me pueden ayudar se los agradezco mucho.
desde ya muchas gracias, saludos.
Re: Ayuda, archivos ... -
zSuYaNw - 06.10.2013
Leer lнnea por lнnea ?
Respuesta: Re: Ayuda, archivos ... -
OTACON - 06.10.2013
Quote:
Originally Posted by zSuYaNw
|
no, archivo por archivo.
Re: Respuesta: Re: Ayuda, archivos ... -
zSuYaNw - 06.10.2013
Quote:
Originally Posted by OTACON
no, archivo por archivo.
|
Tienes que hacer un archivo (Allfiles.txt) que contiene su nombres ..
Respuesta: Ayuda, archivos ... -
OTACON - 06.10.2013
hice esto, para crearl os archivos no hay problema, pero tengo problemas para leerlos
.
pawn Code:
//para crear
new texto[2][100], File:archivo;
for(new index=1; index<20; index++) {
format(texto[0],50, "/carpeta1/carpeta2/textos[%02d].txt", index);
archivo = fopen(texto[0], io_write);
if(archivo) {
format(texto[1],50, "archivo [%02d] escrito con exito!.", index);
fwrite(archivo, texto[1]);
fclose(archivo);
}
}
//para leer
new texto[2][100], File:archivo;
for(new index=1; index<20; index++) {
format(texto[0],50, "/carpeta1/carpeta2/textos[%02d].txt", index);
while(fread(archivo, texto[0])) {
format(archivo[1],50, "textos[%02d] \n", index);
strcat(texto[0], texto[1]);
ShowPlayerDialog(playerid, MENU_ID, DIALOG_STYLE_LIST, "Titulo", texto[0], "Seleccionar", "Cancelar");
}
fclose(archivo);
}
Re: Ayuda, archivos ... -
zSuYaNw - 06.10.2013
Para crear:
pawn Code:
static
File: Arquivo,
string[200],
zstr[50]
;
for(new i; i != 20; ++i){
format(zstr, 50, "textos[%02d].txt", i);
Arquivo = fopen(zstr, io_write);
if(Arquivo){
format(string, 200, "archivo [%02d] escrito con exito!.", i);
fwrite(Arquivo, string);
}
fclose(Arquivo);
}
Para Leer
pawn Code:
static
File: Arquivo,
zstr[100]
;
for(new i; i != 20; ++i){
format(zstr, 50, "textos[%02d].txt", i);
if(fexist(zstr)){
Arquivo = fopen(zstr, io_read);
static
sTe[100]
;
while(fread(Arquivo, sTe)){
printf("Archivo: %s - %s", zstr, sTe);
}
}
}